-
Notifications
You must be signed in to change notification settings - Fork 5
test(extension-types): end-to-end round-trip integration tests (PLT-1659) #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7caa7ba
ac0c1ba
335f540
5d053a1
8091414
49ebff5
9d0353d
9ccfcaa
b20c8db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -244,6 +244,34 @@ def add_records( | |
| f"got {rid_type}. Encode the column to bytes before calling add_records()." | ||
| ) | ||
|
|
||
| # Reject Arrow extension-typed columns: SQL connectors do not preserve | ||
| # ARROW:extension:* field metadata, so extension types would be silently | ||
| # dropped on read, making round-trips impossible. Use DeltaTableDatabase | ||
| # or write directly to Parquet instead. See PLT-1795 for the planned fix. | ||
| # | ||
| # Two representations are checked: | ||
| # 1. In-memory extension types: isinstance(field.type, pa.ExtensionType). | ||
| # 2. Metadata-only extension columns: a plain Arrow type whose field metadata | ||
| # contains the b"ARROW:extension:name" key. This arises when reading a | ||
| # Parquet/IPC file with an unregistered extension type — the array is | ||
| # decoded as its storage type but the metadata is preserved on the field. | ||
| _EXT_NAME_KEY = b"ARROW:extension:name" | ||
| ext_fields: list[tuple[str, str]] = [] | ||
| for field in records.schema: | ||
| if isinstance(field.type, pa.ExtensionType): | ||
| ext_fields.append((field.name, field.type.extension_name)) | ||
| elif field.metadata and _EXT_NAME_KEY in field.metadata: | ||
| ext_fields.append((field.name, field.metadata[_EXT_NAME_KEY].decode("utf-8", errors="replace"))) | ||
| if ext_fields: | ||
| ext_info = ", ".join(f"{name!r}: {ext_name!r}" for name, ext_name in ext_fields) | ||
| raise ValueError( | ||
| f"ConnectorArrowDatabase does not support Arrow extension-typed columns " | ||
| f"({ext_info}). SQL connectors do not preserve ARROW:extension:* field " | ||
| f"metadata, so extension types would be silently dropped on read. " | ||
| f"Use DeltaTableDatabase or write directly to Parquet instead. " | ||
| f"See PLT-1795 for the planned fix." | ||
| ) | ||
|
Comment on lines
+267
to
+273
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. Added |
||
|
|
||
| records = self._deduplicate_within_table(records) | ||
| record_key = self._get_record_key(record_path) | ||
| input_ids = set(cast(list[bytes], records[self.RECORD_ID_COLUMN].to_pylist())) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.