sqlframe 3.24.1__py3-none-any.whl → 3.26.0__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.24.1'
21
- __version_tuple__ = version_tuple = (3, 24, 1)
20
+ __version__ = version = '3.26.0'
21
+ __version_tuple__ = version_tuple = (3, 26, 0)
@@ -551,6 +551,17 @@ def sha1_force_sha1_and_to_hex(col: ColumnOrName) -> Column:
551
551
  )
552
552
 
553
553
 
554
+ def sha2_sha265(col: ColumnOrName) -> Column:
555
+ col_func = get_func_from_session("col")
556
+
557
+ return Column(
558
+ expression.Anonymous(
559
+ this="SHA256",
560
+ expressions=[col_func(col).column_expression],
561
+ )
562
+ )
563
+
564
+
554
565
  def hash_from_farm_fingerprint(*cols: ColumnOrName) -> Column:
555
566
  if len(cols) > 1:
556
567
  raise ValueError("This dialect only supports a single column for calculating hash")
@@ -1492,7 +1492,7 @@ def md5(col: ColumnOrName) -> Column:
1492
1492
  return Column.invoke_expression_over_column(col, expression.MD5)
1493
1493
 
1494
1494
 
1495
- @meta(unsupported_engines=["duckdb", "postgres"])
1495
+ @meta(unsupported_engines=["postgres"])
1496
1496
  def sha1(col: ColumnOrName) -> Column:
1497
1497
  from sqlframe.base.function_alternatives import sha1_force_sha1_and_to_hex
1498
1498
 
@@ -1504,8 +1504,18 @@ def sha1(col: ColumnOrName) -> Column:
1504
1504
  return Column.invoke_expression_over_column(col, expression.SHA)
1505
1505
 
1506
1506
 
1507
- @meta(unsupported_engines=["bigquery", "duckdb", "postgres"])
1507
+ @meta(unsupported_engines=["bigquery", "postgres"])
1508
1508
  def sha2(col: ColumnOrName, numBits: int) -> Column:
1509
+ from sqlframe.base.function_alternatives import sha2_sha265
1510
+
1511
+ session = _get_session()
1512
+
1513
+ if session._is_duckdb:
1514
+ if numBits in [256, 0]:
1515
+ return sha2_sha265(col)
1516
+ else:
1517
+ raise ValueError("This dialect only supports SHA-265 (numBits=256 or numBits=0)")
1518
+
1509
1519
  return Column.invoke_expression_over_column(col, expression.SHA2, length=lit(numBits))
1510
1520
 
1511
1521
 
