Skip to content

Commit b06e261

Browse files
committed
Fix iceberg naming issues
1 parent 9730f69 commit b06e261

44 files changed

Lines changed: 1017 additions & 577 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

opteryx/__version__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# THIS FILE IS AUTOMATICALLY UPDATED DURING THE BUILD PROCESS
22
# DO NOT EDIT THIS FILE DIRECTLY
33

4-
__build__ = 1862
4+
__build__ = 1871
55
__author__ = "@joocer"
6-
__version__ = "0.26.2-beta.1862"
6+
__version__ = "0.26.2-beta.1871"
77

88
# Store the version here so:
99
# 1) we don't load dependencies by storing it in __init__.py

opteryx/connectors/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ def register_store(prefix, connector, *, remove_prefix: bool = False, **kwargs):
181181
# uninstantiated classes aren't a type
182182
raise ValueError("connectors registered with `register_store` must be uninstantiated.")
183183

184+
if connector.__name__ == "IcebergConnector" and not remove_prefix:
185+
raise ValueError(
186+
"IcebergConnector requires remove_prefix=True so catalog prefixes don't leak into table names."
187+
)
188+
184189
# Store connector class directly (not as a string)
185190
_storage_prefixes[prefix] = {
186191
"connector": connector, # type: ignore
@@ -289,6 +294,9 @@ def connector_factory(dataset, statistics, **config):
289294
dataset = dataset[len(prefix) :]
290295
if dataset.startswith(".") or dataset.startswith("//"):
291296
dataset = dataset[1:] if dataset.startswith(".") else dataset[2:]
297+
if connector.__name__ == "IcebergConnector" and dataset and "." not in dataset:
298+
# Default to a namespace matching the prefix when one isn't provided
299+
dataset = f"{prefix}.{dataset}"
292300

293301
return connector(dataset=dataset, statistics=statistics, **connector_entry)
294302

opteryx/connectors/aws_s3_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def get_dataset_schema(self) -> RelationSchema:
176176
self.schema = next(self.read_dataset(just_schema=True), None)
177177

178178
if self.schema is None:
179-
raise DatasetNotFoundError(dataset=self.dataset)
179+
raise DatasetNotFoundError(dataset=self.dataset, connector=self.__type__)
180180

181181
return self.schema
182182

opteryx/connectors/disk_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,6 @@ def get_dataset_schema(self) -> RelationSchema:
376376
if self.schema is None:
377377
if os.path.isdir(self.dataset):
378378
raise EmptyDatasetError(dataset=self.dataset.replace(OS_SEP, "."))
379-
raise DatasetNotFoundError(dataset=self.dataset)
379+
raise DatasetNotFoundError(dataset=self.dataset, connector=self.__type__)
380380

381381
return self.schema

opteryx/connectors/file_connector.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init__(self, *args, **kwargs):
135135

136136
if ".." in self.dataset or self.dataset[0] in ("\\", "/", "~"):
137137
# Don't find any datasets which look like path traversal
138-
raise DatasetNotFoundError(dataset=self.dataset)
138+
raise DatasetNotFoundError(dataset=self.dataset, connector=self.__type__)
139139

140140
# Check if dataset contains wildcards
141141
self.has_wildcards = any(char in self.dataset for char in ["*", "?", "["])
@@ -144,7 +144,7 @@ def __init__(self, *args, **kwargs):
144144
# Expand wildcards to get list of files
145145
self.files = self._expand_wildcards(self.dataset)
146146
if not self.files:
147-
raise DatasetNotFoundError(dataset=self.dataset)
147+
raise DatasetNotFoundError(dataset=self.dataset, connector=self.__type__)
148148
# Use the first file to determine the decoder
149149
self.decoder = get_decoder(self.files[0])
150150
else:
@@ -168,7 +168,7 @@ def _expand_wildcards(self, pattern: str) -> List[str]:
168168
"""
169169
# Additional path traversal check after expansion
170170
if ".." in pattern:
171-
raise DatasetNotFoundError(dataset=pattern)
171+
raise DatasetNotFoundError(dataset=pattern, connector=self.__type__)
172172

173173
# Use glob to expand the pattern
174174
matched_files = glob.glob(pattern, recursive=False)

opteryx/connectors/gcp_cloudstorage_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def get_dataset_schema(self) -> RelationSchema:
318318
break
319319

320320
if self.schema is None:
321-
raise DatasetNotFoundError(dataset=self.dataset)
321+
raise DatasetNotFoundError(dataset=self.dataset, connector=self.__type__)
322322

323323
# if we have more than one blob we need to estimate the row count
324324
if self.schema.row_count_metric and number_of_blobs > 1:

opteryx/connectors/gcp_firestore_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def get_dataset_schema(self) -> RelationSchema:
126126
record = next(self.read_dataset(chunk_size=10), None)
127127

128128
if record is None:
129-
raise DatasetNotFoundError(dataset=self.dataset)
129+
raise DatasetNotFoundError(dataset=self.dataset, connector=self.__type__)
130130

131131
arrow_schema = record.schema
132132

opteryx/connectors/iceberg_connector.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,11 @@ def __init__(self, *args, catalog=None, io=DiskConnector, **kwargs):
148148

149149
import pyiceberg
150150

151-
self.dataset = self.dataset.lower()
152151
try:
153152
self.table = catalog.load_table(self.dataset)
154153
self.io_connector = io(**kwargs)
155154
except pyiceberg.exceptions.NoSuchTableError:
156-
raise DatasetNotFoundError(dataset=self.dataset)
155+
raise DatasetNotFoundError(dataset=self.dataset, connector=self.__type__) from None
157156

158157
def get_dataset_schema(self) -> RelationSchema:
159158
iceberg_schema = self.table.schema()

opteryx/connectors/mongodb_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def get_dataset_schema(self) -> RelationSchema:
7676
record = next(self.read_dataset(chunk_size=25), None)
7777

7878
if record is None:
79-
raise DatasetNotFoundError(dataset=self.dataset)
79+
raise DatasetNotFoundError(dataset=self.dataset, connector=self.__type__)
8080

8181
arrow_schema = record.schema
8282

opteryx/connectors/virtual_data.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def read_dataset(self, columns: list = None, **kwargs) -> "DatasetReader":
9393
def get_dataset_schema(self) -> RelationSchema:
9494
if self.dataset not in WELL_KNOWN_DATASETS:
9595
suggestion = suggest(self.dataset)
96-
raise DatasetNotFoundError(suggestion=suggestion, dataset=self.dataset)
96+
raise DatasetNotFoundError(
97+
suggestion=suggestion, dataset=self.dataset, connector=self.__type__
98+
)
9799
data_provider, _ = _load_provider(self.dataset)
98100
self.relation_statistics = data_provider.statistics()
99101
return data_provider.schema()
@@ -138,6 +140,8 @@ def __next__(self) -> "pyarrow.Table":
138140
data_provider, _ = _load_provider(self.dataset_name)
139141
if data_provider is None:
140142
suggestion = suggest(self.dataset_name.lower())
141-
raise DatasetNotFoundError(suggestion=suggestion, dataset=self.dataset_name)
143+
raise DatasetNotFoundError(
144+
suggestion=suggestion, dataset=self.dataset_name, connector="SAMPLE"
145+
)
142146
table = data_provider.read(self.date, self.variables)
143147
return arrow.post_read_projector(table, self.columns)

0 commit comments

Comments
 (0)