summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/sqlframe/default.nix
blob: d3306e2b2f66c2d4352f93c118740e2bfe06ab73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools-scm,

  # dependencies
  more-itertools,
  prettytable,
  sqlglot,
  typing-extensions,

  # optional-dependencies
  # bigquery
  google-cloud-bigquery,
  google-cloud-bigquery-storage,
  # duckdb
  duckdb,
  pandas,
  # openai
  openai,
  # postgres
  psycopg2,
  # spark
  pyspark,
  # databricks-sql-connector
  databricks-sql-connector,

  # tests
  findspark,
  pytest-forked,
  pytest-postgresql,
  pytest-xdist,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "sqlframe";
  version = "3.43.8";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "eakmanrq";
    repo = "sqlframe";
    tag = "v${version}";
    hash = "sha256-gsWA3aBolsR2zPwseHnQXSJRngXUHFGvi55UPevgUHw=";
  };

  build-system = [ setuptools-scm ];

  dependencies = [
    more-itertools
    prettytable
    sqlglot
    typing-extensions
  ];

  optional-dependencies = {
    bigquery = [
      google-cloud-bigquery
      google-cloud-bigquery-storage
    ]
    ++ google-cloud-bigquery.optional-dependencies.pandas;
    duckdb = [
      duckdb
      pandas
    ];
    openai = [ openai ];
    pandas = [ pandas ];
    postgres = [ psycopg2 ];
    spark = [ pyspark ];
    databricks = [ databricks-sql-connector ];
  };

  pythonImportsCheck = [ "sqlframe" ];

  nativeCheckInputs = [
    findspark
    pytest-forked
    pytest-postgresql
    pytest-xdist
    pytestCheckHook
  ]
  ++ lib.concatAttrValues optional-dependencies;

  disabledTests = [
    # Requires google-cloud credentials
    # google.auth.exceptions.DefaultCredentialsErro
    "test_activate_bigquery_default_dataset"
    # AttributeError: module 'sqlglot.expressions' has no attribute 'Acos'
    "test_unquoted_identifiers"
  ];

  disabledTestPaths = [
    # duckdb.duckdb.CatalogException: Catalog Error: Table Function with name "dsdgen" is not in the catalog, but it exists in the tpcds extension.
    # "tests/integration/test_int_dataframe.py"
    "tests/integration/"
  ];

  meta = {
    description = "Turning PySpark Into a Universal DataFrame API";
    homepage = "https://github.com/eakmanrq/sqlframe";
    changelog = "https://github.com/eakmanrq/sqlframe/releases/tag/${src.tag}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ GaetanLepage ];
  };
}