sqlframe 1.7.1__py3-none-any.whl → 1.9.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
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.7.1'
16
- __version_tuple__ = version_tuple = (1, 7, 1)
15
+ __version__ = version = '1.9.0'
16
+ __version_tuple__ = version_tuple = (1, 9, 0)
sqlframe/base/column.py CHANGED
@@ -229,7 +229,7 @@ class Column:
229
229
  return Column(op)
230
230
 
231
231
  def unary_op(self, klass: t.Callable, **kwargs) -> Column:
232
- return Column(klass(this=self.column_expression, **kwargs))
232
+ return Column(klass(this=exp.Paren(this=self.column_expression), **kwargs))
233
233
 
234
234
  @property
235
235
  def is_alias(self):
@@ -1682,6 +1682,98 @@ def stack(*cols: ColumnOrName) -> Column:
1682
1682
  )
1683
1683
 
1684
1684
 
1685
+ @meta(unsupported_engines="*")
1686
+ def make_interval(
1687
+ years: t.Optional[ColumnOrName] = None,
1688
+ months: t.Optional[ColumnOrName] = None,
1689
+ weeks: t.Optional[ColumnOrName] = None,
1690
+ days: t.Optional[ColumnOrName] = None,
1691
+ hours: t.Optional[ColumnOrName] = None,
1692
+ mins: t.Optional[ColumnOrName] = None,
1693
+ secs: t.Optional[ColumnOrName] = None,
1694
+ ) -> Column:
1695
+ columns = _ensure_column_of_optionals([years, months, weeks, days, hours, mins, secs])
1696
+ if not columns:
1697
+ raise ValueError("At least one value must be provided")
1698
+ return Column.invoke_anonymous_function(columns[0], "MAKE_INTERVAL", *columns[1:])
1699
+
1700
+
1701
+ @meta(unsupported_engines="*")
1702
+ def try_add(left: ColumnOrName, right: ColumnOrName) -> Column:
1703
+ return Column.invoke_anonymous_function(left, "TRY_ADD", right)
1704
+
1705
+
1706
+ @meta(unsupported_engines="*")
1707
+ def try_avg(col: ColumnOrName) -> Column:
1708
+ return Column.invoke_anonymous_function(col, "TRY_AVG")
1709
+
1710
+
1711
+ @meta(unsupported_engines="*")
1712
+ def try_divide(left: ColumnOrName, right: ColumnOrName) -> Column:
1713
+ return Column.invoke_anonymous_function(left, "TRY_DIVIDE", right)
1714
+
1715
+
1716
+ @meta(unsupported_engines="*")
1717
+ def try_multiply(left: ColumnOrName, right: ColumnOrName) -> Column:
1718
+ return Column.invoke_anonymous_function(left, "TRY_MULTIPLY", right)
1719
+
1720
+
1721
+ @meta(unsupported_engines="*")
1722
+ def try_subtract(left: ColumnOrName, right: ColumnOrName) -> Column:
1723
+ return Column.invoke_anonymous_function(left, "TRY_SUBTRACT", right)
1724
+
1725
+
1726
+ @meta(unsupported_engines="*")
1727
+ def try_sum(col: ColumnOrName) -> Column:
1728
+ return Column.invoke_anonymous_function(col, "TRY_SUM")
1729
+
1730
+
1731
+ @meta(unsupported_engines="*")
1732
+ def try_to_binary(col: ColumnOrName, format: t.Optional[ColumnOrName] = None) -> Column:
1733
+ if format is not None:
1734
+ return Column.invoke_anonymous_function(col, "TRY_TO_BINARY", format)
1735
+ return Column.invoke_anonymous_function(col, "TRY_TO_BINARY")
1736
+
1737
+
1738
+ @meta(unsupported_engines="*")
1739
+ def try_to_number(col: ColumnOrName, format: t.Optional[ColumnOrName] = None) -> Column:
1740
+ if format is not None:
1741
+ return Column.invoke_anonymous_function(col, "TRY_TO_NUMBER", format)
1742
+ return Column.invoke_anonymous_function(col, "TRY_TO_NUMBER")
1743
+
1744
+
1745
+ @meta(unsupported_engines="*")
1746
+ def aes_decrypt(
1747
+ input: ColumnOrName,
1748
+ key: ColumnOrName,
1749
+ mode: t.Optional[ColumnOrName] = None,
1750
+ padding: t.Optional[ColumnOrName] = None,
1751
+ aad: t.Optional[ColumnOrName] = None,
1752
+ ) -> Column:
1753
+ columns = _ensure_column_of_optionals([key, mode, padding, aad])
1754
+ return Column.invoke_anonymous_function(input, "AES_DECRYPT", *columns)
1755
+
1756
+
1757
+ @meta(unsupported_engines="*")
1758
+ def aes_encrypt(
1759
+ input: ColumnOrName,
1760
+ key: ColumnOrName,
1761
+ mode: t.Optional[ColumnOrName] = None,
1762
+ padding: t.Optional[ColumnOrName] = None,
1763
+ iv: t.Optional[ColumnOrName] = None,
1764
+ aad: t.Optional[ColumnOrName] = None,
1765
+ ) -> Column:
1766
+ columns = _ensure_column_of_optionals([key, mode, padding, iv, aad])
1767
+ return Column.invoke_anonymous_function(input, "AES_ENCRYPT", *columns)
1768
+
1769
+
1770
+ @meta(unsupported_engines="*")
1771
+ def to_binary(col: ColumnOrName, format: t.Optional[ColumnOrName] = None) -> Column:
1772
+ if format is not None:
1773
+ return Column.invoke_anonymous_function(col, "TO_BINARY", format)
1774
+ return Column.invoke_anonymous_function(col, "TO_BINARY")
1775
+
1776
+
1685
1777
  @meta()
