sqlframe 1.7.0__py3-none-any.whl → 1.8.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 +2 -2
- sqlframe/base/functions.py +84 -4
- sqlframe/base/session.py +1 -0
- sqlframe/spark/catalog.py +4 -1
- sqlframe/spark/functions.py +1 -3
- sqlframe/spark/functions.pyi +12 -0
- {sqlframe-1.7.0.dist-info → sqlframe-1.8.0.dist-info}/METADATA +2 -2
- {sqlframe-1.7.0.dist-info → sqlframe-1.8.0.dist-info}/RECORD +11 -11
- {sqlframe-1.7.0.dist-info → sqlframe-1.8.0.dist-info}/LICENSE +0 -0
- {sqlframe-1.7.0.dist-info → sqlframe-1.8.0.dist-info}/WHEEL +0 -0
- {sqlframe-1.7.0.dist-info → sqlframe-1.8.0.dist-info}/top_level.txt +0 -0
sqlframe/_version.py
CHANGED
sqlframe/base/functions.py
CHANGED
|
@@ -151,9 +151,10 @@ def sumDistinct(col: ColumnOrName) -> Column:
|
|
|
151
151
|
sum_distinct = sumDistinct
|
|
152
152
|
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
# Product does not have a SQL function available
|
|
155
|
+
# @meta(unsupported_engines="*")
|
|
156
|
+
# def product(col: ColumnOrName) -> Column:
|
|
157
|
+
# raise NotImplementedError("Product is not currently implemented")
|
|
157
158
|
|
|
158
159
|
|
|
159
160
|
@meta()
|
|
@@ -1430,6 +1431,8 @@ def to_json(col: ColumnOrName, options: t.Optional[t.Dict[str, str]] = None) ->
|
|
|
1430
1431
|
|
|
1431
1432
|
@meta(unsupported_engines="*")
|
|
1432
1433
|
def schema_of_json(col: ColumnOrName, options: t.Optional[t.Dict[str, str]] = None) -> Column:
|
|
1434
|
+
if isinstance(col, str):
|
|
1435
|
+
col = lit(col)
|
|
1433
1436
|
if options is not None:
|
|
1434
1437
|
options_col = create_map([lit(x) for x in _flatten(options.items())])
|
|
1435
1438
|
return Column.invoke_anonymous_function(col, "SCHEMA_OF_JSON", options_col)
|
|
@@ -1438,6 +1441,8 @@ def schema_of_json(col: ColumnOrName, options: t.Optional[t.Dict[str, str]] = No
|
|
|
1438
1441
|
|
|
1439
1442
|
@meta(unsupported_engines="*")
|
|
1440
1443
|
def schema_of_csv(col: ColumnOrName, options: t.Optional[t.Dict[str, str]] = None) -> Column:
|
|
1444
|
+
if isinstance(col, str):
|
|
1445
|
+
col = lit(col)
|
|
1441
1446
|
if options is not None:
|
|
1442
1447
|
options_col = create_map([lit(x) for x in _flatten(options.items())])
|
|
1443
1448
|
return Column.invoke_anonymous_function(col, "SCHEMA_OF_CSV", options_col)
|
|
@@ -1560,7 +1565,9 @@ def from_csv(
|
|
|
1560
1565
|
) -> Column:
|
|
1561
1566
|
schema = schema if isinstance(schema, Column) else lit(schema)
|
|
1562
1567
|
if options is not None:
|
|
1563
|
-
option_cols = create_map(
|
|
1568
|
+
option_cols = create_map(
|
|
1569
|
+
[lit(str(x) if isinstance(x, bool) else x) for x in _flatten(options.items())]
|
|
1570
|
+
)
|
|
1564
1571
|
return Column.invoke_anonymous_function(col, "FROM_CSV", schema, option_cols)
|
|
1565
1572
|
return Column.invoke_anonymous_function(col, "FROM_CSV", schema)
|
|
1566
1573
|
|
|
@@ -1667,6 +1674,79 @@ def nullif(col1: ColumnOrName, col2: ColumnOrName) -> Column:
|
|
|
1667
1674
|
return Column.invoke_expression_over_column(col1, expression.Nullif, expression=col2)
|
|
1668
1675
|
|
|
1669
1676
|
|
|
1677
|
+
@meta(unsupported_engines="*")
|
|
1678
|
+
def stack(*cols: ColumnOrName) -> Column:
|
|
1679
|
+
columns = [Column.ensure_col(x) for x in cols]
|
|
1680
|
+
return Column.invoke_anonymous_function(
|
|
1681
|
+
columns[0], "STACK", *columns[1:] if len(columns) > 1 else []
|
|
1682
|
+
)
|
|
1683
|
+
|
|
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
|
+
values = [years, months, weeks, days, hours, mins, secs]
|
|
1696
|
+
for value in reversed(values.copy()):
|
|
1697
|
+
if value is not None:
|
|
1698
|
+
break
|
|
1699
|
+
values = values[:-1]
|
|
1700
|
+
else:
|
|
1701
|
+
raise ValueError("At least one value must be provided")
|
|
1702
|
+
columns = [Column.ensure_col(x) if x is not None else lit(None) for x in values]
|
|
1703
|
+
return Column.invoke_anonymous_function(columns[0], "MAKE_INTERVAL", *columns[1:])
|
|
1704
|
+
|
|
1705
|
+
|
|
1706
|
+
@meta(unsupported_engines="*")
|
|
1707
|
+
def try_add(left: ColumnOrName, right: ColumnOrName) -> Column:
|
|
1708
|
+
return Column.invoke_anonymous_function(left, "TRY_ADD", right)
|
|
1709
|
+
|
|
1710
|
+
|
|
1711
|
+
@meta(unsupported_engines="*")
|
|
1712
|
+
def try_avg(col: ColumnOrName) -> Column:
|
|
1713
|
+
return Column.invoke_anonymous_function(col, "TRY_AVG")
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
@meta(unsupported_engines="*")
|
|
1717
|
+
def try_divide(left: ColumnOrName, right: ColumnOrName) -> Column:
|
|
1718
|
+
return Column.invoke_anonymous_function(left, "TRY_DIVIDE", right)
|
|
1719
|
+
|
|
1720
|
+
|
|
1721
|
+
@meta(unsupported_engines="*")
|
|
1722
|
+
def try_multiply(left: ColumnOrName, right: ColumnOrName) -> Column:
|
|
1723
|
+
return Column.invoke_anonymous_function(left, "TRY_MULTIPLY", right)
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
@meta(unsupported_engines="*")
|
|
1727
|
+
def try_subtract(left: ColumnOrName, right: ColumnOrName) -> Column:
|
|
1728
|
+
return Column.invoke_anonymous_function(left, "TRY_SUBTRACT", right)
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
@meta(unsupported_engines="*")
|
|
1732
|
+
def try_sum(col: ColumnOrName) -> Column:
|
|
1733
|
+
return Column.invoke_anonymous_function(col, "TRY_SUM")
|
|
1734
|
+
|
|
1735
|
+
|
|
1736
|
+
@meta(unsupported_engines="*")
|
|
1737
|
+
def try_to_binary(col: ColumnOrName, format: t.Optional[ColumnOrName] = None) -> Column:
|
|
1738
|
+
if format is not None:
|
|
1739
|
+
return Column.invoke_anonymous_function(col, "TRY_TO_BINARY", format)
|
|
1740
|
+
return Column.invoke_anonymous_function(col, "TRY_TO_BINARY")
|
|
1741
|
+
|
|
1742
|
+
|
|
1743
|
+
@meta(unsupported_engines="*")
|
|
1744
|
+
def try_to_number(col: ColumnOrName, format: t.Optional[ColumnOrName] = None) -> Column:
|
|
1745
|
+
if format is not None:
|
|
1746
|
+
return Column.invoke_anonymous_function(col, "TRY_TO_NUMBER", format)
|
|
1747
|
+
return Column.invoke_anonymous_function(col, "TRY_TO_NUMBER")
|
|
1748
|
+
|
|
1749
|
+
|
|
1670
1750
|
@meta()
|
|
1671
1751
|
def _lambda_quoted(value: str) -> t.Optional[bool]:
|
|
1672
1752
|
return False if value == "_" else None
|
sqlframe/base/session.py
CHANGED
sqlframe/spark/catalog.py
CHANGED
|
@@ -519,7 +519,10 @@ class SparkCatalog(
|
|
|
519
519
|
)
|
|
520
520
|
for col in df.columns
|
|
521
521
|
]
|
|
522
|
-
return [
|
|
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
|
sqlframe/spark/functions.py
CHANGED
|
@@ -8,9 +8,7 @@ globals().update(
|
|
|
8
8
|
{
|
|
9
9
|
name: func
|
|
10
10
|
for name, func in inspect.getmembers(module, inspect.isfunction)
|
|
11
|
-
if hasattr(func, "unsupported_engines")
|
|
12
|
-
and "spark" not in func.unsupported_engines
|
|
13
|
-
and "*" not in func.unsupported_engines
|
|
11
|
+
if hasattr(func, "unsupported_engines") and "spark" not in func.unsupported_engines
|
|
14
12
|
}
|
|
15
13
|
)
|
|
16
14
|
|
sqlframe/spark/functions.pyi
CHANGED
|
@@ -132,6 +132,7 @@ from sqlframe.base.functions import (
|
|
|
132
132
|
lpad as lpad,
|
|
133
133
|
ltrim as ltrim,
|
|
134
134
|
make_date as make_date,
|
|
135
|
+
make_interval as make_interval,
|
|
135
136
|
map_concat as map_concat,
|
|
136
137
|
map_entries as map_entries,
|
|
137
138
|
map_filter as map_filter,
|
|
@@ -177,6 +178,8 @@ from sqlframe.base.functions import (
|
|
|
177
178
|
row_number as row_number,
|
|
178
179
|
rpad as rpad,
|
|
179
180
|
rtrim as rtrim,
|
|
181
|
+
schema_of_csv as schema_of_csv,
|
|
182
|
+
schema_of_json as schema_of_json,
|
|
180
183
|
sec as sec,
|
|
181
184
|
second as second,
|
|
182
185
|
sentences as sentences,
|
|
@@ -200,6 +203,7 @@ from sqlframe.base.functions import (
|
|
|
200
203
|
soundex as soundex,
|
|
201
204
|
split as split,
|
|
202
205
|
sqrt as sqrt,
|
|
206
|
+
stack as stack,
|
|
203
207
|
stddev as stddev,
|
|
204
208
|
stddev_pop as stddev_pop,
|
|
205
209
|
stddev_samp as stddev_samp,
|
|
@@ -225,6 +229,14 @@ from sqlframe.base.functions import (
|
|
|
225
229
|
translate as translate,
|
|
226
230
|
trim as trim,
|
|
227
231
|
trunc as trunc,
|
|
232
|
+
try_add as try_add,
|
|
233
|
+
try_avg as try_avg,
|
|
234
|
+
try_divide as try_divide,
|
|
235
|
+
try_multiply as try_multiply,
|
|
236
|
+
try_subtract as try_subtract,
|
|
237
|
+
try_sum as try_sum,
|
|
238
|
+
try_to_binary as try_to_binary,
|
|
239
|
+
try_to_number as try_to_number,
|
|
228
240
|
typeof as typeof,
|
|
229
241
|
unbase64 as unbase64,
|
|
230
242
|
unhex as unhex,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sqlframe
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.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
|
|
@@ -19,6 +19,7 @@ Description-Content-Type: text/markdown
|
|
|
19
19
|
License-File: LICENSE
|
|
20
20
|
Requires-Dist: prettytable (<3.11.0)
|
|
21
21
|
Requires-Dist: sqlglot (<25.1,>=24.0.0)
|
|
22
|
+
Requires-Dist: typing-extensions (<5,>=4.8)
|
|
22
23
|
Provides-Extra: bigquery
|
|
23
24
|
Requires-Dist: google-cloud-bigquery-storage (<3,>=2) ; extra == 'bigquery'
|
|
24
25
|
Requires-Dist: google-cloud-bigquery[pandas] (<4,>=3) ; extra == 'bigquery'
|
|
@@ -36,7 +37,6 @@ Requires-Dist: pytest-xdist (<3.7,>=3.6) ; extra == 'dev'
|
|
|
36
37
|
Requires-Dist: pytest (<8.3,>=8.2.0) ; extra == 'dev'
|
|
37
38
|
Requires-Dist: ruff (<0.5,>=0.4.4) ; extra == 'dev'
|
|
38
39
|
Requires-Dist: types-psycopg2 (<3,>=2.9) ; extra == 'dev'
|
|
39
|
-
Requires-Dist: typing-extensions (<5,>=4.11) ; extra == 'dev'
|
|
40
40
|
Requires-Dist: pre-commit (>=3.5) ; (python_version == "3.8") and extra == 'dev'
|
|
41
41
|
Requires-Dist: pre-commit (<3.8,>=3.7) ; (python_version >= "3.9") and extra == 'dev'
|
|
42
42
|
Provides-Extra: docs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sqlframe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
sqlframe/_version.py,sha256=
|
|
2
|
+
sqlframe/_version.py,sha256=PikY8ZcokXQcck_OODdQtYmXxEq-zKRR9b1ZMOFZlds,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
|
|
@@ -8,12 +8,12 @@ sqlframe/base/dataframe.py,sha256=uL4neDTMy1a9XJH46YLQryzdDci4iDxNXBtiJOzfHfs,67
|
|
|
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=
|
|
11
|
+
sqlframe/base/functions.py,sha256=AXYdxziKsU--huK5o0bl_4DhBns3XFlwPtweCNCIH0E,57191
|
|
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
|
|
15
15
|
sqlframe/base/readerwriter.py,sha256=5NPQMiOrw6I54U243R_6-ynnWYsNksgqwRpPp4IFjIw,25288
|
|
16
|
-
sqlframe/base/session.py,sha256=
|
|
16
|
+
sqlframe/base/session.py,sha256=oQsOwlwAhbqtD8epR44kGXP29S31fIxM29NxfwCbcl0,21993
|
|
17
17
|
sqlframe/base/transforms.py,sha256=y0j3SGDz3XCmNGrvassk1S-owllUWfkHyMgZlY6SFO4,467
|
|
18
18
|
sqlframe/base/types.py,sha256=aJT5YXr-M_LAfUM0uK4asfbrQFab_xmsp1CP2zkG8p0,11924
|
|
19
19
|
sqlframe/base/util.py,sha256=hgmTVzdTvHhfc9d5I96wjk9LGr-vhSZlaB-MejENzcA,9110
|
|
@@ -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=
|
|
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
|
-
sqlframe/spark/functions.py,sha256=
|
|
84
|
-
sqlframe/spark/functions.pyi,sha256=
|
|
83
|
+
sqlframe/spark/functions.py,sha256=PkK4MBpVADhnDbrgFDii5zFaNrhi4y-OYX3Lcu-SW0k,530
|
|
84
|
+
sqlframe/spark/functions.pyi,sha256=GHL_4c5JUeeR7IP9hnZtYDs3FWufoYzO_YjF_52vYVQ,6757
|
|
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.
|
|
101
|
-
sqlframe-1.
|
|
102
|
-
sqlframe-1.
|
|
103
|
-
sqlframe-1.
|
|
104
|
-
sqlframe-1.
|
|
100
|
+
sqlframe-1.8.0.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
|
|
101
|
+
sqlframe-1.8.0.dist-info/METADATA,sha256=lUJKFXpvE7TFVd4VNSlyUYDYnKj3Uy9XzHZNKyr9msE,7496
|
|
102
|
+
sqlframe-1.8.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
103
|
+
sqlframe-1.8.0.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
|
|
104
|
+
sqlframe-1.8.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|