sqlframe 3.28.2__py3-none-any.whl → 3.29.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
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '3.28.2'
21
- __version_tuple__ = version_tuple = (3, 28, 2)
20
+ __version__ = version = '3.29.0'
21
+ __version_tuple__ = version_tuple = (3, 29, 0)
@@ -1595,6 +1595,8 @@ class BaseDataFrame(t.Generic[SESSION, WRITER, NA, STAT, GROUP_DATA]):
1595
1595
 
1596
1596
  @operation(Operation.LIMIT)
1597
1597
  def limit(self, num: int) -> Self:
1598
+ if limit_exp := self.expression.args.get("limit"):
1599
+ num = min(num, int(limit_exp.expression.this))
1598
1600
  return self.copy(expression=self.expression.limit(num))
1599
1601
 
1600
1602
  def toDF(self, *cols: str) -> Self:
@@ -1850,11 +1852,11 @@ class BaseDataFrame(t.Generic[SESSION, WRITER, NA, STAT, GROUP_DATA]):
1850
1852
  def head(self, n: int) -> t.List[Row]: ...
1851
1853
 
1852
1854
  def head(self, n: t.Optional[int] = None) -> t.Union[t.Optional[Row], t.List[Row]]:
1853
- n = n or 1
1854
- df = self.limit(n)
1855
- if n == 1:
1856
- return df.collect()[0]
1857
- return df.collect()
1855
+ df = self.limit(n or 1)
1856
+ collected = df.collect()
1857
+ if n is None:
1858
+ return seq_get(collected, 0)
1859
+ return collected
1858
1860
 
1859
1861
  def first(self) -> t.Optional[Row]:
1860
1862
  return self.head()
@@ -1935,6 +1937,11 @@ class BaseDataFrame(t.Generic[SESSION, WRITER, NA, STAT, GROUP_DATA]):
1935
1937
  def createGlobalTempView(self, name: str) -> None:
1936
1938
  raise NotImplementedError("Global temp views are not yet supported")
1937
1939
 
1940
+ def isEmpty(self) -> bool:
1941
+ from sqlframe.base import functions as F
1942
+
1943
+ return not bool(self.select(F.lit(True)).head())
1944
+
1938
1945
  """
1939
1946
  Stat Functions
1940
1947
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlframe
3
- Version: 3.28.2
3
+ Version: 3.29.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
@@ -69,18 +69,19 @@ Requires-Dist: pyspark <3.6,>=2 ; extra == 'spark'
69
69
 
70
70
  SQLFrame implements the PySpark DataFrame API in order to enable running transformation pipelines directly on database engines - no Spark clusters or dependencies required.
71
71
 
72
- SQLFrame currently supports the following engines (many more in development):
72
+ SQLFrame currently supports the following engines:
73
73
 
74
74
  * [BigQuery](https://sqlframe.readthedocs.io/en/stable/bigquery/)
75
+ * [Databricks](https://sqlframe.readthedocs.io/en/stable/databricks)
75
76
  * [DuckDB](https://sqlframe.readthedocs.io/en/stable/duckdb)
76
77
  * [Postgres](https://sqlframe.readthedocs.io/en/stable/postgres)
77
78
  * [Snowflake](https://sqlframe.readthedocs.io/en/stable/snowflake)
78
79
  * [Spark](https://sqlframe.readthedocs.io/en/stable/spark)
79
80
 
80
- There are also two engines in development. These engines lack test coverage and robust documentation, but are available for early testing:
81
+ There is also one engine in development. This engine lacks test coverage and robust documentation, but is available for testing:
81
82
 
82
83
  * [Redshift](https://sqlframe.readthedocs.io/en/stable/redshift)
83
- * [Databricks](https://sqlframe.readthedocs.io/en/stable/databricks)
84
+
84
85
 
85
86
  SQLFrame also has a "Standalone" session that be used to generate SQL without any connection to a database engine.
86
87
 
@@ -98,6 +99,8 @@ SQLFrame is great for:
98
99
  ```bash
99
100
  # BigQuery
100
101
  pip install "sqlframe[bigquery]"
102
+ # Databricks
103
+ pip install "sqlframe[databricks]"
101
104
  # DuckDB
102
105
  pip install "sqlframe[duckdb]"
103
106
  # Postgres
@@ -108,8 +111,6 @@ pip install "sqlframe[snowflake]"
108
111
  pip install "sqlframe[spark]"
109
112
  # Redshift (in development)
110
113
  pip install "sqlframe[redshift]"
111
- # Databricks (in development)
112
- pip install "sqlframe[databricks]"
113
114
  # Standalone
114
115
  pip install sqlframe
115
116
  ```
@@ -1,11 +1,11 @@
1
1
  sqlframe/__init__.py,sha256=SB80yLTITBXHI2GCDS6n6bN5ObHqgPjfpRPAUwxaots,3403
2
- sqlframe/_version.py,sha256=9o0IPCovPUOxBDHRN7R9Zcb381abgRZxXFEyPESsRhg,513
2
+ sqlframe/_version.py,sha256=OsI8JHahRj2deRNv0lP32D0W4kMOH1vXOQfyhRqxRos,513
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=ZuU_qmt4yjSoTYgecSGnOhitOdh3rJbGCUjnUBp5mlc,38564
7
7
  sqlframe/base/column.py,sha256=AG9Z_6RNhVxLhLU29kRCgzMgDNSm-_GFg96xLqk1-bs,19838
8
- sqlframe/base/dataframe.py,sha256=DEdpFEUbbz9daxC_d-_tbeyctdF7upJezfhZ9bNbfp4,84028
8
+ sqlframe/base/dataframe.py,sha256=D2N2Kvh_tiF60fYODUikq0xRCJYY4WB2aHbEcq5NIUo,84310
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=Bs1bwl25fN3Yy9rb4GnUWBGunQ1C_yelkb2yV9DSZIY,53918
@@ -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.28.2.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
- sqlframe-3.28.2.dist-info/METADATA,sha256=oAw2UR3arflqdajH11cfP0uG0uI9PL2-Emy9nMiExVQ,8971
135
- sqlframe-3.28.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
- sqlframe-3.28.2.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
- sqlframe-3.28.2.dist-info/RECORD,,
133
+ sqlframe-3.29.0.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
134
+ sqlframe-3.29.0.dist-info/METADATA,sha256=0bSBzyT55lAQRUMQcz92sGhoaFOrc9h2EPIRyKPHRbo,8918
135
+ sqlframe-3.29.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
136
+ sqlframe-3.29.0.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
137
+ sqlframe-3.29.0.dist-info/RECORD,,