duckdb 1.5.0.dev44__cp313-cp313-win_amd64.whl → 1.5.0.dev94__cp313-cp313-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.

Files changed (56) hide show
  1. _duckdb-stubs/__init__.pyi +1443 -0
  2. _duckdb-stubs/_func.pyi +46 -0
  3. _duckdb-stubs/_sqltypes.pyi +75 -0
  4. _duckdb.cp313-win_amd64.pyd +0 -0
  5. adbc_driver_duckdb/__init__.py +49 -0
  6. adbc_driver_duckdb/dbapi.py +115 -0
  7. duckdb/__init__.py +341 -435
  8. duckdb/_dbapi_type_object.py +231 -0
  9. duckdb/_version.py +22 -0
  10. duckdb/bytes_io_wrapper.py +12 -9
  11. duckdb/experimental/__init__.py +2 -1
  12. duckdb/experimental/spark/__init__.py +3 -4
  13. duckdb/experimental/spark/_globals.py +8 -8
  14. duckdb/experimental/spark/_typing.py +7 -9
  15. duckdb/experimental/spark/conf.py +16 -15
  16. duckdb/experimental/spark/context.py +60 -44
  17. duckdb/experimental/spark/errors/__init__.py +33 -35
  18. duckdb/experimental/spark/errors/error_classes.py +1 -1
  19. duckdb/experimental/spark/errors/exceptions/__init__.py +1 -1
  20. duckdb/experimental/spark/errors/exceptions/base.py +39 -88
  21. duckdb/experimental/spark/errors/utils.py +11 -16
  22. duckdb/experimental/spark/exception.py +9 -6
  23. duckdb/experimental/spark/sql/__init__.py +5 -5
  24. duckdb/experimental/spark/sql/_typing.py +8 -15
  25. duckdb/experimental/spark/sql/catalog.py +21 -20
  26. duckdb/experimental/spark/sql/column.py +48 -55
  27. duckdb/experimental/spark/sql/conf.py +9 -8
  28. duckdb/experimental/spark/sql/dataframe.py +185 -233
  29. duckdb/experimental/spark/sql/functions.py +1222 -1248
  30. duckdb/experimental/spark/sql/group.py +56 -52
  31. duckdb/experimental/spark/sql/readwriter.py +80 -94
  32. duckdb/experimental/spark/sql/session.py +64 -59
  33. duckdb/experimental/spark/sql/streaming.py +9 -10
  34. duckdb/experimental/spark/sql/type_utils.py +67 -65
  35. duckdb/experimental/spark/sql/types.py +309 -345
  36. duckdb/experimental/spark/sql/udf.py +6 -6
  37. duckdb/filesystem.py +26 -16
  38. duckdb/func/__init__.py +3 -0
  39. duckdb/functional/__init__.py +12 -16
  40. duckdb/polars_io.py +130 -83
  41. duckdb/query_graph/__main__.py +91 -96
  42. duckdb/sqltypes/__init__.py +63 -0
  43. duckdb/typing/__init__.py +18 -8
  44. duckdb/udf.py +10 -5
  45. duckdb/value/__init__.py +1 -0
  46. duckdb/value/constant/__init__.py +62 -60
  47. {duckdb-1.5.0.dev44.dist-info → duckdb-1.5.0.dev94.dist-info}/METADATA +12 -4
  48. duckdb-1.5.0.dev94.dist-info/RECORD +52 -0
  49. duckdb/__init__.pyi +0 -713
  50. duckdb/functional/__init__.pyi +0 -31
  51. duckdb/typing/__init__.pyi +0 -36
  52. duckdb/value/constant/__init__.pyi +0 -115
  53. duckdb-1.5.0.dev44.dist-info/RECORD +0 -47
  54. /duckdb/{value/__init__.pyi → py.typed} +0 -0
  55. {duckdb-1.5.0.dev44.dist-info → duckdb-1.5.0.dev94.dist-info}/WHEEL +0 -0
  56. {duckdb-1.5.0.dev44.dist-info → duckdb-1.5.0.dev94.dist-info}/licenses/LICENSE +0 -0
@@ -1,7 +1,7 @@
1
- from .session import SparkSession
2
- from .readwriter import DataFrameWriter
3
- from .dataframe import DataFrame
1
+ from .catalog import Catalog # noqa: D104
4
2
  from .conf import RuntimeConfig
5
- from .catalog import Catalog
3
+ from .dataframe import DataFrame
4
+ from .readwriter import DataFrameWriter
5
+ from .session import SparkSession
6
6
 
