sqlframe 3.38.0__py3-none-any.whl → 3.38.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sqlframe/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '3.38.0'
21
- __version_tuple__ = version_tuple = (3, 38, 0)
20
+ __version__ = version = '3.38.2'
21
+ __version_tuple__ = version_tuple = (3, 38, 2)
@@ -14,6 +14,7 @@ from sqlglot.helper import flatten as _flatten
14
14
 
15
15
  from sqlframe.base.column import Column
16
16
  from sqlframe.base.decorators import func_metadata as meta
17
+ from sqlframe.base.exceptions import UnsupportedOperationError
17
18
  from sqlframe.base.util import (
18
19
  get_func_from_session,
19
20
  )
@@ -81,9 +82,13 @@ def least(*cols: ColumnOrName) -> Column:
81
82
  return Column.invoke_expression_over_column(cols[0], expression.Least)
82
83
 
83
84
 
84
- @meta(unsupported_engines="bigquery")
85
+ @meta()
85
86
  def count_distinct(col: ColumnOrName, *cols: ColumnOrName) -> Column:
86
87
  columns = [Column.ensure_col(x) for x in [col] + list(cols)]
88
+ if len(columns) > 1 and _get_session()._is_bigquery:
89
+ raise UnsupportedOperationError(
90
+ "BigQuery does not support multiple columns in countDistinct"
91
+ )
87
92
  return Column(
88
93
  expression.Count(
89
94
  this=expression.Distinct(expressions=[x.column_expression for x in columns])
@@ -2313,6 +2318,14 @@ def array_distinct(col: ColumnOrName) -> Column:
2313
2318
  if session._is_bigquery:
2314
2319
  return array_distinct_bgutil(col)
2315
2320
 
2321
+ if session._is_duckdb:
2322
+ # DuckDB's array_distinct removes nulls, but we need to preserve them
2323
+ # Check if original array contains null and append it back if needed
2324
+ original_col = Column.ensure_col(col)
2325
+ distinct_result = Column.invoke_anonymous_function(col, "ARRAY_DISTINCT")
2326
+ has_null = array_position(original_col, lit(None)) > lit(0)
2327
+ return when(has_null, array_append(distinct_result, lit(None))).otherwise(distinct_result)
2328
+
2316
2329
  return Column.invoke_anonymous_function(col, "ARRAY_DISTINCT")
2317
2330
 
2318
2331
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlframe
3
- Version: 3.38.0
3
+ Version: 3.38.2
4
4
  Summary: Turning PySpark Into a Universal DataFrame API
5
5
  Home-page: https://github.com/eakmanrq/sqlframe
6
6
  Author: Ryan Eakman
@@ -17,7 +17,7 @@ Requires-Python: >=3.9
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
19
  Requires-Dist: prettytable <4
20
- Requires-Dist: sqlglot <27.4,>=24.0.0
20
+ Requires-Dist: sqlglot <27.7,>=24.0.0
21
21
  Requires-Dist: typing-extensions
22
22
  Provides-Extra: bigquery
23
23
  Requires-Dist: google-cloud-bigquery-storage <3,>=2 ; extra == 'bigquery'
@@ -1,5 +1,5 @@
1
1
  sqlframe/__init__.py,sha256=SB80yLTITBXHI2GCDS6n6bN5ObHqgPjfpRPAUwxaots,3403
2
- sqlframe/_version.py,sha256=QFZM372YAR5g-moTkhEicbj8HSNBFoNWHFgQ704qMgo,513
2
+ sqlframe/_version.py,sha256=_jX_R7_H72gqRQJCQLfuj94JZgcTBOsYXYFp5ayxiUI,513
3
3
  sqlframe/py.typed,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
4
4
  sqlframe/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  sqlframe/base/_typing.py,sha256=b2clI5HI1zEZKB_3Msx3FeAJQyft44ubUifJwQRVXyQ,1298
@@ -9,7 +9,7 @@ sqlframe/base/dataframe.py,sha256=0diYONDlet8iZt49LC3vcmfXHAAZ2MovPL2pTXYHj2U,85
9
9
  sqlframe/base/decorators.py,sha256=IhE5xNQDkwJHacCvulq5WpUKyKmXm7dL2A3o5WuKGP4,2131
10
10
  sqlframe/base/exceptions.py,sha256=9Uwvqn2eAkDpqm4BrRgbL61qM-GMCbJEMAW8otxO46s,370
11
11
  sqlframe/base/function_alternatives.py,sha256=aTu3nQhIAkZoxrI1IpjpaHEAMxBNms0AnhS0EMR-TwY,51727
12
- sqlframe/base/functions.py,sha256=OxoeI2cEoQY79hdOnvpw0pRiaUHkU55MMpfx7_v5l70,226984
12
+ sqlframe/base/functions.py,sha256=eV0QjTvDKAArIKSMByXkGJalQtjzGVqO8-8vjQWtMvE,227677
13
13
  sqlframe/base/group.py,sha256=fBm8EUve7W7xz11nybTXr09ih-yZxL_vvEiZVE1eb_0,12025
14
14
  sqlframe/base/normalize.py,sha256=nXAJ5CwxVf4DV0GsH-q1w0p8gmjSMlv96k_ez1eVul8,3880
15
15
  sqlframe/base/operations.py,sha256=g-YNcbvNKTOBbYm23GKfB3fmydlR7ZZDAuZUtXIHtzw,4438
@@ -130,8 +130,8 @@ sqlframe/standalone/udf.py,sha256=azmgtUjHNIPs0WMVNId05SHwiYn41MKVBhKXsQJ5dmY,27
130
130
  sqlframe/standalone/window.py,sha256=6GKPzuxeSapJakBaKBeT9VpED1ACdjggDv9JRILDyV0,35
131
131
  sqlframe/testing/__init__.py,sha256=VVCosQhitU74A3NnE52O4mNtGZONapuEXcc20QmSlnQ,132
132
132
  sqlframe/testing/utils.py,sha256=PFsGZpwNUE_4-g_f43_vstTqsK0AQ2lBneb5Eb6NkFo,13008
133
- sqlframe-3.38.0.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
- sqlframe-3.38.0.dist-info/METADATA,sha256=9I9SbVhzN2eSfBMmQ1TN9QjFbWXiAKMra4AvhnqYENc,9039
135
- sqlframe-3.38.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
- sqlframe-3.38.0.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
- sqlframe-3.38.0.dist-info/RECORD,,
133
+ sqlframe-3.38.2.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
+ sqlframe-3.38.2.dist-info/METADATA,sha256=qHIvP28L4dPTMhTjSR150ZzGfGLxUZ7YZmStZUbasg8,9039
135
+ sqlframe-3.38.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
+ sqlframe-3.38.2.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
+ sqlframe-3.38.2.dist-info/RECORD,,