sqlframe 3.43.0__py3-none-any.whl → 3.43.2__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.43.0'
32
- __version_tuple__ = version_tuple = (3, 43, 0)
31
+ __version__ = version = '3.43.2'
32
+ __version_tuple__ = version_tuple = (3, 43, 2)
33
33
 
34
- __commit_id__ = commit_id = 'g38d15d998'
34
+ __commit_id__ = commit_id = 'gf6f09ead9'
@@ -921,8 +921,30 @@ class BaseDataFrame(t.Generic[SESSION, WRITER, NA, STAT, GROUP_DATA]):
921
921
  def groupBy(self, *cols, **kwargs) -> GROUP_DATA:
922
922
  if cols and isinstance(cols[0], list):
923
923
  cols = cols[0] # type: ignore
924
+
925
+ # Special handling for groupBy operations with column aliases
926
+ # `_ensure_and_normalize_cols` sets CTE aliases that may not exist in the final context.
924
927
  columns = self._ensure_and_normalize_cols(cols)
925
- return self._group_data(self, columns, self.last_op)
928
+
929
+ # Post-process the columns to fix any issues with CTE aliases
930
+ from sqlframe.base.normalize import (
931
+ _extract_column_name,
932
+ is_column_unambiguously_available,
933
+ )
934
+
935
+ processed_columns: t.List[Column] = []
936
+
937
+ for col in columns:
938
+ # Check if this column has a table qualifier that might be problematic
939
+ if col.column_expression.args.get("table"):
940
+ # Check if the column is unambiguously available without the qualifier
941
+ column_name = _extract_column_name(this) if (this := col.expression.this) else None
942
+ if column_name and is_column_unambiguously_available(self.expression, column_name):
943
+ # Remove the table qualifier if the column is unambiguous
944
+ col.column_expression.set("table", None)
945
+ processed_columns.append(col)
946
+
947
+ return self._group_data(self, processed_columns, self.last_op)
926
948
 
927
949
  groupby = groupBy
928
950
 
@@ -2067,7 +2067,7 @@ def bit_length(col: ColumnOrName) -> Column:
2067
2067
  if session._is_bigquery:
2068
2068
  return bit_length_from_length(col)
2069
2069
 
2070
- return Column.invoke_anonymous_function(col, "BIT_LENGTH")
2070
+ return Column.invoke_expression_over_column(col, expression.BitLength)
2071
2071
 
2072
2072
 
2073
2073
  @meta()
@@ -2729,7 +2729,7 @@ def aggregate(
2729
2729
  return Column.invoke_expression_over_column(col, expression.Reduce, **kwargs)
2730
2730
 
2731
2731
 
2732
- @meta(unsupported_engines="postgres")
2732
+ @meta(unsupported_engines=["bigquery", "postgres", "snowflake"])
2733
2733
  def transform(
2734
2734
  col: ColumnOrName,
2735
2735
  f: t.Union[t.Callable[[Column], Column], t.Callable[[Column, Column], Column]],
@@ -7169,12 +7169,32 @@ def _lambda_quoted(value: str) -> t.Optional[bool]:
7169
7169
 
7170
7170
  @meta()
7171
7171
  def _get_lambda_from_func(lambda_expression: t.Callable):
7172
- variables = [
7173
- expression.to_identifier(x, quoted=_lambda_quoted(x))
7174
- for x in lambda_expression.__code__.co_varnames
7175
- ]
7172
+ import inspect
7173
+
7174
+ # Get the function signature
7175
+ sig = inspect.signature(lambda_expression)
7176
+ param_names = list(sig.parameters.keys())
7177
+
7178
+ # Check if this looks like a column function (single 'col' parameter)
7179
+ if len(param_names) == 1 and param_names[0] in ["col", "column"]:
7180
+ # Wrap column functions to work with transform
7181
+ variables = [expression.to_identifier("x", quoted=_lambda_quoted("x"))]
7182
+ result = lambda_expression(Column("x"))
7183
+ return expression.Lambda(
7184
+ this=result.column_expression,
7185
+ expressions=variables,
7186
+ )
7187
+
7188
+ # Handle regular functions and lambdas
7189
+ var_names = lambda_expression.__code__.co_varnames[: lambda_expression.__code__.co_argcount]
7190
+
7191
+ variables = [expression.to_identifier(x, quoted=_lambda_quoted(x)) for x in var_names]
7192
+
7193
+ # Call with Column objects for each parameter
7194
+ result = lambda_expression(*[Column(x) for x in var_names])
7195
+
7176
7196
  return expression.Lambda(
7177
- this=lambda_expression(*[Column(x) for x in variables]).column_expression,
7197
+ this=result.column_expression,
7178
7198
  expressions=variables,
7179
7199
  )
7180
7200
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlframe
3
- Version: 3.43.0
3
+ Version: 3.43.2
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.16,>=24.0.0
21
+ Requires-Dist: sqlglot <27.18,>=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'
@@ -1,15 +1,15 @@
1
1
  sqlframe/__init__.py,sha256=SB80yLTITBXHI2GCDS6n6bN5ObHqgPjfpRPAUwxaots,3403
2
- sqlframe/_version.py,sha256=GkrwqhnbavsDQW5LQsruCWe67_xixzoHIDhkzjlbf38,714
2
+ sqlframe/_version.py,sha256=knS0nTLrJHzmkAlJL2R2It95jMGAeQSdYXwXqtFA5lE,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
6
6
  sqlframe/base/catalog.py,sha256=-YulM2BMK8MoWbXi05AsJIPxd4AuiZDBCZuk4HoeMlE,38900
7
7
  sqlframe/base/column.py,sha256=f6rK6-hTiNx9WwJP7t6tqL3xEC2gwERPDlhWCS5iCBw,21417
8
- sqlframe/base/dataframe.py,sha256=wT3R2Qmq4edOefxXCRepiMDNJfVOIvSf6eHd6GOn4i0,88543
8
+ sqlframe/base/dataframe.py,sha256=3vlZij84GUKpS23DZSrTRm0mi5SRFjZv_BSn4rAJ0IE,89614
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=QaCeMMBLz69LE-73x4ksXN6NbZlsshYADg-F8yRXTPA,228816
12
+ sqlframe/base/functions.py,sha256=6b1v8-CvYoHEOK_8kJMibk9TrGwQJkSVO0i_pXL5m7s,229614
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.43.0.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
- sqlframe-3.43.0.dist-info/METADATA,sha256=-M-YLCPxdylEzhy7aPCDjVQc4lkJN47zxzJJdWmvVUo,9070
135
- sqlframe-3.43.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
- sqlframe-3.43.0.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
- sqlframe-3.43.0.dist-info/RECORD,,
133
+ sqlframe-3.43.2.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
+ sqlframe-3.43.2.dist-info/METADATA,sha256=ctg26s2x6TsSTpQLS28UcHYuSvPbRbT6EBEav0L9zuw,9070
135
+ sqlframe-3.43.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
+ sqlframe-3.43.2.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
+ sqlframe-3.43.2.dist-info/RECORD,,