7
- __all__ = ["SparkSession", "DataFrame", "RuntimeConfig", "DataFrameWriter", "Catalog"]
7
+ __all__ = ["Catalog", "DataFrame", "DataFrameWriter", "RuntimeConfig", "SparkSession"]
@@ -19,12 +19,11 @@
19
19
  from typing import (
20
20
  Any,
21
21
  Callable,
22
- List,
23
22
  Optional,
24
- Tuple,
25
23
  TypeVar,
26
24
  Union,
27
25
  )
26
+
28
27
  try:
29
28
  from typing import Literal, Protocol
30
29
  except ImportError:
@@ -57,24 +56,21 @@ AtomicValue = TypeVar(
57
56
  float,
58
57
  )
59
58
 
60
- RowLike = TypeVar("RowLike", List[Any], Tuple[Any, ...], types.Row)
59
+ RowLike = TypeVar("RowLike", list[Any], tuple[Any, ...], types.Row)
61
60
 
62
61
  SQLBatchedUDFType = Literal[100]
63
62
 
64
63
 
65
64
  class SupportsOpen(Protocol):
66
- def open(self, partition_id: int, epoch_id: int) -> bool:
67
- ...
65
+ def open(self, partition_id: int, epoch_id: int) -> bool: ...
68
66
 
69
67
 
70
68
  class SupportsProcess(Protocol):
71
- def process(self, row: types.Row) -> None:
72
- ...
69
+ def process(self, row: types.Row) -> None: ...
73
70
 
74
71
 
75
72
  class SupportsClose(Protocol):
76
- def close(self, error: Exception) -> None:
77
- ...
73
+ def close(self, error: Exception) -> None: ...
78
74
 
79
75
 
80
76
  class UserDefinedFunctionLike(Protocol):
@@ -83,11 +79,8 @@ class UserDefinedFunctionLike(Protocol):
83
79
  deterministic: bool
84
80
 
85
81
  @property
86
- def returnType(self) -> types.DataType:
87
- ...
82
+ def returnType(self) -> types.DataType: ...
88
83
 
89
- def __call__(self, *args: ColumnOrName) -> Column:
90
- ...
84
+ def __call__(self, *args: ColumnOrName) -> Column: ...
91
85
 
92
- def asNondeterministic(self) -> "UserDefinedFunctionLike":
93
- ...
86
+ def asNondeterministic(self) -> "UserDefinedFunctionLike": ...
@@ -1,14 +1,15 @@
1
- from typing import List, NamedTuple, Optional
1
+ from typing import NamedTuple, Optional, Union # noqa: D100
2
+
2
3
  from .session import SparkSession
3
4
 
4
5
 
5
- class Database(NamedTuple):
6
+ class Database(NamedTuple): # noqa: D101
6
7
  name: str
7
8
  description: Optional[str]
8
9
  locationUri: str
9
10
 
10
11
 
11
- class Table(NamedTuple):
12
+ class Table(NamedTuple): # noqa: D101
12
13
  name: str
13
14
  database: Optional[str]
14
15
  description: Optional[str]
@@ -16,7 +17,7 @@ class Table(NamedTuple):
16
17
  isTemporary: bool
17
18
 
18
19
 
19
- class Column(NamedTuple):
20
+ class Column(NamedTuple): # noqa: D101
20
21
  name: str
21
22
  description: Optional[str]
22
23
  dataType: str
@@ -25,36 +26,36 @@ class Column(NamedTuple):
25
26
  isBucket: bool
26
27
 
27
28
 
28
- class Function(NamedTuple):
29
+ class Function(NamedTuple): # noqa: D101
29
30
  name: str
30
31
  description: Optional[str]
31
32
  className: str
32
33
  isTemporary: bool
33
34
 
34
35
 
35
- class Catalog:
36
- def __init__(self, session: SparkSession):
36
+ class Catalog: # noqa: D101
37
+ def __init__(self, session: SparkSession) -> None: # noqa: D107
37
38
  self._session = session
38
39
 
39
- def listDatabases(self) -> List[Database]:
40
- res = self._session.conn.sql('select database_name from duckdb_databases()').fetchall()
40
+ def listDatabases(self) -> list[Database]: # noqa: D102
41
+ res = self._session.conn.sql("select database_name from duckdb_databases()").fetchall()
41
42
 
42
- def transform_to_database(x) -> Database:
43
- return Database(name=x[0], description=None, locationUri='')
43
+ def transform_to_database(x: list[str]) -> Database:
44
+ return Database(name=x[0], description=None, locationUri="")
44
45
 
