sqlframe 3.40.2__py3-none-any.whl → 3.42.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
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '3.40.2'
32
- __version_tuple__ = version_tuple = (3, 40, 2)
31
+ __version__ = version = '3.42.0'
32
+ __version_tuple__ = version_tuple = (3, 42, 0)
33
33
 
34
- __commit_id__ = commit_id = 'gdb7bc99bd'
34
+ __commit_id__ = commit_id = 'gadde0dd66'
@@ -1974,8 +1974,30 @@ def regexp_replace(
1974
1974
  )
1975
1975
 
1976
1976
 
1977
- @meta(unsupported_engines="duckdb")
1977
+ @meta()
1978
1978
  def initcap(col: ColumnOrName) -> Column:
1979
+ session = _get_session()
1980
+
1981
+ if session._is_duckdb:
1982
+ split_func = get_func_from_session("split")
1983
+ transform_func = get_func_from_session("transform")
1984
+ reduce_func = get_func_from_session("reduce")
1985
+ upper_func = get_func_from_session("upper")
1986
+ lower_func = get_func_from_session("lower")
1987
+ length_func = get_func_from_session("length")
1988
+ concat_func = get_func_from_session("concat")
1989
+ concat_ws_func = get_func_from_session("concat_ws")
1990
+ return reduce_func(
1991
+ transform_func(
1992
+ split_func(col, r"\s+"),
1993
+ lambda w: concat_func(
1994
+ upper_func(w.substr(1, 1)), lower_func(w.substr(2, length_func(w) - 1))
1995
+ ),
1996
+ ),
1997
+ None,
1998
+ merge=lambda x, y: concat_ws_func(" ", x, y),
1999
+ )
2000
+
1979
2001
  return Column.invoke_expression_over_column(col, expression.Initcap)
1980
2002
 
1981
2003
 
@@ -2133,6 +2155,11 @@ def bit_xor(col: ColumnOrName) -> Column:
2133
2155
 
2134
2156
  @meta(unsupported_engines=["postgres", "snowflake"])
2135
2157
  def bit_count(col: ColumnOrName) -> Column:
2158
+ session = _get_session()
2159
+
2160
+ if session._is_duckdb:
2161
+ return Column.invoke_anonymous_function(col, "BIT_COUNT")
2162
+
2136
2163
  return Column.invoke_expression_over_column(col, expression.BitwiseCountAgg)
2137
2164
 
2138
2165
 
