sqlframe 3.38.2__py3-none-any.whl → 3.39.1__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
@@ -1,7 +1,14 @@
1
1
  # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
3
 
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
5
12
 
6
13
  TYPE_CHECKING = False
7
14
  if TYPE_CHECKING:
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
9
16
  from typing import Union
10
17
 
11
18
  VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
12
20
  else:
13
21
  VERSION_TUPLE = object
22
+ COMMIT_ID = object
14
23
 
15
24
  version: str
16
25
  __version__: str
17
26
  __version_tuple__: VERSION_TUPLE
18
27
  version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
19
30
 
20
- __version__ = version = '3.38.2'
21
- __version_tuple__ = version_tuple = (3, 38, 2)
31
+ __version__ = version = '3.39.1'
32
+ __version_tuple__ = version_tuple = (3, 39, 1)
33
+
34
+ __commit_id__ = commit_id = 'g0245f44bb'
@@ -2572,7 +2572,7 @@ def shuffle(col: ColumnOrName) -> Column:
2572
2572
 
2573
2573
  @meta(unsupported_engines="snowflake")
2574
2574
  def reverse(col: ColumnOrName) -> Column:
2575
- return Column.invoke_anonymous_function(col, "REVERSE")
2575
+ return Column.invoke_expression_over_column(col, expression.Reverse)
2576
2576
 
2577
2577
 
2578
2578
  @meta(unsupported_engines=["bigquery", "postgres"])
@@ -3219,9 +3219,9 @@ def current_user() -> Column:
3219
3219
  return Column.invoke_expression_over_column(None, expression.CurrentUser)
3220
3220
 
3221
3221
 
3222
- @meta(unsupported_engines="*")
3222
+ @meta()
3223
3223
  def date_from_unix_date(days: ColumnOrName) -> Column:
3224
- return Column.invoke_anonymous_function(days, "date_from_unix_date")
3224
+ return Column.invoke_expression_over_column(days, expression.DateFromUnixDate)
3225
3225
 
3226
3226
 
3227
3227
  @meta(unsupported_engines="*")
@@ -6631,7 +6631,7 @@ def unix_micros(col: ColumnOrName) -> Column:
6631
6631
 
6632
6632
  col = to_timestamp(col)
6633
6633
 
6634
- return Column.invoke_anonymous_function(col, "unix_micros")
6634
+ return Column.invoke_expression_over_column(col, expression.UnixMicros)
6635
6635
 
6636
6636
 
6637
6637
  @meta()
