test(go): enable GetObjects constraint validation tests#155
Open
zeroshade wants to merge 2 commits into
Open
Conversation
Define the Snowflake sample_ddl_constraints fixture and enable the primary, foreign, and unique GetObjects constraint feature flags so the shared validation suite exercises constraint metadata. The constraint metadata implementation already exists in the SQL-template path (connection.go dispatches SHOW PRIMARY KEYS / IMPORTED KEYS / UNIQUE KEYS, and queries/get_objects_all.sql assembles the table_constraints structure). The three tests previously errored with NotImplementedError only because the quirks class did not define the required sample_ddl_constraints property. Snowflake preserves declared key column order (key_sequence), so the normalized quirks remain at their default of False. CHECK constraints stay disabled since Snowflake does not support them. Closes #48
Snowflake folds unquoted identifiers to upper case, but the shared validation suite matches table and column names exactly as written (lower case), consistent with how its adbc_ingest fixtures behave. Quote every identifier in sample_ddl_constraints so the constraint fixture tables and columns round-trip as lower case.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's Changed
Enables the
primary,foreign, anduniqueGetObjects constraint validation tests for the Snowflake driver.Background
The constraint metadata implementation already exists in the SQL-template path of
GetObjects:connection.godispatchesSHOW PRIMARY KEYS/SHOW IMPORTED KEYS/SHOW UNIQUE KEYS, andqueries/get_objects_all.sqlassembles thetable_constraintsstructure. The three validation tests (test_get_objects_constraints_{primary,foreign,unique}) errored withNotImplementedErroronly because the Snowflake quirks class did not define the requiredsample_ddl_constraintsproperty.Changes (
go/validation/tests/snowflake.py)sample_ddl_constraintswith Snowflake DDL that creates the primary / unique / foreign constraint fixture tables (modeled on the BigQuery driver's fixtures, adapted to Snowflake syntax — noNOT ENFORCEDclause, plus aconstraint_uniquetable since Snowflake supportsUNIQUE).get_objects_constraints_foreign,get_objects_constraints_primary, andget_objects_constraints_unique.All identifiers in the DDL are quoted to preserve lower case: Snowflake folds unquoted identifiers to upper case, but the validation suite matches table/column names exactly as written (lower case), consistent with how the suite's
adbc_ingestfixtures round-trip.get_objects_constraints_checkstays disabled (Snowflake does not support CHECK constraints). The_normalizedquirks stayFalsebecause Snowflake preserves the declared key column order (key_sequence), matching the non-normalized branch of the tests.Note on
constraint_column_usageNo driver/SQL change is required. The query emits
[]for primary/unique constraint usage, and the driverbase build round-trip (json:"...,omitempty") normalizes that empty list to null — which is exactly what the tests expect (None). Foreign-key usage is populated as before.Verification
sample_ddl_constraintsreturns 12 statements, and the_normalizedquirks are allFalse.pixi run validate --collect-only -k get_objects_constraintscollects all four constraint tests; the three enabled ones are active andcheckis skipped.constraint_column_usagerenders as null while foreign-key usage stays populated.pre-commit(ruff check/format, codespell, Apache RAT) passes on the changed file.SNOWFLAKE_URI,SNOWFLAKE_DATABASE,SNOWFLAKE_SCHEMA, and the*_SECONDARY*variants), so the live suite was not executed in this environment.Closes #48