sqlframe 3.9.2__py3-none-any.whl → 3.9.3__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 = '3.9.2'
16
- __version_tuple__ = version_tuple = (3, 9, 2)
15
+ __version__ = version = '3.9.3'
16
+ __version_tuple__ = version_tuple = (3, 9, 3)
@@ -1220,6 +1220,11 @@ def get_json_object_cast_object(col: ColumnOrName, path: str) -> Column:
1220
1220
  return get_json_object(col_func(col).cast("variant"), path)
1221
1221
 
1222
1222
 
1223
+ def get_json_object_using_function(col: ColumnOrName, path: str) -> Column:
1224
+ lit = get_func_from_session("lit")
1225
+ return Column.invoke_anonymous_function(col, "GET_JSON_OBJECT", lit(path))
1226
+
1227
+
1223
1228
  def create_map_with_cast(*cols: t.Union[ColumnOrName, t.Iterable[ColumnOrName]]) -> Column:
1224
1229
  from sqlframe.base.functions import create_map
1225
1230
 
@@ -2173,7 +2173,7 @@ def current_database() -> Column:
2173
2173
  current_schema = current_database
2174
2174
 
2175
2175
 
2176
- @meta(unsupported_engines="*")
2176
+ @meta(unsupported_engines=["*", "databricks"])
2177
2177
  def current_timezone() -> Column:
2178
2178
  return Column.invoke_anonymous_function(None, "current_timezone")
2179
2179
 
@@ -2261,7 +2261,7 @@ def get(col: ColumnOrName, index: t.Union[ColumnOrName, int]) -> Column:
2261
2261
  return Column.invoke_anonymous_function(col, "get", index)
2262
2262
 
2263
2263
 
2264
- @meta(unsupported_engines="*")
2264
+ @meta(unsupported_engines=["*", "databricks"])
2265
2265
  def get_active_spark_context() -> SparkContext:
2266
2266
  """Raise RuntimeError if SparkContext is not initialized,
2267
2267
  otherwise, returns the active SparkContext."""
@@ -2778,7 +2778,7 @@ def isnotnull(col: ColumnOrName) -> Column:
2778
2778
  return Column.invoke_anonymous_function(col, "isnotnull")
2779
2779
 
2780
2780
 
2781
- @meta(unsupported_engines="*")
2781
+ @meta(unsupported_engines=["*", "databricks"])
2782
2782
  def java_method(*cols: ColumnOrName) -> Column:
2783
2783
  """
2784
2784
  Calls a method with reflection.
@@ -3050,7 +3050,7 @@ def ln(col: ColumnOrName) -> Column:
3050
3050
  return Column.invoke_expression_over_column(col, expression.Ln)
3051
3051
 
3052
3052
 
3053
- @meta(unsupported_engines="*")
3053
+ @meta(unsupported_engines=["*", "databricks"])
3054
3054
  def localtimestamp() -> Column:
3055
3055
  """
3056
3056
  Returns the current timestamp without time zone at the start of query evaluation
@@ -3080,7 +3080,7 @@ def localtimestamp() -> Column:
3080
3080
  return Column.invoke_anonymous_function(None, "localtimestamp")
3081
3081
 
3082
3082
 