45
46
  databases = [transform_to_database(x) for x in res]
46
47
  return databases
47
48
 
48
- def listTables(self) -> List[Table]:
49
- res = self._session.conn.sql('select table_name, database_name, sql, temporary from duckdb_tables()').fetchall()
49
+ def listTables(self) -> list[Table]: # noqa: D102
50
+ res = self._session.conn.sql("select table_name, database_name, sql, temporary from duckdb_tables()").fetchall()
50
51
 
51
- def transform_to_table(x) -> Table:
52
- return Table(name=x[0], database=x[1], description=x[2], tableType='', isTemporary=x[3])
52
+ def transform_to_table(x: list[str]) -> Table:
53
+ return Table(name=x[0], database=x[1], description=x[2], tableType="", isTemporary=x[3])
53
54
 
54
55
  tables = [transform_to_table(x) for x in res]
55
56
  return tables
56
57
 
57
- def listColumns(self, tableName: str, dbName: Optional[str] = None) -> List[Column]:
58
+ def listColumns(self, tableName: str, dbName: Optional[str] = None) -> list[Column]: # noqa: D102
58
59
  query = f"""
59
60
  select column_name, data_type, is_nullable from duckdb_columns() where table_name = '{tableName}'
60
61
  """
@@ -62,17 +63,17 @@ class Catalog:
62
63
  query += f" and database_name = '{dbName}'"
63
64
  res = self._session.conn.sql(query).fetchall()
64
65
 
65
- def transform_to_column(x) -> Column:
66
+ def transform_to_column(x: list[Union[str, bool]]) -> Column:
66
67
  return Column(name=x[0], description=None, dataType=x[1], nullable=x[2], isPartition=False, isBucket=False)
67
68
 
68
69
  columns = [transform_to_column(x) for x in res]
69
70
  return columns
70
71
 
71
- def listFunctions(self, dbName: Optional[str] = None) -> List[Function]:
72
+ def listFunctions(self, dbName: Optional[str] = None) -> list[Function]: # noqa: D102
72
73
  raise NotImplementedError
73
74
 
74
- def setCurrentDatabase(self, dbName: str) -> None:
75
+ def setCurrentDatabase(self, dbName: str) -> None: # noqa: D102
75
76
  raise NotImplementedError
76
77
 
77
78
 
78
- __all__ = ["Catalog", "Table", "Column", "Function", "Database"]
79
+ __all__ = ["Catalog", "Column", "Database", "Function", "Table"]
@@ -1,19 +1,19 @@
1
- from typing import Union, TYPE_CHECKING, Any, cast, Callable, Tuple
2
- from ..exception import ContributionsAcceptedError
1
+ from collections.abc import Iterable # noqa: D100
2
+ from typing import TYPE_CHECKING, Any, Callable, Union, cast
3
3
 
4
+ from ..exception import ContributionsAcceptedError
4
5
  from .types import DataType
5
6
 
6
7
  if TYPE_CHECKING:
7
- from ._typing import ColumnOrName, LiteralType, DecimalLiteral, DateTimeLiteral
8
+ from ._typing import DateTimeLiteral, DecimalLiteral, LiteralType
8
9
 
9
- from duckdb import ConstantExpression, ColumnExpression, FunctionExpression, Expression
10
-
11
- from duckdb.typing import DuckDBPyType
10
+ from duckdb import ColumnExpression, ConstantExpression, Expression, FunctionExpression
11
+ from duckdb.sqltypes import DuckDBPyType
12
12
 
13
13
  __all__ = ["Column"]
14
14
 
15
15
 
