duckdb 1.4.1.dev113__cp312-cp312-win_amd64.whl → 1.5.0.dev37__cp312-cp312-win_amd64.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.
Potentially problematic release.
This version of duckdb might be problematic. Click here for more details.
- _duckdb.cp312-win_amd64.pyd +0 -0
- duckdb/__init__.py +374 -373
- duckdb/__init__.pyi +180 -604
- duckdb/bytes_io_wrapper.py +7 -6
- duckdb/experimental/__init__.py +1 -2
- duckdb/experimental/spark/__init__.py +4 -3
- duckdb/experimental/spark/_globals.py +8 -8
- duckdb/experimental/spark/_typing.py +9 -7
- duckdb/experimental/spark/conf.py +15 -16
- duckdb/experimental/spark/context.py +44 -60
- duckdb/experimental/spark/errors/__init__.py +35 -33
- duckdb/experimental/spark/errors/error_classes.py +1 -1
- duckdb/experimental/spark/errors/exceptions/__init__.py +1 -1
- duckdb/experimental/spark/errors/exceptions/base.py +88 -39
- duckdb/experimental/spark/errors/utils.py +16 -11
- duckdb/experimental/spark/exception.py +6 -9
- duckdb/experimental/spark/sql/__init__.py +5 -5
- duckdb/experimental/spark/sql/_typing.py +15 -8
- duckdb/experimental/spark/sql/catalog.py +20 -21
- duckdb/experimental/spark/sql/column.py +54 -47
- duckdb/experimental/spark/sql/conf.py +8 -9
- duckdb/experimental/spark/sql/dataframe.py +233 -185
- duckdb/experimental/spark/sql/functions.py +1248 -1222
- duckdb/experimental/spark/sql/group.py +52 -56
- duckdb/experimental/spark/sql/readwriter.py +94 -80
- duckdb/experimental/spark/sql/session.py +59 -64
- duckdb/experimental/spark/sql/streaming.py +10 -9
- duckdb/experimental/spark/sql/type_utils.py +64 -66
- duckdb/experimental/spark/sql/types.py +344 -308
- duckdb/experimental/spark/sql/udf.py +6 -6
- duckdb/filesystem.py +8 -13
- duckdb/functional/__init__.py +16 -2
- duckdb/polars_io.py +57 -66
- duckdb/query_graph/__main__.py +96 -91
- duckdb/typing/__init__.py +8 -8
- duckdb/typing/__init__.pyi +2 -4
- duckdb/udf.py +5 -10
- duckdb/value/__init__.py +0 -1
- duckdb/value/constant/__init__.py +59 -61
- duckdb/value/constant/__init__.pyi +4 -3
- duckdb-1.5.0.dev37.dist-info/METADATA +80 -0
- duckdb-1.5.0.dev37.dist-info/RECORD +47 -0
- duckdb-1.4.1.dev113.dist-info/METADATA +0 -326
- duckdb-1.4.1.dev113.dist-info/RECORD +0 -47
- {duckdb-1.4.1.dev113.dist-info → duckdb-1.5.0.dev37.dist-info}/WHEEL +0 -0
- {duckdb-1.4.1.dev113.dist-info → duckdb-1.5.0.dev37.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
from
|
|
2
|
-
from typing import TYPE_CHECKING, Any, Callable, Union, cast
|
|
3
|
-
|
|
1
|
+
from typing import Union, TYPE_CHECKING, Any, cast, Callable, Tuple
|
|
4
2
|
from ..exception import ContributionsAcceptedError
|
|
3
|
+
|
|
5
4
|
from .types import DataType
|
|
6
5
|
|
|
7
6
|
if TYPE_CHECKING:
|
|
8
|
-
from ._typing import
|
|
7
|
+
from ._typing import ColumnOrName, LiteralType, DecimalLiteral, DateTimeLiteral
|
|
8
|
+
|
|
9
|
+
from duckdb import ConstantExpression, ColumnExpression, FunctionExpression, Expression
|
|
9
10
|
|
|
10
|
-
from duckdb import ColumnExpression, ConstantExpression, Expression, FunctionExpression
|
|
11
11
|
from duckdb.typing import DuckDBPyType
|
|
12
12
|
|
|
13
13
|
__all__ = ["Column"]
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
def _get_expr(x
|
|
16
|
+
def _get_expr(x) -> Expression:
|
|
17
17
|
return x.expr if isinstance(x, Column) else ConstantExpression(x)
|
|
18
18
|
|
|
19
19
|
|
|
@@ -30,7 +30,7 @@ def _unary_op(
|
|
|
30
30
|
name: str,
|
|
31
31
|
doc: str = "unary operator",
|
|
32
32
|
) -> Callable[["Column"], "Column"]:
|
|
33
|
-
"""Create a method for given unary operator
|
|
33
|
+
"""Create a method for given unary operator"""
|
|
34
34
|
|
|
35
35
|
def _(self: "Column") -> "Column":
|
|
36
36
|
# Call the function identified by 'name' on the internal Expression object
|
|
@@ -45,7 +45,7 @@ def _bin_op(
|
|
|
45
45
|
name: str,
|
|
46
46
|
doc: str = "binary operator",
|
|
47
47
|
) -> Callable[["Column", Union["Column", "LiteralType", "DecimalLiteral", "DateTimeLiteral"]], "Column"]:
|
|
48
|
-
"""Create a method for given binary operator
|
|
48
|
+
"""Create a method for given binary operator"""
|
|
49
49
|
|
|
50
50
|
def _(
|
|
51
51
|
self: "Column",
|
|
@@ -63,7 +63,7 @@ def _bin_func(
|
|
|
63
63
|
name: str,
|
|
64
64
|
doc: str = "binary function",
|
|
65
65
|
) -> Callable[["Column", Union["Column", "LiteralType", "DecimalLiteral", "DateTimeLiteral"]], "Column"]:
|
|
66
|
-
"""Create a function expression for the given binary function
|
|
66
|
+
"""Create a function expression for the given binary function"""
|
|
67
67
|
|
|
68
68
|
def _(
|
|
69
69
|
self: "Column",
|
|
@@ -78,7 +78,8 @@ def _bin_func(
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
class Column:
|
|
81
|
-
"""
|
|
81
|
+
"""
|
|
82
|
+
A column in a DataFrame.
|
|
82
83
|
|
|
83
84
|
:class:`Column` instances can be created by::
|
|
84
85
|
|
|
@@ -94,11 +95,11 @@ class Column:
|
|
|
94
95
|
.. versionadded:: 1.3.0
|
|
95
96
|
"""
|
|
96
97
|
|
|
97
|
-
def __init__(self, expr: Expression)
|
|
98
|
+
def __init__(self, expr: Expression):
|
|
98
99
|
self.expr = expr
|
|
99
100
|
|
|
100
101
|
# arithmetic operators
|
|
101
|
-
def __neg__(self)
|
|
102
|
+
def __neg__(self):
|
|
102
103
|
return Column(-self.expr)
|
|
103
104
|
|
|
104
105
|
# `and`, `or`, `not` cannot be overloaded in Python,
|
|
@@ -137,8 +138,9 @@ class Column:
|
|
|
137
138
|
|
|
138
139
|
__rpow__ = _bin_op("__rpow__")
|
|
139
140
|
|
|
140
|
-
def __getitem__(self, k: Any) -> "Column":
|
|
141
|
-
"""
|
|
141
|
+
def __getitem__(self, k: Any) -> "Column":
|
|
142
|
+
"""
|
|
143
|
+
An expression that gets an item at position ``ordinal`` out of a list,
|
|
142
144
|
or gets an item by key out of a dict.
|
|
143
145
|
|
|
144
146
|
.. versionadded:: 1.3.0
|
|
@@ -151,34 +153,35 @@ class Column:
|
|
|
151
153
|
k
|
|
152
154
|
a literal value, or a slice object without step.
|
|
153
155
|
|
|
154
|
-
Returns
|
|
156
|
+
Returns
|
|
155
157
|
-------
|
|
156
158
|
:class:`Column`
|
|
157
159
|
Column representing the item got by key out of a dict, or substrings sliced by
|
|
158
160
|
the given slice object.
|
|
159
161
|
|
|
160
|
-
Examples
|
|
162
|
+
Examples
|
|
161
163
|
--------
|
|
162
|
-
>>> df = spark.createDataFrame([(
|
|
163
|
-
>>> df.select(df.l[slice(1, 3)], df.d[
|
|
164
|
+
>>> df = spark.createDataFrame([('abcedfg', {"key": "value"})], ["l", "d"])
|
|
165
|
+
>>> df.select(df.l[slice(1, 3)], df.d['key']).show()
|
|
164
166
|
+------------------+------+
|
|
165
167
|
|substring(l, 1, 3)|d[key]|
|
|
166
168
|
+------------------+------+
|
|
167
169
|
| abc| value|
|
|
168
170
|
+------------------+------+
|
|
169
|
-
"""
|
|
171
|
+
"""
|
|
170
172
|
if isinstance(k, slice):
|
|
171
173
|
raise ContributionsAcceptedError
|
|
172
174
|
# if k.step is not None:
|
|
173
175
|
# raise ValueError("Using a slice with a step value is not supported")
|
|
174
176
|
# return self.substr(k.start, k.stop)
|
|
175
177
|
else:
|
|
176
|
-
#
|
|
178
|
+
# FIXME: this is super hacky
|
|
177
179
|
expr_str = str(self.expr) + "." + str(k)
|
|
178
180
|
return Column(ColumnExpression(expr_str))
|
|
179
181
|
|
|
180
|
-
def __getattr__(self, item: Any) -> "Column":
|
|
181
|
-
"""
|
|
182
|
+
def __getattr__(self, item: Any) -> "Column":
|
|
183
|
+
"""
|
|
184
|
+
An expression that gets an item at position ``ordinal`` out of a list,
|
|
182
185
|
or gets an item by key out of a dict.
|
|
183
186
|
|
|
184
187
|
Parameters
|
|
@@ -186,53 +189,55 @@ class Column:
|
|
|
186
189
|
item
|
|
187
190
|
a literal value.
|
|
188
191
|
|
|
189
|
-
Returns
|
|
192
|
+
Returns
|
|
190
193
|
-------
|
|
191
194
|
:class:`Column`
|
|
192
195
|
Column representing the item got by key out of a dict.
|
|
193
196
|
|
|
194
|
-
Examples
|
|
197
|
+
Examples
|
|
195
198
|
--------
|
|
196
|
-
>>> df = spark.createDataFrame([(
|
|
199
|
+
>>> df = spark.createDataFrame([('abcedfg', {"key": "value"})], ["l", "d"])
|
|
197
200
|
>>> df.select(df.d.key).show()
|
|
198
201
|
+------+
|
|
199
202
|
|d[key]|
|
|
200
203
|
+------+
|
|
201
204
|
| value|
|
|
202
205
|
+------+
|
|
203
|
-
"""
|
|
206
|
+
"""
|
|
204
207
|
if item.startswith("__"):
|
|
205
|
-
|
|
206
|
-
raise AttributeError(msg)
|
|
208
|
+
raise AttributeError("Can not access __ (dunder) method")
|
|
207
209
|
return self[item]
|
|
208
210
|
|
|
209
|
-
def alias(self, alias: str)
|
|
211
|
+
def alias(self, alias: str):
|
|
210
212
|
return Column(self.expr.alias(alias))
|
|
211
213
|
|
|
212
|
-
def when(self, condition: "Column", value:
|
|
214
|
+
def when(self, condition: "Column", value: Any):
|
|
213
215
|
if not isinstance(condition, Column):
|
|
214
|
-
|
|
215
|
-
raise TypeError(msg)
|
|
216
|
+
raise TypeError("condition should be a Column")
|
|
216
217
|
v = _get_expr(value)
|
|
217
218
|
expr = self.expr.when(condition.expr, v)
|
|
218
219
|
return Column(expr)
|
|
219
220
|
|
|
220
|
-
def otherwise(self, value:
|
|
221
|
+
def otherwise(self, value: Any):
|
|
221
222
|
v = _get_expr(value)
|
|
222
223
|
expr = self.expr.otherwise(v)
|
|
223
224
|
return Column(expr)
|
|
224
225
|
|
|
225
|
-
def cast(self, dataType: Union[DataType, str]) -> "Column":
|
|
226
|
-
|
|
226
|
+
def cast(self, dataType: Union[DataType, str]) -> "Column":
|
|
227
|
+
if isinstance(dataType, str):
|
|
228
|
+
# Try to construct a default DuckDBPyType from it
|
|
229
|
+
internal_type = DuckDBPyType(dataType)
|
|
230
|
+
else:
|
|
231
|
+
internal_type = dataType.duckdb_type
|
|
227
232
|
return Column(self.expr.cast(internal_type))
|
|
228
233
|
|
|
229
|
-
def isin(self, *cols:
|
|
234
|
+
def isin(self, *cols: Any) -> "Column":
|
|
230
235
|
if len(cols) == 1 and isinstance(cols[0], (list, set)):
|
|
231
236
|
# Only one argument supplied, it's a list
|
|
232
|
-
cols = cast(
|
|
237
|
+
cols = cast(Tuple, cols[0])
|
|
233
238
|
|
|
234
239
|
cols = cast(
|
|
235
|
-
|
|
240
|
+
Tuple,
|
|
236
241
|
[_get_expr(c) for c in cols],
|
|
237
242
|
)
|
|
238
243
|
return Column(self.expr.isin(*cols))
|
|
@@ -242,14 +247,14 @@ class Column:
|
|
|
242
247
|
self,
|
|
243
248
|
other: Union["Column", "LiteralType", "DecimalLiteral", "DateTimeLiteral"],
|
|
244
249
|
) -> "Column":
|
|
245
|
-
"""
|
|
250
|
+
"""binary function"""
|
|
246
251
|
return Column(self.expr == (_get_expr(other)))
|
|
247
252
|
|
|
248
253
|
def __ne__( # type: ignore[override]
|
|
249
254
|
self,
|
|
250
|
-
other:
|
|
255
|
+
other: Any,
|
|
251
256
|
) -> "Column":
|
|
252
|
-
"""
|
|
257
|
+
"""binary function"""
|
|
253
258
|
return Column(self.expr != (_get_expr(other)))
|
|
254
259
|
|
|
255
260
|
__lt__ = _bin_op("__lt__")
|
|
@@ -342,20 +347,22 @@ class Column:
|
|
|
342
347
|
nulls_first = _unary_op("nulls_first")
|
|
343
348
|
nulls_last = _unary_op("nulls_last")
|
|
344
349
|
|
|
345
|
-
|
|
350
|
+
|
|
351
|
+
def asc_nulls_first(self) -> "Column":
|
|
346
352
|
return self.asc().nulls_first()
|
|
347
353
|
|
|
348
|
-
def asc_nulls_last(self) -> "Column":
|
|
354
|
+
def asc_nulls_last(self) -> "Column":
|
|
349
355
|
return self.asc().nulls_last()
|
|
350
356
|
|
|
351
|
-
def desc_nulls_first(self) -> "Column":
|
|
357
|
+
def desc_nulls_first(self) -> "Column":
|
|
352
358
|
return self.desc().nulls_first()
|
|
353
359
|
|
|
354
|
-
def desc_nulls_last(self) -> "Column":
|
|
360
|
+
def desc_nulls_last(self) -> "Column":
|
|
355
361
|
return self.desc().nulls_last()
|
|
356
362
|
|
|
357
|
-
def isNull(self) -> "Column":
|
|
363
|
+
def isNull(self) -> "Column":
|
|
358
364
|
return Column(self.expr.isnull())
|
|
359
365
|
|
|
360
|
-
def isNotNull(self) -> "Column":
|
|
366
|
+
def isNotNull(self) -> "Column":
|
|
361
367
|
return Column(self.expr.isnotnull())
|
|
368
|
+
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
from typing import Optional, Union
|
|
2
|
-
|
|
1
|
+
from typing import Optional, Union
|
|
2
|
+
from duckdb.experimental.spark._globals import _NoValueType, _NoValue
|
|
3
3
|
from duckdb import DuckDBPyConnection
|
|
4
|
-
from duckdb.experimental.spark._globals import _NoValue, _NoValueType
|
|
5
4
|
|
|
6
5
|
|
|
7
|
-
class RuntimeConfig:
|
|
8
|
-
def __init__(self, connection: DuckDBPyConnection)
|
|
6
|
+
class RuntimeConfig:
|
|
7
|
+
def __init__(self, connection: DuckDBPyConnection):
|
|
9
8
|
self._connection = connection
|
|
10
9
|
|
|
11
|
-
def set(self, key: str, value: str) -> None:
|
|
10
|
+
def set(self, key: str, value: str) -> None:
|
|
12
11
|
raise NotImplementedError
|
|
13
12
|
|
|
14
|
-
def isModifiable(self, key: str) -> bool:
|
|
13
|
+
def isModifiable(self, key: str) -> bool:
|
|
15
14
|
raise NotImplementedError
|
|
16
15
|
|
|
17
|
-
def unset(self, key: str) -> None:
|
|
16
|
+
def unset(self, key: str) -> None:
|
|
18
17
|
raise NotImplementedError
|
|
19
18
|
|
|
20
|
-
def get(self, key: str, default: Union[Optional[str], _NoValueType] = _NoValue) -> str:
|
|
19
|
+
def get(self, key: str, default: Union[Optional[str], _NoValueType] = _NoValue) -> str:
|
|
21
20
|
raise NotImplementedError
|
|
22
21
|
|
|
23
22
|
|