@@ -6651,15 +6651,10 @@ def unix_millis(col: ColumnOrName) -> Column:
6651
6651
  """
6652
6652
  from sqlframe.base.function_alternatives import unix_millis_multiply_epoch
6653
6653
 
6654
- if (
6655
- _get_session()._is_bigquery
6656
- or _get_session()._is_duckdb
6657
- or _get_session()._is_postgres
6658
- or _get_session()._is_snowflake
6659
- ):
6654
+ if _get_session()._is_duckdb or _get_session()._is_postgres or _get_session()._is_snowflake:
6660
6655
  return unix_millis_multiply_epoch(col)
6661
6656
 
6662
- return Column.invoke_anonymous_function(col, "unix_millis")
6657
+ return Column.invoke_expression_over_column(col, expression.UnixMillis)
6663
6658
 
6664
6659
 
6665
6660
  @meta()
sqlframe/base/session.py CHANGED
@@ -12,7 +12,6 @@ from collections import defaultdict
12
12
  from functools import cached_property
13
13
 
14
14
  import sqlglot
15
- from dateutil.relativedelta import relativedelta
16
15
  from sqlglot import Dialect, exp
17
16
  from sqlglot.dialects.dialect import DialectType, NormalizationStrategy
18
17
  from sqlglot.expressions import parse_identifier
@@ -34,6 +33,7 @@ from sqlframe.base.table import _BaseTable
34
33
  from sqlframe.base.udf import _BaseUDFRegistration
35
34
  from sqlframe.base.util import (
36
35
  get_column_mapping_from_schema_input,
36
+ is_relativedelta_like,
37
37
  normalize_string,
38
38
  verify_pandas_installed,
39
39
  )
@@ -614,7 +614,7 @@ class _BaseSession(t.Generic[CATALOG, READER, WRITER, DF, TABLE, CONN, UDF_REGIS
614
614
  return [cls._to_value(x) for x in value]
615
615
  elif isinstance(value, datetime.datetime):
616
616
  return value.replace(tzinfo=None)
617
- elif isinstance(value, relativedelta):
617
+ elif is_relativedelta_like(value):
618
618
  return datetime.timedelta(
619
619
  days=value.days, hours=value.hours, minutes=value.minutes, seconds=value.seconds
620
620
  )
sqlframe/base/util.py CHANGED
@@ -113,9 +113,13 @@ def get_tables_from_expression_with_join(expression: exp.Select) -> t.List[exp.T
113
113
 
114
114
 
115
115
  def to_csv(options: t.Dict[str, OptionalPrimitiveType], equality_char: str = "=") -> str:
116
- return ", ".join(
117
- [f"{k}{equality_char}{v}" for k, v in (options or {}).items() if v is not None]
118
- )
116
+ results = []
117
+ for k, v in (options or {}).items():
118
+ if v is None:
119
+ continue
120
+ v = f"'{v}'" if isinstance(v, str) else v
121
+ results.append(f"{k}{equality_char}{v}")
122
+ return ", ".join(results)
119
123
 
120
124
 
121
125
  def ensure_column_mapping(schema: t.Union[str, StructType]) -> t.Dict:
@@ -524,3 +528,12 @@ def split_filepath(filepath: str) -> tuple[str, str]:
524
528
  if len(split_) == 2: # noqa: PLR2004
525
529
  return split_[0] + "://", split_[1]
526
530
  return "", split_[0]
531
+
532
+
533
+ def is_relativedelta_like(value: t.Any) -> bool:
534
+ return (
535
+ hasattr(value, "years")
536
+ and hasattr(value, "months")
537
+ and hasattr(value, "weeks")
538
+ and hasattr(value, "leapdays")
539
+ )
@@ -461,11 +461,7 @@ class DatabricksCatalog(
461
461
  exp.Property(this=sg.to_identifier(name=k), value=exp.convert(value=v))
462
462
  for k, v in (table_properties if isinstance(table_properties, dict) else {}).items()
463
463
  )
464
-
465
- format_options: dict[str, t.Union[bool, float, int, str, None]] = {
466
- key: f"'{val}'" for key, val in options.items() if val is not None
467
- }
468
- format_options_str = to_csv(format_options, " ")
464
+ format_options_str = to_csv(options, " ") # type: ignore
469
465
 
470
466
  output_expression_container = exp.Create(
471
467
  this=exp.Schema(
@@ -128,8 +128,6 @@ class DatabricksDataFrameReader(
128
128
  format_options["schema"] = f"{schema}"
129
129
  if "inferSchema" in format_options:
130
130
  format_options["inferColumnTypes"] = format_options.pop("inferSchema")
131
-
132
- format_options = {key: f"'{val}'" for key, val in format_options.items()}
133
131
  format_options_str = to_csv(format_options, " => ")
134
132
 
135
133
  from_clause = f"read_files('{paths}', {format_options_str})"
@@ -338,10 +336,7 @@ class DatabricksDataFrameWriter(
338
336
  format_options_str = ""
339
337
  if format is not None:
340
338
  properties.append(exp.FileFormatProperty(this=exp.Var(this=format.upper())))
341
- format_options: dict[str, OptionalPrimitiveType] = {
342
- key: f"'{val}'" for key, val in options.items() if val is not None
343
- }
344
- format_options_str = to_csv(format_options, " ")
339
+ format_options_str = to_csv(options, " ")
345
340
 
346
341
  if path is not None and isinstance(path, str):
347
342
  properties.append(exp.LocationProperty(this=exp.convert(path)))
@@ -86,10 +86,7 @@ class DuckDBDataFrameReader(
86
86
  select_column_mapping["filename"] = "VARCHAR"
87
87
  select_columns = [x.expression for x in self._to_casted_columns(select_column_mapping)]
88
88
  if format == "csv":
89
- duckdb_columns = ", ".join(
90
- [f"'{column}': '{dtype}'" for column, dtype in column_mapping.items()]
91
- )
92
- merged_options["columns"] = "{" + duckdb_columns + "}"
89
+ merged_options["columns"] = column_mapping # type: ignore
93
90
  else:
94
91
  select_columns = [exp.Star()]
95
92
  if format == "delta":
@@ -110,7 +110,6 @@ class SparkDataFrameReader(
110
110
  if schema:
111
111
  format_options["schema"] = f"{schema}"
112
112
  format_options.pop("inferSchema", None)
113
- format_options = {key: f"'{val}'" for key, val in format_options.items()}
114
113
  format_options_str = to_csv(format_options, " ")
115
114
 
116
115
  tmp_view = f"CREATE OR REPLACE TEMPORARY VIEW {tmp_view_key} USING {format}" + (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlframe
3
- Version: 3.38.2
3
+ Version: 3.39.1
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.7,>=24.0.0
20
+ Requires-Dist: sqlglot <27.8,>=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'
@@ -60,7 +60,7 @@ Requires-Dist: psycopg2 <3,>=2.8 ; extra == 'postgres'
60
60
  Provides-Extra: redshift
61
61
  Requires-Dist: redshift-connector <2.2.0,>=2.1.1 ; extra == 'redshift'
62
62
  Provides-Extra: snowflake
63
- Requires-Dist: snowflake-connector-python[secure-local-storage] <3.17,>=3.10.0 ; extra == 'snowflake'
63
+ Requires-Dist: snowflake-connector-python[secure-local-storage] <3.18,>=3.10.0 ; extra == 'snowflake'
64
64
  Provides-Extra: spark
65
65
  Requires-Dist: pyspark <3.6,>=2 ; extra == 'spark'
66
66
 
@@ -1,5 +1,5 @@
1
1
  sqlframe/__init__.py,sha256=SB80yLTITBXHI2GCDS6n6bN5ObHqgPjfpRPAUwxaots,3403
2
- sqlframe/_version.py,sha256=_jX_R7_H72gqRQJCQLfuj94JZgcTBOsYXYFp5ayxiUI,513
2
+ sqlframe/_version.py,sha256=Magv3v4P13Mop8QdiPMhhrwCJ78Gp6qb0vlJrw80tno,714
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,17 +9,17 @@ 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=eV0QjTvDKAArIKSMByXkGJalQtjzGVqO8-8vjQWtMvE,227677
12
+ sqlframe/base/functions.py,sha256=Hd77xVVOBeD4wr08OeCwFJa89LHAZHsMjZXl3cg_RQs,227630
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
16
16
  sqlframe/base/readerwriter.py,sha256=Nb2VJ_HBmLQp5mK8JhnFooZh2ydAaboCAFVPb-4MNX4,31241
17
- sqlframe/base/session.py,sha256=ExaGjY_lxkMi2WDwJ8wTd2uf7a2PjOOk9bx1ViEaAqA,27507
17
+ sqlframe/base/session.py,sha256=8oaEgGbyctKKEaI0GW6k7Praku7nwx3YRYgAW3mZNk0,27481
18
18
  sqlframe/base/table.py,sha256=rCeh1W5SWbtEVfkLAUiexzrZwNgmZeptLEmLcM1ABkE,6961
19
19
  sqlframe/base/transforms.py,sha256=y0j3SGDz3XCmNGrvassk1S-owllUWfkHyMgZlY6SFO4,467
20
20
  sqlframe/base/types.py,sha256=OktuJ5f7tEogOW0oupI0RBlHfzZMmKh7zGLke9cwllo,12305
21
21
  sqlframe/base/udf.py,sha256=O6hMhBUy9NVv-mhJRtfFhXTIa_-Z8Y_FkmmuOHu0l90,1117
22
- sqlframe/base/util.py,sha256=gv_kRc3LxCuQy3t4dHFldV7elB8RU5PMqIN5-xSkWSo,19107
22
+ sqlframe/base/util.py,sha256=D4HAhtu4DMz5mXyxlUHRP_GrsjLJACpBYlLriyGoT0g,19435
23
23
  sqlframe/base/window.py,sha256=7NaKDTlhun-95LEghukBCjFBwq0RHrPaajWQNCsLxok,4818
24
24
  sqlframe/base/mixins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  sqlframe/base/mixins/catalog_mixins.py,sha256=9fZGWToz9xMJSzUl1vsVtj6TH3TysP3fBCKJLnGUQzE,23353
@@ -40,13 +40,13 @@ sqlframe/bigquery/types.py,sha256=KwNyuXIo-2xVVd4bZED3YrQOobKCtemlxGrJL7DrTC8,34
40
40
  sqlframe/bigquery/udf.py,sha256=ZZ1-P1zWZhQqmhBqwAxfNeKl31nDkkZgkuz7Dn28P_0,264
41
41
  sqlframe/bigquery/window.py,sha256=6GKPzuxeSapJakBaKBeT9VpED1ACdjggDv9JRILDyV0,35
42
42
  sqlframe/databricks/__init__.py,sha256=BkB_eO1UYwcf8j6x7bi4BWmDCMkfn0CUMwossWgwaG4,993
43
- sqlframe/databricks/catalog.py,sha256=T_4NlQ7TD57_UTYFeRezYUu0t9NEx7cgJS60O4DKcBQ,18609
43
+ sqlframe/databricks/catalog.py,sha256=QrleTG5_a8JOVUtVTBUu-c8fvxrS_J28QD85awqTBd4,18452
44
44
  sqlframe/databricks/column.py,sha256=E1tUa62Y5HajkhgFuebU9zohrGyieudcHzTT8gfalio,40
45
45
  sqlframe/databricks/dataframe.py,sha256=8kwT1kWU2TwGjR9zDrGdmkvabiBCivA_Mcg06r2XVX4,3111
46
46
  sqlframe/databricks/functions.py,sha256=La8rjAwO0hD4FBO0QxW5CtZtFAPvOrVc6lG4OtPGgbc,336
47
47
  sqlframe/databricks/functions.pyi,sha256=FzVBpzXCJzxIp73sIAo_R8Wx8uOJrix-W12HsgyeTcQ,23799
48
48
  sqlframe/databricks/group.py,sha256=dU3g0DVLRlfOSCamKchQFXRd1WTFbdxoXkpEX8tPD6Y,399
49
- sqlframe/databricks/readwriter.py,sha256=cuGRI1G627JEZgGNtirrT8LAwT6xQCdgkSAETmLKNXU,14777
49
+ sqlframe/databricks/readwriter.py,sha256=u2-0j_gXB4JikMxLBzUWhJZhJ5tYbGJpIGTqnWuDKqk,14521
50
50
  sqlframe/databricks/session.py,sha256=i2CgrLIHJb53Cx1qu_rE1-cmmm19S-Sw1MhTISX1zYU,4013
51
51
  sqlframe/databricks/table.py,sha256=Q0Vnrl5aUqnqFTQpTwfWMRyQ9AQnagtpnSnXmP6IKRs,678
52
52
  sqlframe/databricks/types.py,sha256=KwNyuXIo-2xVVd4bZED3YrQOobKCtemlxGrJL7DrTC8,34
@@ -59,7 +59,7 @@ sqlframe/duckdb/dataframe.py,sha256=Z8_K69UQGZVeBfVGXVwIJP8OMuIvNBB3DPKTP3Lfu4w,
59
59
  sqlframe/duckdb/functions.py,sha256=ix2efGGD4HLaY1rtCtEd3IrsicGEVGiBAeKOo5OD8rA,424
60
60
  sqlframe/duckdb/functions.pyi,sha256=hDjpT-tGDO8LyElcno5YYRUnJg1dXXbGcRjJ69Zqk_U,12542
61
61
  sqlframe/duckdb/group.py,sha256=IkhbW42Ng1U5YT3FkIdiB4zBqRkW4QyTb-1detY1e_4,383
62
- sqlframe/duckdb/readwriter.py,sha256=WEfUSKI68BFwAt4xwQX-GO8ZSGuUQYgYKkmWE55DmJo,5171
62
+ sqlframe/duckdb/readwriter.py,sha256=IA2nLGBfUVAUrSO3DyYL3LWQz-5pfbjQ1fROnnfw_r4,5022
63
63
  sqlframe/duckdb/session.py,sha256=FBU78oA9Lnj5A8ikVswQEDIlJcA3wc0Thn6KVso5iqM,2793
64
64
  sqlframe/duckdb/table.py,sha256=AmEKoH2TZo98loS5NbNaTuqv0eg76SY_OckVBMmQ6Co,410
65
65
  sqlframe/duckdb/types.py,sha256=KwNyuXIo-2xVVd4bZED3YrQOobKCtemlxGrJL7DrTC8,34
@@ -110,7 +110,7 @@ sqlframe/spark/dataframe.py,sha256=WyXHWsH8Ldu2cWTNmsLy5hEFrjJvQh_Aqv3JJcbDy6k,1
110
110
  sqlframe/spark/functions.py,sha256=MYCgHsjRQWylT-rezWRBuLV6BivcaVarbaQtP4T0toQ,331
111
111
  sqlframe/spark/functions.pyi,sha256=GyOdUzv2Z7Qt99JAKEPKgV2t2Rn274OuqwAfcoAXlN0,24259
112
112
  sqlframe/spark/group.py,sha256=MrvV_v-YkBc6T1zz882WrEqtWjlooWIyHBCmTQg3fCA,379
113
- sqlframe/spark/readwriter.py,sha256=VZHFWnhuFjlI-PMHclp1RmoIiISeT6IIp5O8lDn5TBY,6777
113
+ sqlframe/spark/readwriter.py,sha256=mSrAnFXKyPyNb250Ho1c8CgxEoHovsgG209ys_x0aZs,6691
114
114
  sqlframe/spark/session.py,sha256=irlsTky06pKRKAyPLwVzUtLGe4O8mALSgxIqLvqJNF8,5675
115
115
  sqlframe/spark/table.py,sha256=puWV8h_CqA64zwpzq0ydY9LoygMAvprkODyxyzZeF9M,186
116
116
  sqlframe/spark/types.py,sha256=KwNyuXIo-2xVVd4bZED3YrQOobKCtemlxGrJL7DrTC8,34
@@ -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.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,,
133
+ sqlframe-3.39.1.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
+ sqlframe-3.39.1.dist-info/METADATA,sha256=1WWnSl5RkOZOCniSSzeNgHSUztaC4FbMmCjxakLC6E0,9039
135
+ sqlframe-3.39.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
+ sqlframe-3.39.1.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
+ sqlframe-3.39.1.dist-info/RECORD,,