Skip to content

test(go): enable GetObjects constraint validation tests#155

Open
zeroshade wants to merge 2 commits into
mainfrom
test/get-objects-constraints
Open

test(go): enable GetObjects constraint validation tests#155
zeroshade wants to merge 2 commits into
mainfrom
test/get-objects-constraints

Conversation

@zeroshade

@zeroshade zeroshade commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What's Changed

Enables the primary, foreign, and unique GetObjects constraint validation tests for the Snowflake driver.

Background

The constraint metadata implementation already exists in the SQL-template path of GetObjects: connection.go dispatches SHOW PRIMARY KEYS / SHOW IMPORTED KEYS / SHOW UNIQUE KEYS, and queries/get_objects_all.sql assembles the table_constraints structure. The three validation tests (test_get_objects_constraints_{primary,foreign,unique}) errored with NotImplementedError only because the Snowflake quirks class did not define the required sample_ddl_constraints property.

Changes (go/validation/tests/snowflake.py)

  • Add sample_ddl_constraints with Snowflake DDL that creates the primary / unique / foreign constraint fixture tables (modeled on the BigQuery driver's fixtures, adapted to Snowflake syntax — no NOT ENFORCED clause, plus a constraint_unique table since Snowflake supports UNIQUE).
  • Enable get_objects_constraints_foreign, get_objects_constraints_primary, and get_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_ingest fixtures round-trip.

get_objects_constraints_check stays disabled (Snowflake does not support CHECK constraints). The _normalized quirks stay False because Snowflake preserves the declared key column order (key_sequence), matching the non-normalized branch of the tests.

Note on constraint_column_usage

No 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

  • Quirks load correctly: the three flags are set, sample_ddl_constraints returns 12 statements, and the _normalized quirks are all False.
  • pixi run validate --collect-only -k get_objects_constraints collects all four constraint tests; the three enabled ones are active and check is skipped.
  • A round-trip unit check confirmed that primary/unique constraint_column_usage renders as null while foreign-key usage stays populated.
  • pre-commit (ruff check/format, codespell, Apache RAT) passes on the changed file.
  • Full end-to-end validation requires live Snowflake credentials (SNOWFLAKE_URI, SNOWFLAKE_DATABASE, SNOWFLAKE_SCHEMA, and the *_SECONDARY* variants), so the live suite was not executed in this environment.

Closes #48

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Go] Implement constraint metadata in GetObjects

1 participant