deltacat 2.0.0b10__py3-none-any.whl → 2.0.0b11__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.
- deltacat/__init__.py +19 -15
- deltacat/benchmarking/benchmark_engine.py +4 -2
- deltacat/benchmarking/test_benchmark_pipeline.py +6 -4
- deltacat/catalog/__init__.py +62 -5
- deltacat/catalog/main/impl.py +18 -8
- deltacat/catalog/model/catalog.py +111 -73
- deltacat/catalog/model/properties.py +25 -22
- deltacat/compute/jobs/client.py +7 -5
- deltacat/constants.py +1 -2
- deltacat/env.py +10 -0
- deltacat/examples/basic_logging.py +1 -3
- deltacat/examples/{iceberg → experimental/iceberg}/iceberg_bucket_writer.py +3 -5
- deltacat/examples/{iceberg → experimental/iceberg}/iceberg_reader.py +2 -4
- deltacat/examples/indexer/indexer.py +2 -2
- deltacat/examples/indexer/job_runner.py +1 -2
- deltacat/experimental/catalog/iceberg/__init__.py +6 -0
- deltacat/{catalog → experimental/catalog}/iceberg/iceberg_catalog_config.py +1 -1
- deltacat/{catalog → experimental/catalog}/iceberg/impl.py +27 -9
- deltacat/{storage → experimental/storage}/iceberg/iceberg_scan_planner.py +1 -1
- deltacat/{storage → experimental/storage}/iceberg/impl.py +1 -1
- deltacat/experimental/storage/rivulet/__init__.py +11 -0
- deltacat/{storage → experimental/storage}/rivulet/arrow/serializer.py +7 -4
- deltacat/{storage → experimental/storage}/rivulet/dataset.py +13 -9
- deltacat/{storage → experimental/storage}/rivulet/dataset_executor.py +12 -20
- deltacat/experimental/storage/rivulet/feather/__init__.py +7 -0
- deltacat/{storage → experimental/storage}/rivulet/feather/file_reader.py +7 -5
- deltacat/{storage → experimental/storage}/rivulet/feather/serializer.py +4 -4
- deltacat/{storage → experimental/storage}/rivulet/fs/file_provider.py +3 -3
- deltacat/{storage → experimental/storage}/rivulet/fs/file_store.py +2 -2
- deltacat/{storage → experimental/storage}/rivulet/fs/output_file.py +1 -1
- deltacat/{storage → experimental/storage}/rivulet/logical_plan.py +4 -4
- deltacat/{storage → experimental/storage}/rivulet/metastore/delta.py +1 -1
- deltacat/{storage → experimental/storage}/rivulet/metastore/json_sst.py +3 -3
- deltacat/{storage → experimental/storage}/rivulet/metastore/sst.py +2 -2
- deltacat/{storage → experimental/storage}/rivulet/metastore/sst_interval_tree.py +3 -3
- deltacat/experimental/storage/rivulet/parquet/__init__.py +7 -0
- deltacat/{storage → experimental/storage}/rivulet/parquet/file_reader.py +7 -5
- deltacat/{storage → experimental/storage}/rivulet/parquet/serializer.py +4 -4
- deltacat/{storage → experimental/storage}/rivulet/reader/block_scanner.py +20 -9
- deltacat/{storage → experimental/storage}/rivulet/reader/data_reader.py +3 -3
- deltacat/{storage → experimental/storage}/rivulet/reader/data_scan.py +5 -3
- deltacat/{storage → experimental/storage}/rivulet/reader/dataset_metastore.py +4 -4
- deltacat/{storage → experimental/storage}/rivulet/reader/dataset_reader.py +8 -6
- deltacat/{storage → experimental/storage}/rivulet/reader/pyarrow_data_reader.py +4 -1
- deltacat/{storage → experimental/storage}/rivulet/reader/reader_type_registrar.py +4 -4
- deltacat/{storage → experimental/storage}/rivulet/schema/schema.py +1 -1
- deltacat/{storage → experimental/storage}/rivulet/serializer.py +1 -1
- deltacat/{storage → experimental/storage}/rivulet/serializer_factory.py +9 -5
- deltacat/experimental/storage/rivulet/shard/range_shard.py +129 -0
- deltacat/{storage → experimental/storage}/rivulet/writer/memtable_dataset_writer.py +20 -9
- deltacat/io/reader/deltacat_read_api.py +1 -1
- deltacat/storage/model/shard.py +6 -2
- deltacat/tests/catalog/main/test_catalog_impl_namespace_operations.py +130 -0
- deltacat/tests/catalog/main/test_catalog_impl_table_operations.py +436 -0
- deltacat/tests/catalog/model/__init__.py +0 -0
- deltacat/tests/catalog/model/test_table_definition.py +16 -0
- deltacat/tests/catalog/test_catalogs.py +52 -98
- deltacat/tests/catalog/test_default_catalog_impl.py +1 -2
- deltacat/tests/daft/__init__.py +0 -0
- deltacat/tests/daft/test_model.py +97 -0
- deltacat/tests/experimental/__init__.py +0 -0
- deltacat/tests/experimental/catalog/__init__.py +0 -0
- deltacat/tests/experimental/catalog/iceberg/__init__.py +0 -0
- deltacat/tests/experimental/catalog/iceberg/test_iceberg_catalog.py +71 -0
- deltacat/tests/experimental/daft/__init__.py +0 -0
- deltacat/tests/experimental/daft/test_deltacat_daft_integration.py +136 -0
- deltacat/tests/experimental/storage/__init__.py +0 -0
- deltacat/tests/experimental/storage/rivulet/__init__.py +0 -0
- deltacat/tests/{storage → experimental/storage}/rivulet/conftest.py +3 -3
- deltacat/tests/experimental/storage/rivulet/fs/__init__.py +0 -0
- deltacat/tests/{storage → experimental/storage}/rivulet/fs/test_file_location_provider.py +3 -3
- deltacat/tests/experimental/storage/rivulet/reader/__init__.py +0 -0
- deltacat/tests/experimental/storage/rivulet/reader/query_expression.py +80 -0
- deltacat/tests/experimental/storage/rivulet/reader/test_data_scan.py +119 -0
- deltacat/tests/experimental/storage/rivulet/reader/test_dataset_metastore.py +71 -0
- deltacat/tests/experimental/storage/rivulet/schema/__init__.py +0 -0
- deltacat/tests/{storage → experimental/storage}/rivulet/schema/test_schema.py +1 -1
- deltacat/tests/experimental/storage/rivulet/shard/__init__.py +0 -0
- deltacat/tests/experimental/storage/rivulet/shard/test_range_shard.py +162 -0
- deltacat/tests/{storage → experimental/storage}/rivulet/test_dataset.py +5 -3
- deltacat/tests/{storage → experimental/storage}/rivulet/test_manifest.py +5 -5
- deltacat/tests/{storage → experimental/storage}/rivulet/test_sst_interval_tree.py +5 -5
- deltacat/tests/{storage → experimental/storage}/rivulet/test_utils.py +8 -6
- deltacat/tests/experimental/storage/rivulet/writer/__init__.py +0 -0
- deltacat/tests/{storage → experimental/storage}/rivulet/writer/test_dataset_write_then_read.py +11 -9
- deltacat/tests/{storage → experimental/storage}/rivulet/writer/test_dataset_writer.py +2 -2
- deltacat/tests/{storage → experimental/storage}/rivulet/writer/test_memtable_dataset_writer.py +7 -7
- deltacat/tests/storage/model/test_shard.py +3 -1
- deltacat/types/media.py +3 -3
- deltacat/utils/daft.py +530 -4
- deltacat/utils/export.py +3 -1
- deltacat/utils/url.py +1 -1
- {deltacat-2.0.0b10.dist-info → deltacat-2.0.0b11.dist-info}/METADATA +4 -5
- {deltacat-2.0.0b10.dist-info → deltacat-2.0.0b11.dist-info}/RECORD +120 -100
- deltacat/catalog/iceberg/__init__.py +0 -4
- deltacat/daft/daft_scan.py +0 -115
- deltacat/daft/model.py +0 -258
- deltacat/daft/translator.py +0 -126
- deltacat/examples/common/fixtures.py +0 -15
- deltacat/storage/rivulet/__init__.py +0 -11
- deltacat/storage/rivulet/feather/__init__.py +0 -5
- deltacat/storage/rivulet/parquet/__init__.py +0 -5
- /deltacat/{daft → examples/experimental}/__init__.py +0 -0
- /deltacat/examples/{common → experimental/iceberg}/__init__.py +0 -0
- /deltacat/{examples/iceberg → experimental/catalog}/__init__.py +0 -0
- /deltacat/{catalog → experimental/catalog}/iceberg/overrides.py +0 -0
- /deltacat/{storage/iceberg → experimental/storage}/__init__.py +0 -0
- /deltacat/{storage/rivulet/arrow → experimental/storage/iceberg}/__init__.py +0 -0
- /deltacat/{storage → experimental/storage}/iceberg/model.py +0 -0
- /deltacat/{storage/rivulet/fs → experimental/storage/rivulet/arrow}/__init__.py +0 -0
- /deltacat/{storage/rivulet/metastore → experimental/storage/rivulet/fs}/__init__.py +0 -0
- /deltacat/{storage → experimental/storage}/rivulet/fs/input_file.py +0 -0
- /deltacat/{storage/rivulet/reader → experimental/storage/rivulet/metastore}/__init__.py +0 -0
- /deltacat/{storage → experimental/storage}/rivulet/mvp/Table.py +0 -0
- /deltacat/{storage → experimental/storage}/rivulet/mvp/__init__.py +0 -0
- /deltacat/{storage → experimental/storage}/rivulet/parquet/data_reader.py +0 -0
- /deltacat/{storage/rivulet/schema → experimental/storage/rivulet/reader}/__init__.py +0 -0
- /deltacat/{storage → experimental/storage}/rivulet/reader/query_expression.py +0 -0
- /deltacat/{storage/rivulet/writer → experimental/storage/rivulet/schema}/__init__.py +0 -0
- /deltacat/{storage → experimental/storage}/rivulet/schema/datatype.py +0 -0
- /deltacat/{tests/storage/rivulet → experimental/storage/rivulet/shard}/__init__.py +0 -0
- /deltacat/{tests/storage/rivulet/fs → experimental/storage/rivulet/writer}/__init__.py +0 -0
- /deltacat/{storage → experimental/storage}/rivulet/writer/dataset_writer.py +0 -0
- /deltacat/tests/{storage/rivulet/schema → catalog/data}/__init__.py +0 -0
- /deltacat/tests/{storage/rivulet/writer → catalog/main}/__init__.py +0 -0
- {deltacat-2.0.0b10.dist-info → deltacat-2.0.0b11.dist-info}/LICENSE +0 -0
- {deltacat-2.0.0b10.dist-info → deltacat-2.0.0b11.dist-info}/WHEEL +0 -0
- {deltacat-2.0.0b10.dist-info → deltacat-2.0.0b11.dist-info}/top_level.txt +0 -0
deltacat/daft/model.py
DELETED
@@ -1,258 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
import pyarrow as pa
|
4
|
-
from pyarrow import Field as PaField
|
5
|
-
from daft import Schema as DaftSchema, DataType
|
6
|
-
from daft.daft import (
|
7
|
-
PartitionField as DaftPartitionField,
|
8
|
-
PartitionTransform as DaftTransform,
|
9
|
-
)
|
10
|
-
from daft.logical.schema import Field as DaftField
|
11
|
-
from daft.io.scan import make_partition_field
|
12
|
-
|
13
|
-
from deltacat.storage.model.schema import Schema
|
14
|
-
from deltacat.storage.model.interop import ModelMapper
|
15
|
-
from deltacat.storage.model.partition import PartitionKey
|
16
|
-
from deltacat.storage.model.transform import (
|
17
|
-
BucketingStrategy,
|
18
|
-
Transform,
|
19
|
-
BucketTransform,
|
20
|
-
HourTransform,
|
21
|
-
DayTransform,
|
22
|
-
MonthTransform,
|
23
|
-
YearTransform,
|
24
|
-
IdentityTransform,
|
25
|
-
TruncateTransform,
|
26
|
-
)
|
27
|
-
|
28
|
-
|
29
|
-
class DaftFieldMapper(ModelMapper[DaftField, PaField]):
|
30
|
-
@staticmethod
|
31
|
-
def map(
|
32
|
-
obj: Optional[DaftField],
|
33
|
-
**kwargs,
|
34
|
-
) -> Optional[PaField]:
|
35
|
-
"""Convert Daft Field to PyArrow Field.
|
36
|
-
|
37
|
-
Args:
|
38
|
-
obj: The Daft Field to convert
|
39
|
-
**kwargs: Additional arguments
|
40
|
-
|
41
|
-
Returns:
|
42
|
-
Converted PyArrow Field object
|
43
|
-
"""
|
44
|
-
if obj is None:
|
45
|
-
return None
|
46
|
-
|
47
|
-
return pa.field(
|
48
|
-
name=obj.name,
|
49
|
-
type=obj.dtype.to_arrow_dtype(),
|
50
|
-
)
|
51
|
-
|
52
|
-
@staticmethod
|
53
|
-
def unmap(
|
54
|
-
obj: Optional[PaField],
|
55
|
-
**kwargs,
|
56
|
-
) -> Optional[DaftField]:
|
57
|
-
"""Convert PyArrow Field to Daft Field.
|
58
|
-
|
59
|
-
Args:
|
60
|
-
obj: The PyArrow Field to convert
|
61
|
-
**kwargs: Additional arguments
|
62
|
-
|
63
|
-
Returns:
|
64
|
-
Converted Daft Field object
|
65
|
-
"""
|
66
|
-
if obj is None:
|
67
|
-
return None
|
68
|
-
|
69
|
-
return DaftField.create(
|
70
|
-
name=obj.name,
|
71
|
-
dtype=DataType.from_arrow_type(obj.type), # type: ignore
|
72
|
-
)
|
73
|
-
|
74
|
-
|
75
|
-
class DaftTransformMapper(ModelMapper[DaftTransform, Transform]):
|
76
|
-
@staticmethod
|
77
|
-
def map(
|
78
|
-
obj: Optional[DaftTransform],
|
79
|
-
**kwargs,
|
80
|
-
) -> Optional[Transform]:
|
81
|
-
"""Convert DaftTransform to DeltaCAT Transform.
|
82
|
-
|
83
|
-
Args:
|
84
|
-
obj: The DaftTransform to convert
|
85
|
-
**kwargs: Additional arguments
|
86
|
-
|
87
|
-
Returns:
|
88
|
-
Converted Transform object
|
89
|
-
"""
|
90
|
-
|
91
|
-
# daft.PartitionTransform doesn't have a Python interface for accessing its attributes,
|
92
|
-
# thus conversion is not possible.
|
93
|
-
# TODO: request Daft to expose Python friendly interface for daft.PartitionTransform
|
94
|
-
raise NotImplementedError(
|
95
|
-
"Converting transform from Daft to DeltaCAT is not supported"
|
96
|
-
)
|
97
|
-
|
98
|
-
@staticmethod
|
99
|
-
def unmap(
|
100
|
-
obj: Optional[Transform],
|
101
|
-
**kwargs,
|
102
|
-
) -> Optional[DaftTransform]:
|
103
|
-
"""Convert DeltaCAT Transform to DaftTransform.
|
104
|
-
|
105
|
-
Args:
|
106
|
-
obj: The Transform to convert
|
107
|
-
**kwargs: Additional arguments
|
108
|
-
|
109
|
-
Returns:
|
110
|
-
Converted DaftTransform object
|
111
|
-
"""
|
112
|
-
if obj is None:
|
113
|
-
return None
|
114
|
-
|
115
|
-
# Map DeltaCAT transforms to Daft transforms using isinstance
|
116
|
-
|
117
|
-
if isinstance(obj, IdentityTransform):
|
118
|
-
return DaftTransform.identity()
|
119
|
-
elif isinstance(obj, HourTransform):
|
120
|
-
return DaftTransform.hour()
|
121
|
-
elif isinstance(obj, DayTransform):
|
122
|
-
return DaftTransform.day()
|
123
|
-
elif isinstance(obj, MonthTransform):
|
124
|
-
return DaftTransform.month()
|
125
|
-
elif isinstance(obj, YearTransform):
|
126
|
-
return DaftTransform.year()
|
127
|
-
elif isinstance(obj, BucketTransform):
|
128
|
-
if obj.parameters.bucketing_strategy == BucketingStrategy.ICEBERG:
|
129
|
-
return DaftTransform.iceberg_bucket(obj.parameters.num_buckets)
|
130
|
-
else:
|
131
|
-
raise ValueError(
|
132
|
-
f"Unsupported Bucketing Strategy: {obj.parameters.bucketing_strategy}"
|
133
|
-
)
|
134
|
-
elif isinstance(obj, TruncateTransform):
|
135
|
-
return DaftTransform.iceberg_truncate(obj.parameters.width)
|
136
|
-
|
137
|
-
raise ValueError(f"Unsupported Transform: {obj}")
|
138
|
-
|
139
|
-
|
140
|
-
class DaftPartitionKeyMapper(ModelMapper[DaftPartitionField, PartitionKey]):
|
141
|
-
@staticmethod
|
142
|
-
def map(
|
143
|
-
obj: Optional[DaftPartitionField],
|
144
|
-
schema: Optional[DaftSchema] = None,
|
145
|
-
**kwargs,
|
146
|
-
) -> Optional[PartitionKey]:
|
147
|
-
"""Convert DaftPartitionField to PartitionKey.
|
148
|
-
|
149
|
-
Args:
|
150
|
-
obj: The DaftPartitionField to convert
|
151
|
-
schema: The Daft schema containing field information
|
152
|
-
**kwargs: Additional arguments
|
153
|
-
|
154
|
-
Returns:
|
155
|
-
Converted PartitionKey object
|
156
|
-
"""
|
157
|
-
# Daft PartitionField only exposes 1 attribute `field` which is not enough
|
158
|
-
# to convert to DeltaCAT PartitionKey
|
159
|
-
# TODO: request Daft to expose more Python friendly interface for PartitionField
|
160
|
-
raise NotImplementedError(
|
161
|
-
f"Converting Daft PartitionField to DeltaCAT PartitionKey is not supported"
|
162
|
-
)
|
163
|
-
|
164
|
-
@staticmethod
|
165
|
-
def unmap(
|
166
|
-
obj: Optional[PartitionKey],
|
167
|
-
schema: Optional[Schema] = None,
|
168
|
-
**kwargs,
|
169
|
-
) -> Optional[DaftPartitionField]:
|
170
|
-
"""Convert PartitionKey to DaftPartitionField.
|
171
|
-
|
172
|
-
Args:
|
173
|
-
obj: The DeltaCAT PartitionKey to convert
|
174
|
-
schema: The Schema containing field information
|
175
|
-
**kwargs: Additional arguments
|
176
|
-
|
177
|
-
Returns:
|
178
|
-
Converted DaftPartitionField object
|
179
|
-
"""
|
180
|
-
if obj is None:
|
181
|
-
return None
|
182
|
-
if obj.name is None:
|
183
|
-
raise ValueError("Name is required for PartitionKey conversion")
|
184
|
-
if not schema:
|
185
|
-
raise ValueError("Schema is required for PartitionKey conversion")
|
186
|
-
if len(obj.key) < 1:
|
187
|
-
raise ValueError(
|
188
|
-
f"At least 1 PartitionKey FieldLocator is expected, instead got {len(obj.key)}. FieldLocators: {obj.key}."
|
189
|
-
)
|
190
|
-
|
191
|
-
# Get the source field from schema - FieldLocator in PartitionKey.key points to the source field of partition field
|
192
|
-
dc_source_field = schema.field(obj.key[0]).arrow
|
193
|
-
daft_source_field = DaftFieldMapper.unmap(obj=dc_source_field)
|
194
|
-
# Convert transform if present
|
195
|
-
daft_transform = DaftTransformMapper.unmap(obj.transform)
|
196
|
-
daft_partition_field = DaftPartitionKeyMapper.get_daft_partition_field(
|
197
|
-
partition_field_name=obj.name,
|
198
|
-
daft_source_field=daft_source_field,
|
199
|
-
dc_transform=obj.transform,
|
200
|
-
)
|
201
|
-
|
202
|
-
# Create DaftPartitionField
|
203
|
-
return make_partition_field(
|
204
|
-
field=daft_partition_field,
|
205
|
-
source_field=daft_source_field,
|
206
|
-
transform=daft_transform,
|
207
|
-
)
|
208
|
-
|
209
|
-
@staticmethod
|
210
|
-
def get_daft_partition_field(
|
211
|
-
partition_field_name: str,
|
212
|
-
daft_source_field: Optional[DaftField],
|
213
|
-
# TODO: replace DeltaCAT transform with Daft Transform for uniformality
|
214
|
-
# We cannot use Daft Transform here because Daft Transform doesn't have a Python interface for us to
|
215
|
-
# access its attributes.
|
216
|
-
# TODO: request Daft to provide a more python friendly interface for Daft Tranform
|
217
|
-
dc_transform: Optional[Transform],
|
218
|
-
) -> DaftField:
|
219
|
-
"""Generate Daft Partition Field given partition field name, source field and transform.
|
220
|
-
Partition field type is inferred using source field type and transform.
|
221
|
-
|
222
|
-
Args:
|
223
|
-
partition_field_name (str): the specified result field name
|
224
|
-
daft_source_field (DaftField): the source field of the partition field
|
225
|
-
daft_transform (DaftTransform): transform applied on the source field to create partition field
|
226
|
-
|
227
|
-
Returns:
|
228
|
-
DaftField: Daft Field representing the partition field
|
229
|
-
"""
|
230
|
-
if daft_source_field is None:
|
231
|
-
raise ValueError("Source field is required for PartitionField conversion")
|
232
|
-
if dc_transform is None:
|
233
|
-
raise ValueError("Transform is required for PartitionField conversion")
|
234
|
-
|
235
|
-
result_type = None
|
236
|
-
# Below type conversion logic references Daft - Iceberg conversion logic:
|
237
|
-
# https://github.com/Eventual-Inc/Daft/blob/7f2e9b5fb50fdfe858be17572f132b37dd6e5ab2/daft/iceberg/iceberg_scan.py#L61-L85
|
238
|
-
if isinstance(dc_transform, IdentityTransform):
|
239
|
-
result_type = daft_source_field.dtype
|
240
|
-
elif isinstance(dc_transform, YearTransform):
|
241
|
-
result_type = DataType.int32()
|
242
|
-
elif isinstance(dc_transform, MonthTransform):
|
243
|
-
result_type = DataType.int32()
|
244
|
-
elif isinstance(dc_transform, DayTransform):
|
245
|
-
result_type = DataType.int32()
|
246
|
-
elif isinstance(dc_transform, HourTransform):
|
247
|
-
result_type = DataType.int32()
|
248
|
-
elif isinstance(dc_transform, BucketTransform):
|
249
|
-
result_type = DataType.int32()
|
250
|
-
elif isinstance(dc_transform, TruncateTransform):
|
251
|
-
result_type = daft_source_field.dtype
|
252
|
-
else:
|
253
|
-
raise ValueError(f"Unsupported transform: {dc_transform}")
|
254
|
-
|
255
|
-
return DaftField.create(
|
256
|
-
name=partition_field_name,
|
257
|
-
dtype=result_type,
|
258
|
-
)
|
deltacat/daft/translator.py
DELETED
@@ -1,126 +0,0 @@
|
|
1
|
-
from daft.io.scan import ScanPushdowns
|
2
|
-
import pyarrow as pa
|
3
|
-
from typing import Callable, Dict
|
4
|
-
from daft.io.pushdowns import (
|
5
|
-
Expr as DaftExpr,
|
6
|
-
Literal as DaftLiteral,
|
7
|
-
Reference as DaftReference,
|
8
|
-
TermVisitor,
|
9
|
-
)
|
10
|
-
|
11
|
-
from deltacat.storage.model.expression import (
|
12
|
-
Expression,
|
13
|
-
Reference,
|
14
|
-
Literal,
|
15
|
-
Equal,
|
16
|
-
NotEqual,
|
17
|
-
GreaterThan,
|
18
|
-
LessThan,
|
19
|
-
GreaterThanEqual,
|
20
|
-
LessThanEqual,
|
21
|
-
And,
|
22
|
-
Or,
|
23
|
-
Not,
|
24
|
-
IsNull,
|
25
|
-
)
|
26
|
-
from deltacat.storage.model.scan.push_down import PartitionFilter, Pushdown
|
27
|
-
|
28
|
-
|
29
|
-
def translate_pushdown(pushdown: ScanPushdowns) -> Pushdown:
|
30
|
-
"""
|
31
|
-
Helper method to translate a Daft ScanPushdowns object into a Deltacat Pushdown.
|
32
|
-
|
33
|
-
Args:
|
34
|
-
pushdown: Daft ScanPushdowns object
|
35
|
-
|
36
|
-
Returns:
|
37
|
-
Pushdown: Deltacat Pushdown object with translated filters
|
38
|
-
"""
|
39
|
-
translator = DaftToDeltacatExpressionTranslator()
|
40
|
-
partition_filter = None
|
41
|
-
|
42
|
-
if pushdown.predicate:
|
43
|
-
predicate = translator.visit(pushdown.predicate, None)
|
44
|
-
partition_filter = PartitionFilter.of(predicate)
|
45
|
-
|
46
|
-
# TODO: translate other pushdown filters
|
47
|
-
return Pushdown.of(
|
48
|
-
row_filter=None,
|
49
|
-
column_filter=None,
|
50
|
-
partition_filter=partition_filter,
|
51
|
-
limit=None,
|
52
|
-
)
|
53
|
-
|
54
|
-
|
55
|
-
class DaftToDeltacatExpressionTranslator(TermVisitor[None, Expression]):
|
56
|
-
"""
|
57
|
-
This visitor implementation traverses a Daft expression tree and produces
|
58
|
-
an equivalent Deltacat expression tree for use in Deltacat's query pushdown
|
59
|
-
system.
|
60
|
-
"""
|
61
|
-
|
62
|
-
_PROCEDURES: Dict[str, Callable[..., Expression]] = {
|
63
|
-
# Comparison predicates
|
64
|
-
"=": Equal.of,
|
65
|
-
"!=": NotEqual.of,
|
66
|
-
"<": LessThan.of,
|
67
|
-
">": GreaterThan.of,
|
68
|
-
"<=": LessThanEqual.of,
|
69
|
-
">=": GreaterThanEqual.of,
|
70
|
-
# Logical predicates
|
71
|
-
"and": And.of,
|
72
|
-
"or": Or.of,
|
73
|
-
"not": Not.of,
|
74
|
-
# Special operations
|
75
|
-
"is_null": IsNull.of,
|
76
|
-
}
|
77
|
-
|
78
|
-
def visit_reference(self, term: DaftReference, context: None) -> Expression:
|
79
|
-
"""
|
80
|
-
Convert Daft Reference to Deltacat Reference.
|
81
|
-
|
82
|
-
Args:
|
83
|
-
term: A Daft Reference expression representing a field or column.
|
84
|
-
context: Not used in this visitor implementation.
|
85
|
-
|
86
|
-
Returns:
|
87
|
-
DeltacatExpression: A Deltacat Reference expression for the same field.
|
88
|
-
"""
|
89
|
-
return Reference(term.path)
|
90
|
-
|
91
|
-
def visit_literal(self, term: DaftLiteral, context: None) -> Expression:
|
92
|
-
"""
|
93
|
-
Convert Daft Literal to Deltacat Literal.
|
94
|
-
|
95
|
-
Args:
|
96
|
-
term: A Daft Literal expression representing a constant value.
|
97
|
-
context: Not used in this visitor implementation.
|
98
|
-
|
99
|
-
Returns:
|
100
|
-
DeltacatExpression: A Deltacat Literal expression wrapping the same value as a PyArrow scalar.
|
101
|
-
"""
|
102
|
-
return Literal(pa.scalar(term.value))
|
103
|
-
|
104
|
-
def visit_expr(self, term: DaftExpr, context: None) -> Expression:
|
105
|
-
"""
|
106
|
-
This method handles the translation of procedure calls (operations) from
|
107
|
-
Daft to Deltacat, including special cases for IN, BETWEEN, and LIKE.
|
108
|
-
|
109
|
-
Args:
|
110
|
-
term: A Daft Expr expression representing an operation.
|
111
|
-
context: Not used in this visitor implementation.
|
112
|
-
|
113
|
-
Returns:
|
114
|
-
DeltacatExpression: An equivalent Deltacat expression.
|
115
|
-
|
116
|
-
Raises:
|
117
|
-
ValueError: If the operation has an invalid number of arguments or
|
118
|
-
if the operation is not supported by Deltacat.
|
119
|
-
"""
|
120
|
-
proc = term.proc
|
121
|
-
args = [self.visit(arg.term, context) for arg in term.args]
|
122
|
-
|
123
|
-
if proc not in self._PROCEDURES:
|
124
|
-
raise ValueError(f"Deltacat does not support procedure '{proc}'.")
|
125
|
-
|
126
|
-
return self._PROCEDURES[proc](*args)
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import logging
|
3
|
-
import argparse
|
4
|
-
from deltacat import logs
|
5
|
-
|
6
|
-
logger = logs.configure_deltacat_logger(logging.getLogger(__name__))
|
7
|
-
|
8
|
-
|
9
|
-
def store_cli_args_in_os_environ(script_args_list=[]):
|
10
|
-
parser = argparse.ArgumentParser()
|
11
|
-
for args, kwargs in script_args_list:
|
12
|
-
parser.add_argument(*args, **kwargs)
|
13
|
-
args = parser.parse_args()
|
14
|
-
print(f"Command Line Arguments: {args}")
|
15
|
-
os.environ.update(vars(args))
|
@@ -1,11 +0,0 @@
|
|
1
|
-
from deltacat.storage.rivulet.schema.schema import Schema
|
2
|
-
from deltacat.storage.rivulet.schema.schema import Field
|
3
|
-
from deltacat.storage.rivulet.dataset import Dataset
|
4
|
-
from deltacat.storage.rivulet.schema.schema import Datatype
|
5
|
-
|
6
|
-
__all__ = [
|
7
|
-
"Schema",
|
8
|
-
"Field",
|
9
|
-
"Dataset",
|
10
|
-
"Datatype",
|
11
|
-
]
|
@@ -1,5 +0,0 @@
|
|
1
|
-
# TODO later on this will be moved to a dedicated package
|
2
|
-
from deltacat.storage.rivulet.feather.file_reader import FeatherFileReader
|
3
|
-
from deltacat.storage.rivulet.reader.reader_type_registrar import FileReaderRegistrar
|
4
|
-
|
5
|
-
FileReaderRegistrar.register_reader("feather", FeatherFileReader)
|
@@ -1,5 +0,0 @@
|
|
1
|
-
# TODO later on this will be moved to a dedicated package
|
2
|
-
from deltacat.storage.rivulet.parquet.file_reader import ParquetFileReader
|
3
|
-
from deltacat.storage.rivulet.reader.reader_type_registrar import FileReaderRegistrar
|
4
|
-
|
5
|
-
FileReaderRegistrar.register_reader("parquet", ParquetFileReader)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|