@@ -2681,7 +2708,7 @@ def from_csv(
2681
2708
  return Column.invoke_anonymous_function(col, "FROM_CSV", schema)
2682
2709
 
2683
2710
 
2684
- @meta(unsupported_engines=["bigquery", "duckdb", "postgres", "snowflake"])
2711
+ @meta(unsupported_engines=["bigquery", "postgres", "snowflake"])
2685
2712
  def aggregate(
2686
2713
  col: ColumnOrName,
2687
2714
  initialValue: ColumnOrName,
@@ -2689,21 +2716,20 @@ def aggregate(
2689
2716
  finish: t.Optional[t.Callable[[Column], Column]] = None,
2690
2717
  ) -> Column:
2691
2718
  merge_exp = _get_lambda_from_func(merge)
2719
+ kwargs = dict(
2720
+ initial=initialValue,
2721
+ merge=merge_exp,
2722
+ )
2723
+ session = _get_session()
2692
2724
  if finish is not None:
2693
2725
  finish_exp = _get_lambda_from_func(finish)
2694
- return Column.invoke_expression_over_column(
2695
- col,
2696
- expression.Reduce,
2697
- initial=initialValue,
2698
- merge=Column(merge_exp),
2699
- finish=Column(finish_exp),
2700
- )
2701
- return Column.invoke_expression_over_column(
2702
- col, expression.Reduce, initial=initialValue, merge=Column(merge_exp)
2703
- )
2726
+ kwargs["finish"] = Column(finish_exp)
2727
+ if session._is_duckdb:
2728
+ kwargs.pop("initial", None)
2729
+ return Column.invoke_expression_over_column(col, expression.Reduce, **kwargs)
2704
2730
 
2705
2731
 
2706
- @meta(unsupported_engines=["bigquery", "duckdb", "postgres", "snowflake"])
2732
+ @meta(unsupported_engines="postgres")
2707
2733
  def transform(
2708
2734
  col: ColumnOrName,
2709
2735
  f: t.Union[t.Callable[[Column], Column], t.Callable[[Column, Column], Column]],
@@ -5216,7 +5242,7 @@ def regexp_count(str: ColumnOrName, regexp: ColumnOrName) -> Column:
5216
5242
  return Column.invoke_anonymous_function(str, "regexp_count", regexp)
5217
5243
 
5218
5244
 
5219
- @meta(unsupported_engines="*")
5245
+ @meta(unsupported_engines=["bigquery", "postgres"])
5220
5246
  def regexp_extract_all(
5221
5247
  str: ColumnOrName, regexp: ColumnOrName, idx: t.Optional[t.Union[int, Column]] = None
5222
5248
  ) -> Column:
@@ -5251,6 +5277,9 @@ def regexp_extract_all(
5251
5277
  >>> df.select(regexp_extract_all('str', col("regexp")).alias('d')).collect()
5252
5278
  [Row(d=['100', '300'])]
5253
5279
  """
5280
+ if idx is None:
5281
+ idx = 1
5282
+
5254
5283
  return Column.invoke_expression_over_column(
5255
5284
  str, expression.RegexpExtractAll, expression=regexp, group=idx
5256
5285
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlframe
3
- Version: 3.40.2
3
+ Version: 3.42.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 @@ Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
19
  Requires-Dist: more-itertools
20
20
  Requires-Dist: prettytable <4
21
- Requires-Dist: sqlglot <27.13,>=24.0.0
21
+ Requires-Dist: sqlglot <27.15,>=24.0.0
22
22
  Requires-Dist: typing-extensions
23
23
  Provides-Extra: bigquery
24
24
  Requires-Dist: google-cloud-bigquery-storage <3,>=2 ; extra == 'bigquery'
@@ -28,7 +28,7 @@ Requires-Dist: databricks-sql-connector[pyarrow] <5,>=3.6 ; extra == 'databricks
28
28
  Provides-Extra: dev
29
29
  Requires-Dist: duckdb <1.4,>=1.2 ; extra == 'dev'
30
30
  Requires-Dist: findspark <3,>=2 ; extra == 'dev'
31
- Requires-Dist: mypy <1.18,>=1.10.0 ; extra == 'dev'
31
+ Requires-Dist: mypy <1.19,>=1.10.0 ; extra == 'dev'
32
32
  Requires-Dist: openai <2,>=1.30 ; extra == 'dev'
33
33
  Requires-Dist: pandas-stubs <3,>=2 ; extra == 'dev'
34
34
  Requires-Dist: pandas <3,>=2 ; extra == 'dev'
@@ -41,7 +41,7 @@ Requires-Dist: pytest-postgresql <8,>=6 ; extra == 'dev'
41
41
  Requires-Dist: pytest-rerunfailures ; extra == 'dev'
42
42
  Requires-Dist: pytest-xdist <3.9,>=3.6 ; extra == 'dev'
43
43
  Requires-Dist: pytest <8.5,>=8.2.0 ; extra == 'dev'
44
- Requires-Dist: ruff <0.13,>=0.4.4 ; extra == 'dev'
44
+ Requires-Dist: ruff <0.14,>=0.4.4 ; extra == 'dev'
45
45
  Requires-Dist: types-psycopg2 <3,>=2.9 ; extra == 'dev'
46
46
  Provides-Extra: docs
47
47
  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=3OGXpC5dnC00OMMG_59F7UDDhHQJ9rorOrt-3thT5Zg,714
2
+ sqlframe/_version.py,sha256=SsOOM9QJfro_JWrCpQSS5Pq52ergp6bxQ1nOQPkMZJs,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,7 +9,7 @@ sqlframe/base/dataframe.py,sha256=Kl3WycARIWBBIze0enmZDGkfOt65mZDQ2hx_6pxRsxI,87
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=fc3jLuPAIJ3Hl4Bezm9Kgzsk4e5uFfgMgfajUCBKQG0,227919
12
+ sqlframe/base/functions.py,sha256=QaCeMMBLz69LE-73x4ksXN6NbZlsshYADg-F8yRXTPA,228816
13
13
  sqlframe/base/group.py,sha256=fBm8EUve7W7xz11nybTXr09ih-yZxL_vvEiZVE1eb_0,12025
14
14
  sqlframe/base/normalize.py,sha256=YPeopWr8ZRjevArYfrM-DZBkQp4t4UfAEwynoj4VvcU,11773
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.40.2.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
- sqlframe-3.40.2.dist-info/METADATA,sha256=Ed2s5MTrVUt6Xzx75bG-Wlfh71zZwO7-Bnr9xlMpCSk,9070
135
- sqlframe-3.40.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
- sqlframe-3.40.2.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
- sqlframe-3.40.2.dist-info/RECORD,,
133
+ sqlframe-3.42.0.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
+ sqlframe-3.42.0.dist-info/METADATA,sha256=g3qTG2C4TsHFM1Q_pkybk7u_Sp4OY5nshpsSsQPKzTM,9070
135
+ sqlframe-3.42.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
+ sqlframe-3.42.0.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
+ sqlframe-3.42.0.dist-info/RECORD,,