16
- def _get_expr(x) -> Expression:
16
+ def _get_expr(x: Union["Column", str]) -> 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,8 +78,7 @@ def _bin_func(
78
78
 
79
79
 
80
80
  class Column:
81
- """
82
- A column in a DataFrame.
81
+ """A column in a DataFrame.
83
82
 
84
83
  :class:`Column` instances can be created by::
85
84
 
@@ -95,11 +94,11 @@ class Column:
95
94
  .. versionadded:: 1.3.0
96
95
  """
97
96
 
98
- def __init__(self, expr: Expression):
97
+ def __init__(self, expr: Expression) -> None: # noqa: D107
99
98
  self.expr = expr
100
99
 
101
100
  # arithmetic operators
102
- def __neg__(self):
101
+ def __neg__(self) -> "Column": # noqa: D105
103
102
  return Column(-self.expr)
104
103
 
105
104
  # `and`, `or`, `not` cannot be overloaded in Python,
@@ -138,9 +137,8 @@ class Column:
138
137
 
139
138
  __rpow__ = _bin_op("__rpow__")
140
139
 
141
- def __getitem__(self, k: Any) -> "Column":
142
- """
143
- An expression that gets an item at position ``ordinal`` out of a list,
140
+ def __getitem__(self, k: Any) -> "Column": # noqa: ANN401
141
+ """An expression that gets an item at position ``ordinal`` out of a list,
144
142
  or gets an item by key out of a dict.
145
143
 
146
144
  .. versionadded:: 1.3.0
@@ -153,35 +151,34 @@ class Column:
153
151
  k
154
152
  a literal value, or a slice object without step.
155
153
 
156
- Returns
154
+ Returns:
157
155
  -------
158
156
  :class:`Column`
159
157
  Column representing the item got by key out of a dict, or substrings sliced by
160
158
  the given slice object.
161
159
 
162
- Examples
160
+ Examples:
163
161
  --------
164
- >>> df = spark.createDataFrame([('abcedfg', {"key": "value"})], ["l", "d"])
165
- >>> df.select(df.l[slice(1, 3)], df.d['key']).show()
162
+ >>> df = spark.createDataFrame([("abcedfg", {"key": "value"})], ["l", "d"])
163
+ >>> df.select(df.l[slice(1, 3)], df.d["key"]).show()
166
164
  +------------------+------+
167
165
  |substring(l, 1, 3)|d[key]|
168
166
  +------------------+------+
169
167
  | abc| value|
170
168
  +------------------+------+
171
- """
169
+ """ # noqa: D205
172
170
  if isinstance(k, slice):
173
171
  raise ContributionsAcceptedError
174
172
  # if k.step is not None:
175
173
  # raise ValueError("Using a slice with a step value is not supported")
176
174
  # return self.substr(k.start, k.stop)
177
175
  else:
178
- # FIXME: this is super hacky
176
+ # TODO: this is super hacky # noqa: TD002, TD003
179
177
  expr_str = str(self.expr) + "." + str(k)
180
178
  return Column(ColumnExpression(expr_str))
181
179
 
182
- def __getattr__(self, item: Any) -> "Column":
183
- """
184
- An expression that gets an item at position ``ordinal`` out of a list,
180
+ def __getattr__(self, item: Any) -> "Column": # noqa: ANN401
181
+ """An expression that gets an item at position ``ordinal`` out of a list,
185
182
  or gets an item by key out of a dict.
186
183
 
187
184
  Parameters
@@ -189,55 +186,53 @@ class Column:
189
186
  item
190
187
  a literal value.
191
188
 
192
- Returns
189
+ Returns:
193
190
  -------
194
191
  :class:`Column`
195
192
  Column representing the item got by key out of a dict.
196
193
 
197
- Examples
194
+ Examples:
198
195
  --------
199
- >>> df = spark.createDataFrame([('abcedfg', {"key": "value"})], ["l", "d"])
196
+ >>> df = spark.createDataFrame([("abcedfg", {"key": "value"})], ["l", "d"])
200
197
  >>> df.select(df.d.key).show()
201
198
  +------+
202
199
  |d[key]|
203
200
  +------+
204
201
  | value|
205
202
  +------+
206
- """
203
+ """ # noqa: D205
207
204
  if item.startswith("__"):
208
- raise AttributeError("Can not access __ (dunder) method")
205
+ msg = "Can not access __ (dunder) method"
206
+ raise AttributeError(msg)
209
207
  return self[item]
210
208
 
211
- def alias(self, alias: str):
209
+ def alias(self, alias: str) -> "Column": # noqa: D102
212
210
  return Column(self.expr.alias(alias))
213
211
 
214
- def when(self, condition: "Column", value: Any):
212
+ def when(self, condition: "Column", value: Union["Column", str]) -> "Column": # noqa: D102
215
213
  if not isinstance(condition, Column):
216
- raise TypeError("condition should be a Column")
214
+ msg = "condition should be a Column"
215
+ raise TypeError(msg)
217
216
  v = _get_expr(value)
218
217
  expr = self.expr.when(condition.expr, v)
219
218
  return Column(expr)
220
219
 
221
- def otherwise(self, value: Any):
220
+ def otherwise(self, value: Union["Column", str]) -> "Column": # noqa: D102
222
221
  v = _get_expr(value)
223
222
  expr = self.expr.otherwise(v)
224
223
  return Column(expr)
225
224
 
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
225
+ def cast(self, dataType: Union[DataType, str]) -> "Column": # noqa: D102
226
+ internal_type = DuckDBPyType(dataType) if isinstance(dataType, str) else dataType.duckdb_type
232
227
  return Column(self.expr.cast(internal_type))
233
228
 
234
- def isin(self, *cols: Any) -> "Column":
229
+ def isin(self, *cols: Union[Iterable[Union["Column", str]], Union["Column", str]]) -> "Column": # noqa: D102
235
230
  if len(cols) == 1 and isinstance(cols[0], (list, set)):
236
231
  # Only one argument supplied, it's a list
237
- cols = cast(Tuple, cols[0])
232
+ cols = cast("tuple", cols[0])
238
233
 
239
234
  cols = cast(
240
- Tuple,
235
+ "tuple",
241
236
  [_get_expr(c) for c in cols],
242
237
  )
243
238
  return Column(self.expr.isin(*cols))
@@ -247,14 +242,14 @@ class Column:
247
242
  self,
248
243
  other: Union["Column", "LiteralType", "DecimalLiteral", "DateTimeLiteral"],
249
244
  ) -> "Column":
250
- """binary function"""
245
+ """Binary function."""
251
246
  return Column(self.expr == (_get_expr(other)))
252
247
 
253
248
  def __ne__( # type: ignore[override]
254
249
  self,
255
- other: Any,
250
+ other: object,
256
251
  ) -> "Column":
257
- """binary function"""
252
+ """Binary function."""
258
253
  return Column(self.expr != (_get_expr(other)))
259
254
 
260
255
  __lt__ = _bin_op("__lt__")
@@ -347,22 +342,20 @@ class Column:
347
342
  nulls_first = _unary_op("nulls_first")
348
343
  nulls_last = _unary_op("nulls_last")
349
344
 
350
-
351
- def asc_nulls_first(self) -> "Column":
345
+ def asc_nulls_first(self) -> "Column": # noqa: D102
352
346
  return self.asc().nulls_first()
353
347
 
354
- def asc_nulls_last(self) -> "Column":
348
+ def asc_nulls_last(self) -> "Column": # noqa: D102
355
349
  return self.asc().nulls_last()
356
350
 
357
- def desc_nulls_first(self) -> "Column":
351
+ def desc_nulls_first(self) -> "Column": # noqa: D102
358
352
  return self.desc().nulls_first()
359
353
 
360
- def desc_nulls_last(self) -> "Column":
354
+ def desc_nulls_last(self) -> "Column": # noqa: D102
361
355
  return self.desc().nulls_last()
362
356
 
363
- def isNull(self) -> "Column":
357
+ def isNull(self) -> "Column": # noqa: D102
364
358
  return Column(self.expr.isnull())
365
359
 
366
- def isNotNull(self) -> "Column":
360
+ def isNotNull(self) -> "Column": # noqa: D102
367
361
  return Column(self.expr.isnotnull())
368
-
@@ -1,22 +1,23 @@
1
- from typing import Optional, Union
2
- from duckdb.experimental.spark._globals import _NoValueType, _NoValue
1
+ from typing import Optional, Union # noqa: D100
2
+
3
3
  from duckdb import DuckDBPyConnection
4
+ from duckdb.experimental.spark._globals import _NoValue, _NoValueType
4
5
 
5
6
 
6
- class RuntimeConfig:
7
- def __init__(self, connection: DuckDBPyConnection):
7
+ class RuntimeConfig: # noqa: D101
8
+ def __init__(self, connection: DuckDBPyConnection) -> None: # noqa: D107
8
9
  self._connection = connection
9
10
 
10
- def set(self, key: str, value: str) -> None:
11
+ def set(self, key: str, value: str) -> None: # noqa: D102
11
12
  raise NotImplementedError
12
13
 
13
- def isModifiable(self, key: str) -> bool:
14
+ def isModifiable(self, key: str) -> bool: # noqa: D102
14
15
  raise NotImplementedError
15
16
 
16
- def unset(self, key: str) -> None:
17
+ def unset(self, key: str) -> None: # noqa: D102
17
18
  raise NotImplementedError
18
19
 
19
- def get(self, key: str, default: Union[Optional[str], _NoValueType] = _NoValue) -> str:
20
+ def get(self, key: str, default: Union[Optional[str], _NoValueType] = _NoValue) -> str: # noqa: D102
20
21
  raise NotImplementedError
21
22
 
22
23