3083
- @meta(unsupported_engines="*")
3083
+ @meta(unsupported_engines=["*", "databricks"])
3084
3084
  def make_dt_interval(
3085
3085
  days: t.Optional[ColumnOrName] = None,
3086
3086
  hours: t.Optional[ColumnOrName] = None,
@@ -3227,7 +3227,7 @@ def make_timestamp(
3227
3227
  )
3228
3228
 
3229
3229
 
3230
- @meta(unsupported_engines="*")
3230
+ @meta(unsupported_engines=["*", "databricks"])
3231
3231
  def make_timestamp_ltz(
3232
3232
  years: ColumnOrName,
3233
3233
  months: ColumnOrName,
@@ -3354,7 +3354,7 @@ def make_timestamp_ntz(
3354
3354
  )
3355
3355
 
3356
3356
 
3357
- @meta(unsupported_engines="*")
3357
+ @meta(unsupported_engines=["*", "databricks"])
3358
3358
  def make_ym_interval(
3359
3359
  years: t.Optional[ColumnOrName] = None,
3360
3360
  months: t.Optional[ColumnOrName] = None,
@@ -3922,7 +3922,7 @@ def printf(format: ColumnOrName, *cols: ColumnOrName) -> Column:
3922
3922
  return Column.invoke_anonymous_function(format, "printf", *cols)
3923
3923
 
3924
3924
 
3925
- @meta(unsupported_engines=["*", "spark"])
3925
+ @meta(unsupported_engines=["*", "spark", "databricks"])
3926
3926
  def product(col: ColumnOrName) -> Column:
3927
3927
  """
3928
3928
  Aggregate function: returns the product of the values in a group.
@@ -3961,7 +3961,7 @@ def product(col: ColumnOrName) -> Column:
3961
3961
  reduce = aggregate
3962
3962
 
3963
3963
 
3964
- @meta(unsupported_engines="*")
3964
+ @meta(unsupported_engines=["*", "databricks"])
3965
3965
  def reflect(*cols: ColumnOrName) -> Column:
3966
3966
  """
3967
3967
  Calls a method with reflection.
@@ -5046,7 +5046,7 @@ def to_str(value: t.Any) -> t.Optional[str]:
5046
5046
  return str(value)
5047
5047
 
5048
5048
 
5049
- @meta(unsupported_engines="*")
5049
+ @meta(unsupported_engines=["*", "databricks"])
5050
5050
  def to_timestamp_ltz(
5051
5051
  timestamp: ColumnOrName,
5052
5052
  format: t.Optional[ColumnOrName] = None,
@@ -26,7 +26,6 @@ if t.TYPE_CHECKING:
26
26
 
27
27
 
28
28
  class DatabricksCatalog(
29
- SetCurrentCatalogFromUseMixin["DatabricksSession", "DatabricksDataFrame"],
30
29
  GetCurrentCatalogFromFunctionMixin["DatabricksSession", "DatabricksDataFrame"],
31
30
  GetCurrentDatabaseFromFunctionMixin["DatabricksSession", "DatabricksDataFrame"],
32
31
  ListDatabasesFromInfoSchemaMixin["DatabricksSession", "DatabricksDataFrame"],
@@ -38,6 +37,15 @@ class DatabricksCatalog(
38
37
  CURRENT_CATALOG_EXPRESSION: exp.Expression = exp.func("current_catalog")
39
38
  UPPERCASE_INFO_SCHEMA = True
40
39
 
40
+ def setCurrentCatalog(self, catalogName: str) -> None:
41
+ self.session._collect(
42
+ exp.Use(
43
+ kind=exp.Var(this=exp.to_identifier("CATALOG")),
44
+ this=exp.parse_identifier(catalogName, dialect=self.session.input_dialect),
45
+ ),
46
+ quote_identifiers=False,
47
+ )
48
+
41
49
  def listFunctions(
42
50
  self, dbName: t.Optional[str] = None, pattern: t.Optional[str] = None
43
51
  ) -> t.List[Function]:
@@ -106,7 +114,9 @@ class DatabricksCatalog(
106
114
  )
107
115
  functions = [
108
116
  Function(
109
- name=normalize_string(x["function"], from_dialect="execution", to_dialect="output"),
117
+ name=normalize_string(
118
+ x["function"].split(".")[-1], from_dialect="execution", to_dialect="output"
119
+ ),
110
120
  catalog=normalize_string(
111
121
  schema.catalog, from_dialect="execution", to_dialect="output"
112
122
  ),
@@ -1,7 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import logging
4
- import sys
5
4
  import typing as t
6
5
 
7
6
  from sqlframe.base.catalog import Column as CatalogColumn
@@ -52,7 +51,9 @@ class DatabricksDataFrame(
52
51
  columns.append(
53
52
  CatalogColumn(
54
53
  name=normalize_string(
55
- row.col_name, from_dialect="execution", to_dialect="output"
54
+ row.col_name,
55
+ from_dialect="execution",
56
+ to_dialect="output",
56
57
  ),
57
58
  dataType=normalize_string(
58
59
  row.data_type,
@@ -19,4 +19,5 @@ from sqlframe.base.function_alternatives import ( # noqa
19
19
  arrays_overlap_renamed as arrays_overlap,
20
20
  _is_string_using_typeof_string_lcase as _is_string,
21
21
  try_element_at_zero_based as try_element_at,
22
+ get_json_object_using_function as get_json_object,
22
23
  )
@@ -44,7 +44,20 @@ class DatabricksSession(
44
44
  from databricks import sql
45
45
 
46
46
  if not hasattr(self, "_conn"):
47
- super().__init__(conn or sql.connect(server_hostname, http_path, access_token))
47
+ super().__init__(
48
+ conn or sql.connect(server_hostname, http_path, access_token, disable_pandas=True)
49
+ )
50
+
51
+ @classmethod
52
+ def _try_get_map(cls, value: t.Any) -> t.Optional[t.Dict[str, t.Any]]:
53
+ if (
54
+ value
55
+ and isinstance(value, list)
56
+ and all(isinstance(item, tuple) for item in value)
57
+ and all(len(item) == 2 for item in value)
58
+ ):
59
+ return dict(value)
60
+ return None
48
61
 
49
62
  class Builder(_BaseSession.Builder):
50
63
  DEFAULT_EXECUTION_DIALECT = "databricks"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlframe
3
- Version: 3.9.2
3
+ Version: 3.9.3
4
4
  Summary: Turning PySpark Into a Universal DataFrame API
5
5
  Home-page: https://github.com/eakmanrq/sqlframe
6
6
  Author: Ryan Eakman
@@ -1,5 +1,5 @@
1
1
  sqlframe/__init__.py,sha256=wfqm98eLoLid9oV_FzzpG5loKC6LxOhj2lXpfN7SARo,3138
2
- sqlframe/_version.py,sha256=QJm9ayY7R0okky0MsvD6a8gDu2IP6eTPk4n5rk7LAGs,411
2
+ sqlframe/_version.py,sha256=ePIdX1C-mMoAemzEjqIHTX7SWT0yo97HOcaf1C5t0aQ,411
3
3
  sqlframe/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  sqlframe/base/_typing.py,sha256=b2clI5HI1zEZKB_3Msx3FeAJQyft44ubUifJwQRVXyQ,1298
5
5
  sqlframe/base/catalog.py,sha256=SzFQalTWdhWzxUY-4ut1f9TfOECp_JmJEgNPfrRKCe0,38457
@@ -7,8 +7,8 @@ sqlframe/base/column.py,sha256=06fhVZ2nCn2QLxnfjdK-oYKeTFJC_smgSxu7u2UYlVg,17878
7
7
  sqlframe/base/dataframe.py,sha256=ICW9eJElRsVIRutuu2aVJmP9k1n4oi6MfcLR0IrsBIs,74454
8
8
  sqlframe/base/decorators.py,sha256=Jy4bf8MhZ-AJ6CWTj59bBJRqamtLbPC0USUMFrY6g0w,449
9
9
  sqlframe/base/exceptions.py,sha256=9Uwvqn2eAkDpqm4BrRgbL61qM-GMCbJEMAW8otxO46s,370
10
- sqlframe/base/function_alternatives.py,sha256=jofb2-nweefqcjUsd4xVqfRmJSZ-T_0Iq5roW2pL0OA,50768
11
- sqlframe/base/functions.py,sha256=0pfNPCgFs7qKopkM9Q-E_BxCGJHUqlk3YqIzKg4jdQ4,190024
10
+ sqlframe/base/function_alternatives.py,sha256=8nSUXoBuEA6jH-hJJraxudYlVQlRDxrt1ePlXT7KFTE,50964
11
+ sqlframe/base/functions.py,sha256=uiY9S-fUPEBKDdsisRG4bXpgGrRwj9Y5rsdKyqkSB-4,190182
12
12
  sqlframe/base/group.py,sha256=fsyG5990_Pd7gFPjTFrH9IEoAquL_wEkVpIlBAIkZJU,4091
13
13
  sqlframe/base/normalize.py,sha256=nXAJ5CwxVf4DV0GsH-q1w0p8gmjSMlv96k_ez1eVul8,3880
14
14
  sqlframe/base/operations.py,sha256=-AhNuEzcV7ZExoP1oY3blaKip-joQyJeQVvfBTs_2g4,3456
@@ -36,14 +36,14 @@ sqlframe/bigquery/types.py,sha256=KwNyuXIo-2xVVd4bZED3YrQOobKCtemlxGrJL7DrTC8,34
36
36
  sqlframe/bigquery/udf.py,sha256=ZZ1-P1zWZhQqmhBqwAxfNeKl31nDkkZgkuz7Dn28P_0,264
37
37
  sqlframe/bigquery/window.py,sha256=6GKPzuxeSapJakBaKBeT9VpED1ACdjggDv9JRILDyV0,35
38
38
  sqlframe/databricks/__init__.py,sha256=BkB_eO1UYwcf8j6x7bi4BWmDCMkfn0CUMwossWgwaG4,993
39
- sqlframe/databricks/catalog.py,sha256=LpAn2UahzyIC3VKvQ8_6OVevaxFS_mf2HM2K4e4azZ8,11309
39
+ sqlframe/databricks/catalog.py,sha256=_0KWKp6GoplS2F-oMa2bLJEJNrKcrSeO77DoKQFl1Pc,11614
40
40
  sqlframe/databricks/column.py,sha256=E1tUa62Y5HajkhgFuebU9zohrGyieudcHzTT8gfalio,40
41
- sqlframe/databricks/dataframe.py,sha256=2VbzMs6ehrXUzgFCKNCARNMVO-FNnmEeku8hPIv948c,2141
42
- sqlframe/databricks/functions.py,sha256=rDTnOyj_SKm6mzFtL4GraDNXRnbYyfpijtn8dOQDmog,640
41
+ sqlframe/databricks/dataframe.py,sha256=HjRrTVMn_H6rVUn9aw3ub2njwhUYD2s9b9YqL1W2bCA,2179
42
+ sqlframe/databricks/functions.py,sha256=nxpK7s8jqDVySVFuyigYakYI1WDkBMDGx86-6kJKqN8,695
43
43
  sqlframe/databricks/functions.pyi,sha256=jiZr-EGGuXEodEeKq56MwibcXBk4Lpy4H3brFd0DDVA,11628
44
44
  sqlframe/databricks/group.py,sha256=dU3g0DVLRlfOSCamKchQFXRd1WTFbdxoXkpEX8tPD6Y,399
45
45
  sqlframe/databricks/readwriter.py,sha256=Lter5V3y6YqDSyv6FOrLF9JRfM6f5kIgB8AC-4nfJJo,3285
46
- sqlframe/databricks/session.py,sha256=BOpYMy2bgtYZ7XvEhQD2gqzl5XHEvFHt3R2V40y2isI,1752
46
+ sqlframe/databricks/session.py,sha256=3Mg9U-Xm7cTAQC7KaUnHOhiKxzLoZ5zBjTfbLVar2WE,2146
47
47
  sqlframe/databricks/types.py,sha256=KwNyuXIo-2xVVd4bZED3YrQOobKCtemlxGrJL7DrTC8,34
48
48
  sqlframe/databricks/udf.py,sha256=3rmxv_6zSLfIxH8P8P050ZO-ki0aqBb9wWuUQBtl4m8,272
49
49
  sqlframe/databricks/window.py,sha256=6GKPzuxeSapJakBaKBeT9VpED1ACdjggDv9JRILDyV0,35
@@ -119,8 +119,8 @@ sqlframe/standalone/udf.py,sha256=azmgtUjHNIPs0WMVNId05SHwiYn41MKVBhKXsQJ5dmY,27
119
119
  sqlframe/standalone/window.py,sha256=6GKPzuxeSapJakBaKBeT9VpED1ACdjggDv9JRILDyV0,35
120
120
  sqlframe/testing/__init__.py,sha256=VVCosQhitU74A3NnE52O4mNtGZONapuEXcc20QmSlnQ,132
121
121
  sqlframe/testing/utils.py,sha256=9DDYVuocO7tygee3RaajuJNZ24sJwf_LY556kKg7kTw,13011
122
- sqlframe-3.9.2.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
123
- sqlframe-3.9.2.dist-info/METADATA,sha256=5j2ptOPa6jrnQxNPvl9qxXqIeloc-tT4AxY32cf9CRc,9142
124
- sqlframe-3.9.2.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
125
- sqlframe-3.9.2.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
126
- sqlframe-3.9.2.dist-info/RECORD,,
122
+ sqlframe-3.9.3.dist-info/LICENSE,sha256=VZu79YgW780qxaFJMr0t5ZgbOYEh04xWoxaWOaqIGWk,1068
123
+ sqlframe-3.9.3.dist-info/METADATA,sha256=X-RrDW7IFhHvBCYK7rFLvRCcMPOIBCmlNpwFbOxJmLU,9142
124
+ sqlframe-3.9.3.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
125
+ sqlframe-3.9.3.dist-info/top_level.txt,sha256=T0_RpoygaZSF6heeWwIDQgaP0varUdSK1pzjeJZRjM8,9
126
+ sqlframe-3.9.3.dist-info/RECORD,,