- Notifications
You must be signed in to change notification settings - Fork126
SEA: Normalise Column Values from Metadata queries#662
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
varun-edachali-dbx wants to merge9 commits intocol-normalisationChoose a base branch fromcol-vals-norm
base:col-normalisation
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Draft
Changes fromall commits
Commits
Show all changes
9 commits Select commitHold shift + click to select a range
966a7aa simple col transformations
varun-edachali-dbx244e3c8 simple remarks transforms
varun-edachali-dbx392e45f run e2e tests for metadata queries, run transform regardless of None …
varun-edachali-dbxe8486b3 remove redundant test
varun-edachali-dbxd82bab8 extract data type from columnType
varun-edachali-dbxa7861e9 fix unit test for DATA_TYPE
varun-edachali-dbxccd5793 nit: cleaner assignemnt of column
varun-edachali-dbx660a51f remove incompatible tests (catalog name required for SEA metadata que…
varun-edachali-dbxc015cf8 remove backend_params fixture
varun-edachali-dbxFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
23 changes: 22 additions & 1 deletionsrc/databricks/sql/backend/sea/backend.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
17 changes: 13 additions & 4 deletionssrc/databricks/sql/backend/sea/result_set.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
30 changes: 25 additions & 5 deletionssrc/databricks/sql/backend/sea/utils/metadata_mappings.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletionssrc/databricks/sql/backend/sea/utils/metadata_transforms.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| """Simple transformation functions for metadata value normalization.""" | ||
| def transform_is_autoincrement(value): | ||
| """Transform IS_AUTOINCREMENT: boolean to YES/NO string.""" | ||
| if isinstance(value, bool) or value is None: | ||
| return "YES" if value else "NO" | ||
| return value | ||
| def transform_is_nullable(value): | ||
| """Transform IS_NULLABLE: true/false to YES/NO string.""" | ||
| if value is True or value == "true": | ||
| return "YES" | ||
| elif value is False or value == "false": | ||
| return "NO" | ||
| return value | ||
| def transform_remarks(value): | ||
| if value is None: | ||
| return "" | ||
| return value | ||
| def transform_nullable(value): | ||
| """Transform NULLABLE column: boolean/string to integer.""" | ||
| if value is True or value == "true" or value == "YES": | ||
| return 1 | ||
| elif value is False or value == "false" or value == "NO": | ||
| return 0 | ||
| return value | ||
| # Type code mapping based on JDBC specification | ||
| TYPE_CODE_MAP = { | ||
| "STRING": 12, # VARCHAR | ||
| "VARCHAR": 12, # VARCHAR | ||
| "CHAR": 1, # CHAR | ||
| "INT": 4, # INTEGER | ||
| "INTEGER": 4, # INTEGER | ||
| "BIGINT": -5, # BIGINT | ||
| "SMALLINT": 5, # SMALLINT | ||
| "TINYINT": -6, # TINYINT | ||
| "DOUBLE": 8, # DOUBLE | ||
| "FLOAT": 6, # FLOAT | ||
| "REAL": 7, # REAL | ||
| "DECIMAL": 3, # DECIMAL | ||
| "NUMERIC": 2, # NUMERIC | ||
| "BOOLEAN": 16, # BOOLEAN | ||
| "DATE": 91, # DATE | ||
| "TIMESTAMP": 93, # TIMESTAMP | ||
| "BINARY": -2, # BINARY | ||
| "ARRAY": 2003, # ARRAY | ||
| "MAP": 2002, # JAVA_OBJECT | ||
| "STRUCT": 2002, # JAVA_OBJECT | ||
| } | ||
| def transform_data_type(value): | ||
| """Transform DATA_TYPE: type name to JDBC type code.""" | ||
| if isinstance(value, str): | ||
| # Handle parameterized types like DECIMAL(10,2) | ||
| base_type = value.split("(")[0].upper() | ||
| return TYPE_CODE_MAP.get(base_type, value) | ||
| return value | ||
| def transform_ordinal_position(value): | ||
| """Transform ORDINAL_POSITION: decrement by 1 (1-based to 0-based).""" | ||
| if isinstance(value, int): | ||
| return value - 1 | ||
| return value | ||
| def create_table_catalog_transform(catalog_name): | ||
| """Factory function to create TABLE_CATALOG transform with bound catalog name.""" | ||
| def transform_table_catalog(value): | ||
| """Transform TABLE_CATALOG: return the catalog name for all rows.""" | ||
| return catalog_name | ||
| return transform_table_catalog |
4 changes: 3 additions & 1 deletionsrc/databricks/sql/backend/sea/utils/result_column.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletionstests/e2e/test_driver.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletiontests/unit/test_metadata_mappings.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletionstests/unit/test_sea_backend.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.