@@ -2355,15 +2365,31 @@ def from_json(
2355
2365
  schema = schema.simpleString()
2356
2366
  schema = schema if isinstance(schema, Column) else lit(schema)
2357
2367
  if options is not None:
2358
- options_col = create_map([lit(x) for x in _flatten(options.items())])
2368
+ options_col = create_map([lit(str(x)) for x in _flatten(options.items())])
2359
2369
  return Column.invoke_anonymous_function(col, "FROM_JSON", schema, options_col)
2360
2370
  return Column.invoke_anonymous_function(col, "FROM_JSON", schema)
2361
2371
 
2362
2372
 
2363
- @meta(unsupported_engines=["bigquery", "duckdb", "postgres", "snowflake"])
2373
+ @meta(unsupported_engines=["bigquery", "postgres", "snowflake"])
2364
2374
  def to_json(col: ColumnOrName, options: t.Optional[t.Dict[str, str]] = None) -> Column:
2375
+ session = _get_session()
2376
+ if session._is_duckdb:
2377
+ # check if Spark options match DuckDB's default behavior
2378
+ is_spark_equivalent = (
2379
+ options
2380
+ and list(options.keys()) == ["ignoreNullFields"] # only one option specified
2381
+ and str(options.get("ignoreNullFields", "true")).lower() == "false"
2382
+ )
2383
+ if not is_spark_equivalent:
2384
+ logger.warning(
2385
+ "Options for `to_json()` ignored, since not supported in this dialect."
2386
+ + " Potential `null` values are included in the returned JSON string."
2387
+ + " This is different from Spark's default behavior."
2388
+ )
2389
+ options = None
2390
+
2365
2391
  if options is not None:
2366
- options_col = create_map([lit(x) for x in _flatten(options.items())])
2392
+ options_col = create_map([lit(str(x)) for x in _flatten(options.items())])
2367
2393
  return Column.invoke_expression_over_column(col, expression.JSONFormat, options=options_col)
2368
2394
  return Column.invoke_expression_over_column(col, expression.JSONFormat)
2369
2395
 
@@ -2373,7 +2399,7 @@ def schema_of_json(col: ColumnOrName, options: t.Optional[t.Dict[str, str]] = No
2373
2399
  if isinstance(col, str):
2374
2400
  col = lit(col)
2375
2401
  if options is not None:
2376
- options_col = create_map([lit(x) for x in _flatten(options.items())])
2402
+ options_col = create_map([lit(str(x)) for x in _flatten(options.items())])
2377
2403
  return Column.invoke_anonymous_function(col, "SCHEMA_OF_JSON", options_col)
2378
2404
  return Column.invoke_anonymous_function(col, "SCHEMA_OF_JSON")
2379
2405
 
@@ -2383,7 +2409,7 @@ def schema_of_csv(col: ColumnOrName, options: t.Optional[t.Dict[str, str]] = Non
2383
2409
  if isinstance(col, str):
2384
2410
  col = lit(col)
2385
2411
  if options is not None:
2386
- options_col = create_map([lit(x) for x in _flatten(options.items())])
2412
+ options_col = create_map([lit(str(x)) for x in _flatten(options.items())])
2387
2413
  return Column.invoke_anonymous_function(col, "SCHEMA_OF_CSV", options_col)
2388
2414
  return Column.invoke_anonymous_function(col, "SCHEMA_OF_CSV")
2389
2415
 
@@ -2391,7 +2417,7 @@ def schema_of_csv(col: ColumnOrName, options: t.Optional[t.Dict[str, str]] = Non
2391
2417
  @meta(unsupported_engines=["bigquery", "duckdb", "postgres", "snowflake"])
2392
2418
  def to_csv(col: ColumnOrName, options: t.Optional[t.Dict[str, str]] = None) -> Column:
2393
2419
  if options is not None:
2394
- options_col = create_map([lit(x) for x in _flatten(options.items())])
2420
+ options_col = create_map([lit(str(x)) for x in _flatten(options.items())])
2395
2421
  return Column.invoke_anonymous_function(col, "TO_CSV", options_col)
2396
2422
  return Column.invoke_anonymous_function(col, "TO_CSV")
2397
2423
 
@@ -166,6 +166,7 @@ from sqlframe.base.functions import rpad as rpad
166
166
  from sqlframe.base.functions import rtrim as rtrim
167
167
  from sqlframe.base.functions import second as second
168
168
  from sqlframe.base.functions import sequence as sequence
169
+ from sqlframe.base.functions import sha1 as sha1
169
170
  from sqlframe.base.functions import shiftLeft as shiftLeft
170
171
  from sqlframe.base.functions import shiftleft as shiftleft
171
172
  from sqlframe.base.functions import shiftRight as shiftRight
@@ -194,6 +195,7 @@ from sqlframe.base.functions import sumDistinct as sumDistinct
194
195
  from sqlframe.base.functions import tan as tan
195
196
  from sqlframe.base.functions import timestamp_seconds as timestamp_seconds
196
197
  from sqlframe.base.functions import to_date as to_date
198
+ from sqlframe.base.functions import to_json as to_json
197
199
  from sqlframe.base.functions import to_timestamp as to_timestamp
198
200
  from sqlframe.base.functions import to_unix_timestamp as to_unix_timestamp
199
201
  from sqlframe.base.functions import toDegrees as toDegrees
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlframe
3
- Version: 3.24.1
3
+ Version: 3.26.0
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 <26.10,>=24.0.0
20
+ Requires-Dist: sqlglot <26.12,>=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'
@@ -39,7 +39,7 @@ Requires-Dist: pytest-forked ; extra == 'dev'
39
39
  Requires-Dist: pytest-postgresql <8,>=6 ; extra == 'dev'
40
40
  Requires-Dist: pytest-xdist <3.7,>=3.6 ; extra == 'dev'
41
41
  Requires-Dist: pytest <8.4,>=8.2.0 ; extra == 'dev'
42
- Requires-Dist: ruff <0.10,>=0.4.4 ; extra == 'dev'
42
+ Requires-Dist: ruff <0.12,>=0.4.4 ; extra == 'dev'
43
43
  Requires-Dist: types-psycopg2 <3,>=2.9 ; extra == 'dev'
44
44
  Provides-Extra: docs
45
45
  Requires-Dist: mkdocs-include-markdown-plugin ==6.0.6 ; extra == 'docs'
@@ -1,5 +1,5 @@
1
1
  sqlframe/__init__.py,sha256=SB80yLTITBXHI2GCDS6n6bN5ObHqgPjfpRPAUwxaots,3403
2
- sqlframe/_version.py,sha256=bOjc-tAPBepEtx0iEev4SZqKYnCU7LBd6gdTvVgKhf4,513
2
+ sqlframe/_version.py,sha256=O47f8PhfWsbiZ4mjHJkrL81FZEFxis7lNo0FJknkGus,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
@@ -8,8 +8,8 @@ sqlframe/base/column.py,sha256=AG9Z_6RNhVxLhLU29kRCgzMgDNSm-_GFg96xLqk1-bs,19838
8
8
  sqlframe/base/dataframe.py,sha256=OgEUlDI5Y4rWrVngW5LttCUMC40WR-Pyr5af6aqbMNU,84028
9
9
  sqlframe/base/decorators.py,sha256=ms-CvDOIW3T8IVB9VqDmLwAiaEsqXLYRXEqVQaxktiM,1890
10
10
  sqlframe/base/exceptions.py,sha256=9Uwvqn2eAkDpqm4BrRgbL61qM-GMCbJEMAW8otxO46s,370
11
- sqlframe/base/function_alternatives.py,sha256=KFkEm0aIHzajvQmiPZnzTLh-Ud9wjeg4lJ4Rk0vk-YU,53674
12
- sqlframe/base/functions.py,sha256=gWUxngV4cgbPvKqK7_N-2rYGycRyoKJnZqPfFyqIgbE,223305
11
+ sqlframe/base/function_alternatives.py,sha256=Bs1bwl25fN3Yy9rb4GnUWBGunQ1C_yelkb2yV9DSZIY,53918
12
+ sqlframe/base/functions.py,sha256=mSwASQe1WGyMzcwYudioJCR-bvOoqasuqNDFQ2GCC6g,224299
13
13
  sqlframe/base/group.py,sha256=4R9sOZm4ZRlTfShq2j3_HQOiL_Tj1bYkouenYsgnlII,4115
14
14
  sqlframe/base/normalize.py,sha256=nXAJ5CwxVf4DV0GsH-q1w0p8gmjSMlv96k_ez1eVul8,3880
15
15
  sqlframe/base/operations.py,sha256=g-YNcbvNKTOBbYm23GKfB3fmydlR7ZZDAuZUtXIHtzw,4438
@@ -57,7 +57,7 @@ sqlframe/duckdb/catalog.py,sha256=89FCSJglMbOxonk3IXmlkMcdXCfMdePpGfqlbkkB_d0,51
57
57
  sqlframe/duckdb/column.py,sha256=E1tUa62Y5HajkhgFuebU9zohrGyieudcHzTT8gfalio,40
58
58
  sqlframe/duckdb/dataframe.py,sha256=Z8_K69UQGZVeBfVGXVwIJP8OMuIvNBB3DPKTP3Lfu4w,1908
59
59
  sqlframe/duckdb/functions.py,sha256=ix2efGGD4HLaY1rtCtEd3IrsicGEVGiBAeKOo5OD8rA,424
60
- sqlframe/duckdb/functions.pyi,sha256=P0ky6k-J7LdCDrQ0OjfRC3ARIYNHPmAmmaB_jBEO5L0,12383
60
+ sqlframe/duckdb/functions.pyi,sha256=dileIrfRspqWPBFUlXn3R8YLBQqhq0XnH6_6Rp8x1PA,12487
61
61
  sqlframe/duckdb/group.py,sha256=IkhbW42Ng1U5YT3FkIdiB4zBqRkW4QyTb-1detY1e_4,383
62
62
  sqlframe/duckdb/readwriter.py,sha256=-_Ama7evadIa3PYvynKDK6RcTMTDBHpHJzfANTine7g,4983
63
63
  sqlframe/duckdb/session.py,sha256=H1qjMYmhpwUHmf6jOPA6IhPIEIeX8rlvOl3MTIEijG0,2719
@@ -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.24.1.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
- sqlframe-3.24.1.dist-info/METADATA,sha256=e3fUxg1B0Y2UNWFxg4_igcqsGue6PlytRssEeROM6KQ,8971
135
- sqlframe-3.24.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
- sqlframe-3.24.1.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
- sqlframe-3.24.1.dist-info/RECORD,,
133
+ sqlframe-3.26.0.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
+ sqlframe-3.26.0.dist-info/METADATA,sha256=v5x-leHKJrTGK_cyWjXlJRBwLr0VrX1av511o4tKI-E,8971
135
+ sqlframe-3.26.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
+ sqlframe-3.26.0.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
+ sqlframe-3.26.0.dist-info/RECORD,,