Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions go/validation/tests/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class SnowflakeQuirks(model.DriverQuirks):
connection_get_table_schema=True,
connection_transactions=True,
get_objects=True,
get_objects_constraints_foreign=False,
get_objects_constraints_primary=False,
get_objects_constraints_unique=False,
get_objects_constraints_foreign=True,
get_objects_constraints_primary=True,
get_objects_constraints_unique=True,
statement_bind=True,
statement_bulk_ingest=True,
statement_bulk_ingest_catalog=True,
Expand Down Expand Up @@ -64,6 +64,28 @@ class SnowflakeQuirks(model.DriverQuirks):
def queries_paths(self) -> tuple[Path]:
return (Path(__file__).parent.parent / "queries",)

@property
def sample_ddl_constraints(self) -> list[str]:
# Identifiers are quoted to preserve lower case: Snowflake folds unquoted
# names to upper case, but the validation suite matches the names exactly
# as written. The leading "z" column is dropped after creation so the
# constraint columns are not at ordinal position 1, ensuring GetObjects
# maps them by name rather than by ordinal position.
return [
'CREATE TABLE "constraint_primary" ("z" INT, "a" INT, "b" STRING, PRIMARY KEY ("a"))',
'CREATE TABLE "constraint_primary_multi" ("z" INT, "a" INT, "b" STRING, PRIMARY KEY ("b", "a"))',
'CREATE TABLE "constraint_primary_multi2" ("z" INT, "a" STRING, "b" INT, PRIMARY KEY ("a", "b"))',
'CREATE TABLE "constraint_unique" ("z" INT, "a" INT, "b" INT, "c" INT, UNIQUE ("a"), UNIQUE ("c", "b"))',
'CREATE TABLE "constraint_foreign" ("z" INT, "a" INT, "b" INT, FOREIGN KEY ("b") REFERENCES "constraint_primary" ("a"))',
'CREATE TABLE "constraint_foreign_multi" ("z" INT, "a" INT, "b" INT, "c" STRING, FOREIGN KEY ("c", "b") REFERENCES "constraint_primary_multi2" ("a", "b"))',
'ALTER TABLE "constraint_primary" DROP COLUMN "z"',
'ALTER TABLE "constraint_primary_multi" DROP COLUMN "z"',
'ALTER TABLE "constraint_primary_multi2" DROP COLUMN "z"',
'ALTER TABLE "constraint_unique" DROP COLUMN "z"',
'ALTER TABLE "constraint_foreign" DROP COLUMN "z"',
'ALTER TABLE "constraint_foreign_multi" DROP COLUMN "z"',
]

def is_table_not_found(self, table_name: str | None, error: Exception) -> bool:
error_msg = str(error).lower()

Expand Down
Loading