1686
1778
  def _lambda_quoted(value: str) -> t.Optional[bool]:
1687
1779
  return False if value == "_" else None
@@ -1697,3 +1789,11 @@ def _get_lambda_from_func(lambda_expression: t.Callable):
1697
1789
  this=lambda_expression(*[Column(x) for x in variables]).expression,
1698
1790
  expressions=variables,
1699
1791
  )
1792
+
1793
+
1794
+ def _ensure_column_of_optionals(optionals: t.List[t.Optional[ColumnOrName]]) -> t.List[Column]:
1795
+ for value in reversed(optionals.copy()):
1796
+ if value is not None:
1797
+ break
1798
+ optionals = optionals[:-1]
1799
+ return [Column.ensure_col(x) if x is not None else lit(None) for x in optionals]
sqlframe/spark/catalog.py CHANGED
@@ -519,7 +519,10 @@ class SparkCatalog(
519
519
  )
520
520
  for col in df.columns
521
521
  ]
522
- return [Column(*x) for x in self._spark_catalog.listColumns(tableName, dbName)]
522
+ return [
523
+ Column(**{name: x._asdict()[name] for name in Column._fields})
524
+ for x in self._spark_catalog.listColumns(tableName, dbName)
525
+ ]
523
526
 
524
527
  def listFunctions(
525
528
  self, dbName: t.Optional[str] = None, pattern: t.Optional[str] = None
@@ -7,6 +7,8 @@ from sqlframe.base.functions import (
7
7
  abs as abs,
8
8
  acos as acos,
9
9
  acosh as acosh,
10
+ aes_encrypt as aes_encrypt,
11
+ aes_decrypt as aes_decrypt,
10
12
  aggregate as aggregate,
11
13
  approxCountDistinct as approxCountDistinct,
12
14
  approx_count_distinct as approx_count_distinct,
@@ -132,6 +134,7 @@ from sqlframe.base.functions import (
132
134
  lpad as lpad,
133
135
  ltrim as ltrim,
134
136
  make_date as make_date,
137
+ make_interval as make_interval,
135
138
  map_concat as map_concat,
136
139
  map_entries as map_entries,
137
140
  map_filter as map_filter,
@@ -217,6 +220,7 @@ from sqlframe.base.functions import (
217
220
  timestamp_seconds as timestamp_seconds,
218
221
  toDegrees as toDegrees,
219
222
  toRadians as toRadians,
223
+ to_binary as to_binary,
220
224
  to_csv as to_csv,
221
225
  to_date as to_date,
222
226
  to_json as to_json,
@@ -228,6 +232,14 @@ from sqlframe.base.functions import (
228
232
  translate as translate,
229
233
  trim as trim,
230
234
  trunc as trunc,
235
+ try_add as try_add,
236
+ try_avg as try_avg,
237
+ try_divide as try_divide,
238
+ try_multiply as try_multiply,
239
+ try_subtract as try_subtract,
240
+ try_sum as try_sum,
241
+ try_to_binary as try_to_binary,
242
+ try_to_number as try_to_number,
231
243
  typeof as typeof,
232
244
  unbase64 as unbase64,
233
245
  unhex as unhex,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlframe
3
- Version: 1.7.1
3
+ Version: 1.9.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
@@ -18,7 +18,7 @@ Requires-Python: >=3.8
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
20
  Requires-Dist: prettytable (<3.11.0)
21
- Requires-Dist: sqlglot (<25.1,>=24.0.0)
21
+ Requires-Dist: sqlglot (<25.4,>=24.0.0)
22
22
  Requires-Dist: typing-extensions (<5,>=4.8)
23
23
  Provides-Extra: bigquery
24
24
  Requires-Dist: google-cloud-bigquery-storage (<3,>=2) ; extra == 'bigquery'
@@ -26,7 +26,7 @@ Requires-Dist: google-cloud-bigquery[pandas] (<4,>=3) ; extra == 'bigquery'
26
26
  Provides-Extra: dev
27
27
  Requires-Dist: duckdb (<1.1,>=0.9) ; extra == 'dev'
28
28
  Requires-Dist: mypy (<1.11,>=1.10.0) ; extra == 'dev'
29
- Requires-Dist: openai (<1.34,>=1.30) ; extra == 'dev'
29
+ Requires-Dist: openai (<1.36,>=1.30) ; extra == 'dev'
30
30
  Requires-Dist: pandas-stubs (<3,>=2) ; extra == 'dev'
31
31
  Requires-Dist: pandas (<3,>=2) ; extra == 'dev'
32
32
  Requires-Dist: psycopg (<4,>=3.1) ; extra == 'dev'
@@ -49,7 +49,7 @@ Provides-Extra: duckdb
49
49
  Requires-Dist: duckdb (<1.1,>=0.9) ; extra == 'duckdb'
50
50
  Requires-Dist: pandas (<3,>=2) ; extra == 'duckdb'
51
51
  Provides-Extra: openai
52
- Requires-Dist: openai (<1.34,>=1.30) ; extra == 'openai'
52
+ Requires-Dist: openai (<1.36,>=1.30) ; extra == 'openai'
53
53
  Provides-Extra: pandas
54
54
  Requires-Dist: pandas (<3,>=2) ; extra == 'pandas'
55
55
  Provides-Extra: postgres
@@ -57,7 +57,7 @@ Requires-Dist: psycopg2 (<3,>=2.8) ; extra == 'postgres'
57
57
  Provides-Extra: redshift
58
58
  Requires-Dist: redshift-connector (<2.2.0,>=2.1.1) ; extra == 'redshift'
59
59
  Provides-Extra: snowflake
60
- Requires-Dist: snowflake-connector-python[secure-local-storage] (<3.11,>=3.10.0) ; extra == 'snowflake'
60
+ Requires-Dist: snowflake-connector-python[secure-local-storage] (<3.12,>=3.10.0) ; extra == 'snowflake'
61
61
  Provides-Extra: spark
62
62
  Requires-Dist: pyspark (<3.6,>=2) ; extra == 'spark'
63
63
 
@@ -1,14 +1,14 @@
1
1
  sqlframe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- sqlframe/_version.py,sha256=kn-QYzzAhfbnfKK6EpE9gJz8TDZkEk52evaid1DHkG4,411
2
+ sqlframe/_version.py,sha256=Wi1Vgg8ccNVK7oIZNO8kmGhwjztIUyuzlku2tkT7820,411
3
3
  sqlframe/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  sqlframe/base/_typing.py,sha256=DuTay8-o9W-pw3RPZCgLunKNJLS9PkaV11G_pxXp9NY,1256
5
5
  sqlframe/base/catalog.py,sha256=ATDGirouUjal05P4ymL-wIi8rgjg_8w4PoACamiO64A,37245
6
- sqlframe/base/column.py,sha256=0WgIRBfF8Fkbx_OtiaUB1-BsX3qCd4W5IL534Q2BkCA,16137
6
+ sqlframe/base/column.py,sha256=5bfJWj9dnStHUxLSrWMD-gwiC4-aHKC8lhoC62nhM1k,16153
7
7
  sqlframe/base/dataframe.py,sha256=uL4neDTMy1a9XJH46YLQryzdDci4iDxNXBtiJOzfHfs,67718
8
8
  sqlframe/base/decorators.py,sha256=I5osMgx9BuCgbtp4jVM2DNwYJVLzCv-OtTedhQEik0g,1882
9
9
  sqlframe/base/exceptions.py,sha256=pCB9hXX4jxZWzNg3JN1i38cv3BmpUlee5NoLYx3YXIQ,208
10
10
  sqlframe/base/function_alternatives.py,sha256=NDXs2igY7PBsStzTSRZvJcCshBOJkPQl2GbhpVFU6To,42931
11
- sqlframe/base/functions.py,sha256=i4XvQ9KOW55SX2gs1CAk3U1t6-TRLiIZG_RJj_Zn5cI,54852
11
+ sqlframe/base/functions.py,sha256=FZczLQzADcXQWuKUbv67LHnK1yQU4nVzJGnNJQEHkrY,58438
12
12
  sqlframe/base/group.py,sha256=TES9CleVmH3x-0X-tqmuUKfCKSWjH5vg1aU3R6dDmFc,4059
13
13
  sqlframe/base/normalize.py,sha256=nXAJ5CwxVf4DV0GsH-q1w0p8gmjSMlv96k_ez1eVul8,3880
14
14
  sqlframe/base/operations.py,sha256=-AhNuEzcV7ZExoP1oY3blaKip-joQyJeQVvfBTs_2g4,3456
@@ -77,11 +77,11 @@ sqlframe/snowflake/session.py,sha256=bDOlnuIiQ9j_zfF7F5H1gTLmpHUjruIxr2CfXcS_7YU
77
77
  sqlframe/snowflake/types.py,sha256=KwNyuXIo-2xVVd4bZED3YrQOobKCtemlxGrJL7DrTC8,34
78
78
  sqlframe/snowflake/window.py,sha256=6GKPzuxeSapJakBaKBeT9VpED1ACdjggDv9JRILDyV0,35
79
79
  sqlframe/spark/__init__.py,sha256=WhYQAZMJN1EMNAVGUH7BEinxNdYtXOrrr-6HUniJOyI,649
80
- sqlframe/spark/catalog.py,sha256=YeWBCUlkkhf2jDcmaFo-JvG4DQ6Daqyy1zEnVBx5gMo,32526
80
+ sqlframe/spark/catalog.py,sha256=rIX5DtPnINbcPZRUe4Z1bOpkJoNRlrO9qWkUeTQClNc,32612
81
81
  sqlframe/spark/column.py,sha256=E1tUa62Y5HajkhgFuebU9zohrGyieudcHzTT8gfalio,40
82
82
  sqlframe/spark/dataframe.py,sha256=V3z5Bx9snLgYh4bDwJfJb5mj1P7UsZF8DMlLwZXopBg,1309
83
83
  sqlframe/spark/functions.py,sha256=PkK4MBpVADhnDbrgFDii5zFaNrhi4y-OYX3Lcu-SW0k,530
84
- sqlframe/spark/functions.pyi,sha256=eiAAXKW57HOJNfqLndkyijxlpIt-5WfojLWTk2gN6_Y,6479
84
+ sqlframe/spark/functions.pyi,sha256=0gyD8H7qYqiG-u_dpZB9wBuPni6GB5wa8YXUICoZMwU,6849
85
85
  sqlframe/spark/group.py,sha256=MrvV_v-YkBc6T1zz882WrEqtWjlooWIyHBCmTQg3fCA,379
86
86
  sqlframe/spark/readwriter.py,sha256=w68EImTcGJv64X7pc1tk5tDjDxb1nAnn-MiIaaN9Dc8,812
87
87
  sqlframe/spark/session.py,sha256=ztIS7VCFxjR3B7i4JXaXo0evTUhUjOsIAZb7Ssqt2cU,4254
@@ -97,8 +97,8 @@ sqlframe/standalone/readwriter.py,sha256=EZNyDJ4ID6sGNog3uP4-e9RvchX4biJJDNtc5hk
97
97
  sqlframe/standalone/session.py,sha256=wQmdu2sv6KMTAv0LRFk7TY7yzlh3xvmsyqilEtRecbY,1191
98
98
  sqlframe/standalone/types.py,sha256=KwNyuXIo-2xVVd4bZED3YrQOobKCtemlxGrJL7DrTC8,34
99
99
  sqlframe/standalone/window.py,sha256=6GKPzuxeSapJakBaKBeT9VpED1ACdjggDv9JRILDyV0,35
100
- sqlframe-1.7.1.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
101
- sqlframe-1.7.1.dist-info/METADATA,sha256=K-7c9prIXrECo4scNvY_F2mHYwNEWjCefXJDpe_ahlc,7496
102
- sqlframe-1.7.1.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
103
- sqlframe-1.7.1.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
104
- sqlframe-1.7.1.dist-info/RECORD,,
100
+ sqlframe-1.9.0.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
101
+ sqlframe-1.9.0.dist-info/METADATA,sha256=ZqMpC8SchKLMSu0-H36KkmMLQcv13IKaK-AKumtcIYA,7496
102
+ sqlframe-1.9.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
103
+ sqlframe-1.9.0.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
104
+ sqlframe-1.9.0.dist-info/RECORD,,