duckdb 1.4.1.dev113__cp310-cp310-macosx_11_0_arm64.whl → 1.5.0.dev32__cp310-cp310-macosx_11_0_arm64.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.cpython-310-darwin.so +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.4.1.dev113.dist-info → duckdb-1.5.0.dev32.dist-info}/METADATA +18 -18
- duckdb-1.5.0.dev32.dist-info/RECORD +47 -0
- duckdb-1.4.1.dev113.dist-info/RECORD +0 -47
- {duckdb-1.4.1.dev113.dist-info → duckdb-1.5.0.dev32.dist-info}/WHEEL +0 -0
- {duckdb-1.4.1.dev113.dist-info → duckdb-1.5.0.dev32.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
from typing import Optional, cast
|
|
1
|
+
from typing import Dict, Optional, cast
|
|
2
2
|
|
|
3
3
|
from ..utils import ErrorClassesReader
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
class PySparkException(Exception):
|
|
7
|
-
"""
|
|
6
|
+
"""
|
|
7
|
+
Base Exception for handling errors generated from PySpark.
|
|
8
|
+
"""
|
|
8
9
|
|
|
9
|
-
def __init__(
|
|
10
|
+
def __init__(
|
|
10
11
|
self,
|
|
11
12
|
message: Optional[str] = None,
|
|
12
13
|
# The error class, decides the message format, must be one of the valid options listed in 'error_classes.py'
|
|
13
14
|
error_class: Optional[str] = None,
|
|
14
15
|
# The dictionary listing the arguments specified in the message (or the error_class)
|
|
15
|
-
message_parameters: Optional[
|
|
16
|
-
)
|
|
16
|
+
message_parameters: Optional[Dict[str, str]] = None,
|
|
17
|
+
):
|
|
17
18
|
# `message` vs `error_class` & `message_parameters` are mutually exclusive.
|
|
18
19
|
assert (message is not None and (error_class is None and message_parameters is None)) or (
|
|
19
20
|
message is None and (error_class is not None and message_parameters is not None)
|
|
@@ -23,7 +24,7 @@ class PySparkException(Exception):
|
|
|
23
24
|
|
|
24
25
|
if message is None:
|
|
25
26
|
self.message = self.error_reader.get_error_message(
|
|
26
|
-
cast(
|
|
27
|
+
cast(str, error_class), cast(Dict[str, str], message_parameters)
|
|
27
28
|
)
|
|
28
29
|
else:
|
|
29
30
|
self.message = message
|
|
@@ -32,23 +33,25 @@ class PySparkException(Exception):
|
|
|
32
33
|
self.message_parameters = message_parameters
|
|
33
34
|
|
|
34
35
|
def getErrorClass(self) -> Optional[str]:
|
|
35
|
-
"""
|
|
36
|
+
"""
|
|
37
|
+
Returns an error class as a string.
|
|
36
38
|
|
|
37
39
|
.. versionadded:: 3.4.0
|
|
38
40
|
|
|
39
|
-
See Also
|
|
41
|
+
See Also
|
|
40
42
|
--------
|
|
41
43
|
:meth:`PySparkException.getMessageParameters`
|
|
42
44
|
:meth:`PySparkException.getSqlState`
|
|
43
45
|
"""
|
|
44
46
|
return self.error_class
|
|
45
47
|
|
|
46
|
-
def getMessageParameters(self) -> Optional[
|
|
47
|
-
"""
|
|
48
|
+
def getMessageParameters(self) -> Optional[Dict[str, str]]:
|
|
49
|
+
"""
|
|
50
|
+
Returns a message parameters as a dictionary.
|
|
48
51
|
|
|
49
52
|
.. versionadded:: 3.4.0
|
|
50
53
|
|
|
51
|
-
See Also
|
|
54
|
+
See Also
|
|
52
55
|
--------
|
|
53
56
|
:meth:`PySparkException.getErrorClass`
|
|
54
57
|
:meth:`PySparkException.getSqlState`
|
|
@@ -56,113 +59,159 @@ class PySparkException(Exception):
|
|
|
56
59
|
return self.message_parameters
|
|
57
60
|
|
|
58
61
|
def getSqlState(self) -> None:
|
|
59
|
-
"""
|
|
62
|
+
"""
|
|
63
|
+
Returns an SQLSTATE as a string.
|
|
60
64
|
|
|
61
65
|
Errors generated in Python have no SQLSTATE, so it always returns None.
|
|
62
66
|
|
|
63
67
|
.. versionadded:: 3.4.0
|
|
64
68
|
|
|
65
|
-
See Also
|
|
69
|
+
See Also
|
|
66
70
|
--------
|
|
67
71
|
:meth:`PySparkException.getErrorClass`
|
|
68
72
|
:meth:`PySparkException.getMessageParameters`
|
|
69
73
|
"""
|
|
70
74
|
return None
|
|
71
75
|
|
|
72
|
-
def __str__(self) -> str:
|
|
76
|
+
def __str__(self) -> str:
|
|
73
77
|
if self.getErrorClass() is not None:
|
|
74
78
|
return f"[{self.getErrorClass()}] {self.message}"
|
|
75
79
|
else:
|
|
76
80
|
return self.message
|
|
77
81
|
|
|
78
|
-
|
|
79
82
|
class AnalysisException(PySparkException):
|
|
80
|
-
"""
|
|
83
|
+
"""
|
|
84
|
+
Failed to analyze a SQL query plan.
|
|
85
|
+
"""
|
|
81
86
|
|
|
82
87
|
|
|
83
88
|
class SessionNotSameException(PySparkException):
|
|
84
|
-
"""
|
|
89
|
+
"""
|
|
90
|
+
Performed the same operation on different SparkSession.
|
|
91
|
+
"""
|
|
85
92
|
|
|
86
93
|
|
|
87
94
|
class TempTableAlreadyExistsException(AnalysisException):
|
|
88
|
-
"""
|
|
95
|
+
"""
|
|
96
|
+
Failed to create temp view since it is already exists.
|
|
97
|
+
"""
|
|
89
98
|
|
|
90
99
|
|
|
91
100
|
class ParseException(AnalysisException):
|
|
92
|
-
"""
|
|
101
|
+
"""
|
|
102
|
+
Failed to parse a SQL command.
|
|
103
|
+
"""
|
|
93
104
|
|
|
94
105
|
|
|
95
106
|
class IllegalArgumentException(PySparkException):
|
|
96
|
-
"""
|
|
107
|
+
"""
|
|
108
|
+
Passed an illegal or inappropriate argument.
|
|
109
|
+
"""
|
|
97
110
|
|
|
98
111
|
|
|
99
112
|
class ArithmeticException(PySparkException):
|
|
100
|
-
"""
|
|
113
|
+
"""
|
|
114
|
+
Arithmetic exception thrown from Spark with an error class.
|
|
115
|
+
"""
|
|
101
116
|
|
|
102
117
|
|
|
103
118
|
class UnsupportedOperationException(PySparkException):
|
|
104
|
-
"""
|
|
119
|
+
"""
|
|
120
|
+
Unsupported operation exception thrown from Spark with an error class.
|
|
121
|
+
"""
|
|
105
122
|
|
|
106
123
|
|
|
107
124
|
class ArrayIndexOutOfBoundsException(PySparkException):
|
|
108
|
-
"""
|
|
125
|
+
"""
|
|
126
|
+
Array index out of bounds exception thrown from Spark with an error class.
|
|
127
|
+
"""
|
|
109
128
|
|
|
110
129
|
|
|
111
130
|
class DateTimeException(PySparkException):
|
|
112
|
-
"""
|
|
131
|
+
"""
|
|
132
|
+
Datetime exception thrown from Spark with an error class.
|
|
133
|
+
"""
|
|
113
134
|
|
|
114
135
|
|
|
115
136
|
class NumberFormatException(IllegalArgumentException):
|
|
116
|
-
"""
|
|
137
|
+
"""
|
|
138
|
+
Number format exception thrown from Spark with an error class.
|
|
139
|
+
"""
|
|
117
140
|
|
|
118
141
|
|
|
119
142
|
class StreamingQueryException(PySparkException):
|
|
120
|
-
"""
|
|
143
|
+
"""
|
|
144
|
+
Exception that stopped a :class:`StreamingQuery`.
|
|
145
|
+
"""
|
|
121
146
|
|
|
122
147
|
|
|
123
148
|
class QueryExecutionException(PySparkException):
|
|
124
|
-
"""
|
|
149
|
+
"""
|
|
150
|
+
Failed to execute a query.
|
|
151
|
+
"""
|
|
125
152
|
|
|
126
153
|
|
|
127
154
|
class PythonException(PySparkException):
|
|
128
|
-
"""
|
|
155
|
+
"""
|
|
156
|
+
Exceptions thrown from Python workers.
|
|
157
|
+
"""
|
|
129
158
|
|
|
130
159
|
|
|
131
160
|
class SparkRuntimeException(PySparkException):
|
|
132
|
-
"""
|
|
161
|
+
"""
|
|
162
|
+
Runtime exception thrown from Spark with an error class.
|
|
163
|
+
"""
|
|
133
164
|
|
|
134
165
|
|
|
135
166
|
class SparkUpgradeException(PySparkException):
|
|
136
|
-
"""
|
|
167
|
+
"""
|
|
168
|
+
Exception thrown because of Spark upgrade.
|
|
169
|
+
"""
|
|
137
170
|
|
|
138
171
|
|
|
139
172
|
class UnknownException(PySparkException):
|
|
140
|
-
"""
|
|
173
|
+
"""
|
|
174
|
+
None of the above exceptions.
|
|
175
|
+
"""
|
|
141
176
|
|
|
142
177
|
|
|
143
178
|
class PySparkValueError(PySparkException, ValueError):
|
|
144
|
-
"""
|
|
179
|
+
"""
|
|
180
|
+
Wrapper class for ValueError to support error classes.
|
|
181
|
+
"""
|
|
145
182
|
|
|
146
183
|
|
|
147
184
|
class PySparkIndexError(PySparkException, IndexError):
|
|
148
|
-
"""
|
|
185
|
+
"""
|
|
186
|
+
Wrapper class for IndexError to support error classes.
|
|
187
|
+
"""
|
|
149
188
|
|
|
150
189
|
|
|
151
190
|
class PySparkTypeError(PySparkException, TypeError):
|
|
152
|
-
"""
|
|
191
|
+
"""
|
|
192
|
+
Wrapper class for TypeError to support error classes.
|
|
193
|
+
"""
|
|
153
194
|
|
|
154
195
|
|
|
155
196
|
class PySparkAttributeError(PySparkException, AttributeError):
|
|
156
|
-
"""
|
|
197
|
+
"""
|
|
198
|
+
Wrapper class for AttributeError to support error classes.
|
|
199
|
+
"""
|
|
157
200
|
|
|
158
201
|
|
|
159
202
|
class PySparkRuntimeError(PySparkException, RuntimeError):
|
|
160
|
-
"""
|
|
203
|
+
"""
|
|
204
|
+
Wrapper class for RuntimeError to support error classes.
|
|
205
|
+
"""
|
|
161
206
|
|
|
162
207
|
|
|
163
208
|
class PySparkAssertionError(PySparkException, AssertionError):
|
|
164
|
-
"""
|
|
209
|
+
"""
|
|
210
|
+
Wrapper class for AssertionError to support error classes.
|
|
211
|
+
"""
|
|
165
212
|
|
|
166
213
|
|
|
167
214
|
class PySparkNotImplementedError(PySparkException, NotImplementedError):
|
|
168
|
-
"""
|
|
215
|
+
"""
|
|
216
|
+
Wrapper class for NotImplementedError to support error classes.
|
|
217
|
+
"""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
#
|
|
2
2
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3
3
|
# contributor license agreements. See the NOTICE file distributed with
|
|
4
4
|
# this work for additional information regarding copyright ownership.
|
|
@@ -16,30 +16,37 @@
|
|
|
16
16
|
#
|
|
17
17
|
|
|
18
18
|
import re
|
|
19
|
+
from typing import Dict
|
|
19
20
|
|
|
20
21
|
from .error_classes import ERROR_CLASSES_MAP
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
class ErrorClassesReader:
|
|
24
|
-
"""
|
|
25
|
+
"""
|
|
26
|
+
A reader to load error information from error_classes.py.
|
|
27
|
+
"""
|
|
25
28
|
|
|
26
|
-
def __init__(self) -> None:
|
|
29
|
+
def __init__(self) -> None:
|
|
27
30
|
self.error_info_map = ERROR_CLASSES_MAP
|
|
28
31
|
|
|
29
|
-
def get_error_message(self, error_class: str, message_parameters:
|
|
30
|
-
"""
|
|
32
|
+
def get_error_message(self, error_class: str, message_parameters: Dict[str, str]) -> str:
|
|
33
|
+
"""
|
|
34
|
+
Returns the completed error message by applying message parameters to the message template.
|
|
35
|
+
"""
|
|
31
36
|
message_template = self.get_message_template(error_class)
|
|
32
37
|
# Verify message parameters.
|
|
33
38
|
message_parameters_from_template = re.findall("<([a-zA-Z0-9_-]+)>", message_template)
|
|
34
39
|
assert set(message_parameters_from_template) == set(message_parameters), (
|
|
35
|
-
f"Undefined error message parameter for error class: {error_class}.
|
|
40
|
+
f"Undefined error message parameter for error class: {error_class}. "
|
|
41
|
+
f"Parameters: {message_parameters}"
|
|
36
42
|
)
|
|
37
43
|
table = str.maketrans("<>", "{}")
|
|
38
44
|
|
|
39
45
|
return message_template.translate(table).format(**message_parameters)
|
|
40
46
|
|
|
41
47
|
def get_message_template(self, error_class: str) -> str:
|
|
42
|
-
"""
|
|
48
|
+
"""
|
|
49
|
+
Returns the message template for corresponding error class from error_classes.py.
|
|
43
50
|
|
|
44
51
|
For example,
|
|
45
52
|
when given `error_class` is "EXAMPLE_ERROR_CLASS",
|
|
@@ -86,8 +93,7 @@ class ErrorClassesReader:
|
|
|
86
93
|
if main_error_class in self.error_info_map:
|
|
87
94
|
main_error_class_info_map = self.error_info_map[main_error_class]
|
|
88
95
|
else:
|
|
89
|
-
|
|
90
|
-
raise ValueError(msg)
|
|
96
|
+
raise ValueError(f"Cannot find main error class '{main_error_class}'")
|
|
91
97
|
|
|
92
98
|
main_message_template = "\n".join(main_error_class_info_map["message"])
|
|
93
99
|
|
|
@@ -102,8 +108,7 @@ class ErrorClassesReader:
|
|
|
102
108
|
if sub_error_class in main_error_class_subclass_info_map:
|
|
103
109
|
sub_error_class_info_map = main_error_class_subclass_info_map[sub_error_class]
|
|
104
110
|
else:
|
|
105
|
-
|
|
106
|
-
raise ValueError(msg)
|
|
111
|
+
raise ValueError(f"Cannot find sub error class '{sub_error_class}'")
|
|
107
112
|
|
|
108
113
|
sub_message_template = "\n".join(sub_error_class_info_map["message"])
|
|
109
114
|
message_template = main_message_template + " " + sub_message_template
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
# ruff: noqa: D100
|
|
2
|
-
from typing import Optional
|
|
3
|
-
|
|
4
|
-
|
|
5
1
|
class ContributionsAcceptedError(NotImplementedError):
|
|
6
|
-
"""
|
|
2
|
+
"""
|
|
3
|
+
This method is not planned to be implemented, if you would like to implement this method
|
|
7
4
|
or show your interest in this method to other members of the community,
|
|
8
|
-
feel free to open up a PR or a Discussion over on https://github.com/duckdb/duckdb
|
|
9
|
-
"""
|
|
5
|
+
feel free to open up a PR or a Discussion over on https://github.com/duckdb/duckdb
|
|
6
|
+
"""
|
|
10
7
|
|
|
11
|
-
def __init__(self, message
|
|
8
|
+
def __init__(self, message=None):
|
|
12
9
|
doc = self.__class__.__doc__
|
|
13
10
|
if message:
|
|
14
|
-
doc = message +
|
|
11
|
+
doc = message + '\n' + doc
|
|
15
12
|
super().__init__(doc)
|
|
16
13
|
|
|
17
14
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
from .catalog import Catalog # noqa: D104
|
|
2
|
-
from .conf import RuntimeConfig
|
|
3
|
-
from .dataframe import DataFrame
|
|
4
|
-
from .readwriter import DataFrameWriter
|
|
5
1
|
from .session import SparkSession
|
|
2
|
+
from .readwriter import DataFrameWriter
|
|
3
|
+
from .dataframe import DataFrame
|
|
4
|
+
from .conf import RuntimeConfig
|
|
5
|
+
from .catalog import Catalog
|
|
6
6
|
|
|
7
|
-
__all__ = ["
|
|
7
|
+
__all__ = ["SparkSession", "DataFrame", "RuntimeConfig", "DataFrameWriter", "Catalog"]
|
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
from typing import (
|
|
20
20
|
Any,
|
|
21
21
|
Callable,
|
|
22
|
+
List,
|
|
22
23
|
Optional,
|
|
24
|
+
Tuple,
|
|
23
25
|
TypeVar,
|
|
24
26
|
Union,
|
|
25
27
|
)
|
|
26
|
-
|
|
27
28
|
try:
|
|
28
29
|
from typing import Literal, Protocol
|
|
29
30
|
except ImportError:
|
|
@@ -56,21 +57,24 @@ AtomicValue = TypeVar(
|
|
|
56
57
|
float,
|
|
57
58
|
)
|
|
58
59
|
|
|
59
|
-
RowLike = TypeVar("RowLike",
|
|
60
|
+
RowLike = TypeVar("RowLike", List[Any], Tuple[Any, ...], types.Row)
|
|
60
61
|
|
|
61
62
|
SQLBatchedUDFType = Literal[100]
|
|
62
63
|
|
|
63
64
|
|
|
64
65
|
class SupportsOpen(Protocol):
|
|
65
|
-
def open(self, partition_id: int, epoch_id: int) -> bool:
|
|
66
|
+
def open(self, partition_id: int, epoch_id: int) -> bool:
|
|
67
|
+
...
|
|
66
68
|
|
|
67
69
|
|
|
68
70
|
class SupportsProcess(Protocol):
|
|
69
|
-
def process(self, row: types.Row) -> None:
|
|
71
|
+
def process(self, row: types.Row) -> None:
|
|
72
|
+
...
|
|
70
73
|
|
|
71
74
|
|
|
72
75
|
class SupportsClose(Protocol):
|
|
73
|
-
def close(self, error: Exception) -> None:
|
|
76
|
+
def close(self, error: Exception) -> None:
|
|
77
|
+
...
|
|
74
78
|
|
|
75
79
|
|
|
76
80
|
class UserDefinedFunctionLike(Protocol):
|
|
@@ -79,8 +83,11 @@ class UserDefinedFunctionLike(Protocol):
|
|
|
79
83
|
deterministic: bool
|
|
80
84
|
|
|
81
85
|
@property
|
|
82
|
-
def returnType(self) -> types.DataType:
|
|
86
|
+
def returnType(self) -> types.DataType:
|
|
87
|
+
...
|
|
83
88
|
|
|
84
|
-
def __call__(self, *args: ColumnOrName) -> Column:
|
|
89
|
+
def __call__(self, *args: ColumnOrName) -> Column:
|
|
90
|
+
...
|
|
85
91
|
|
|
86
|
-
def asNondeterministic(self) -> "UserDefinedFunctionLike":
|
|
92
|
+
def asNondeterministic(self) -> "UserDefinedFunctionLike":
|
|
93
|
+
...
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
from typing import NamedTuple, Optional
|
|
2
|
-
|
|
1
|
+
from typing import List, NamedTuple, Optional
|
|
3
2
|
from .session import SparkSession
|
|
4
3
|
|
|
5
4
|
|
|
6
|
-
class Database(NamedTuple):
|
|
5
|
+
class Database(NamedTuple):
|
|
7
6
|
name: str
|
|
8
7
|
description: Optional[str]
|
|
9
8
|
locationUri: str
|
|
10
9
|
|
|
11
10
|
|
|
12
|
-
class Table(NamedTuple):
|
|
11
|
+
class Table(NamedTuple):
|
|
13
12
|
name: str
|
|
14
13
|
database: Optional[str]
|
|
15
14
|
description: Optional[str]
|
|
@@ -17,7 +16,7 @@ class Table(NamedTuple): # noqa: D101
|
|
|
17
16
|
isTemporary: bool
|
|
18
17
|
|
|
19
18
|
|
|
20
|
-
class Column(NamedTuple):
|
|
19
|
+
class Column(NamedTuple):
|
|
21
20
|
name: str
|
|
22
21
|
description: Optional[str]
|
|
23
22
|
dataType: str
|
|
@@ -26,36 +25,36 @@ class Column(NamedTuple): # noqa: D101
|
|
|
26
25
|
isBucket: bool
|
|
27
26
|
|
|
28
27
|
|
|
29
|
-
class Function(NamedTuple):
|
|
28
|
+
class Function(NamedTuple):
|
|
30
29
|
name: str
|
|
31
30
|
description: Optional[str]
|
|
32
31
|
className: str
|
|
33
32
|
isTemporary: bool
|
|
34
33
|
|
|
35
34
|
|
|
36
|
-
class Catalog:
|
|
37
|
-
def __init__(self, session: SparkSession)
|
|
35
|
+
class Catalog:
|
|
36
|
+
def __init__(self, session: SparkSession):
|
|
38
37
|
self._session = session
|
|
39
38
|
|
|
40
|
-
def listDatabases(self) ->
|
|
41
|
-
res = self._session.conn.sql(
|
|
39
|
+
def listDatabases(self) -> List[Database]:
|
|
40
|
+
res = self._session.conn.sql('select database_name from duckdb_databases()').fetchall()
|
|
42
41
|
|
|
43
|
-
def transform_to_database(x
|
|
44
|
-
return Database(name=x[0], description=None, locationUri=
|
|
42
|
+
def transform_to_database(x) -> Database:
|
|
43
|
+
return Database(name=x[0], description=None, locationUri='')
|
|
45
44
|
|
|
46
45
|
databases = [transform_to_database(x) for x in res]
|
|
47
46
|
return databases
|
|
48
47
|
|
|
49
|
-
def listTables(self) ->
|
|
50
|
-
res = self._session.conn.sql(
|
|
48
|
+
def listTables(self) -> List[Table]:
|
|
49
|
+
res = self._session.conn.sql('select table_name, database_name, sql, temporary from duckdb_tables()').fetchall()
|
|
51
50
|
|
|
52
|
-
def transform_to_table(x
|
|
53
|
-
return Table(name=x[0], database=x[1], description=x[2], tableType=
|
|
51
|
+
def transform_to_table(x) -> Table:
|
|
52
|
+
return Table(name=x[0], database=x[1], description=x[2], tableType='', isTemporary=x[3])
|
|
54
53
|
|
|
55
54
|
tables = [transform_to_table(x) for x in res]
|
|
56
55
|
return tables
|
|
57
56
|
|
|
58
|
-
def listColumns(self, tableName: str, dbName: Optional[str] = None) ->
|
|
57
|
+
def listColumns(self, tableName: str, dbName: Optional[str] = None) -> List[Column]:
|
|
59
58
|
query = f"""
|
|
60
59
|
select column_name, data_type, is_nullable from duckdb_columns() where table_name = '{tableName}'
|
|
61
60
|
"""
|
|
@@ -63,17 +62,17 @@ class Catalog: # noqa: D101
|
|
|
63
62
|
query += f" and database_name = '{dbName}'"
|
|
64
63
|
res = self._session.conn.sql(query).fetchall()
|
|
65
64
|
|
|
66
|
-
def transform_to_column(x
|
|
65
|
+
def transform_to_column(x) -> Column:
|
|
67
66
|
return Column(name=x[0], description=None, dataType=x[1], nullable=x[2], isPartition=False, isBucket=False)
|
|
68
67
|
|
|
69
68
|
columns = [transform_to_column(x) for x in res]
|
|
70
69
|
return columns
|
|
71
70
|
|
|
72
|
-
def listFunctions(self, dbName: Optional[str] = None) ->
|
|
71
|
+
def listFunctions(self, dbName: Optional[str] = None) -> List[Function]:
|
|
73
72
|
raise NotImplementedError
|
|
74
73
|
|
|
75
|
-
def setCurrentDatabase(self, dbName: str) -> None:
|
|
74
|
+
def setCurrentDatabase(self, dbName: str) -> None:
|
|
76
75
|
raise NotImplementedError
|
|
77
76
|
|
|
78
77
|
|
|
79
|
-
__all__ = ["Catalog", "
|
|
78
|
+
__all__ = ["Catalog", "Table", "Column", "Function", "Database"]
|