Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion docs/reference/adapters/adbc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ SQLSpec does not define a portable SQL statistics contract. It wraps
- Unsupported (raises ``OperationalError``)
* - Flight SQL / GizmoSQL
- Native overlay is server dependent; central dialect fallback applies
when the backend dialect is mapped
when the backend dialect is mapped. DuckDB-backed GizmoSQL exposes
catalogs, schemas, tables, columns, and constraints through
``GetObjects`` when the server returns a complete payload; incomplete
constraint or nullability metadata falls back to SQLSpec's central
dialect SQL.
- Server dependent
* - BigQuery
- Central BigQuery SQL fallback
Expand Down
37 changes: 36 additions & 1 deletion tests/integration/adapters/adbc/test_gizmosql_data_dictionary.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""GizmoSQL data dictionary and migration integration tests for ADBC."""

from pathlib import Path
from typing import Any
from typing import Any, cast

import pytest

Expand All @@ -13,6 +13,21 @@
pytestmark = [pytest.mark.adbc, pytest.mark.xdist_group("gizmosql")]


def _get_objects_dict_list(value: object) -> list[dict[str, Any]]:
if not isinstance(value, list):
return []
return [cast("dict[str, Any]", item) for item in value if isinstance(item, dict)]


def _find_get_objects_table(rows: list[dict[str, Any]], table_name: str) -> dict[str, Any] | None:
for catalog in rows:
for db_schema in _get_objects_dict_list(catalog.get("catalog_db_schemas")):
for table in _get_objects_dict_list(db_schema.get("db_schema_tables")):
if table.get("table_name") == table_name:
return table
return None


@xfail_if_driver_missing
def test_gizmosql_data_dictionary_tables_columns_and_indexes(adbc_gizmosql_session: AdbcDriver) -> None:
"""GizmoSQL should expose DuckDB table and column metadata through the ADBC dictionary."""
Expand Down Expand Up @@ -51,6 +66,26 @@ def test_gizmosql_data_dictionary_tables_columns_and_indexes(adbc_gizmosql_sessi
assert schema_rows
schema_name = schema_rows[0]["table_schema"]

raw_objects = (
adbc_gizmosql_session.connection
.adbc_get_objects(depth="all", db_schema_filter=schema_name, table_name_filter="gizmosql_dd_child_adbc")
.read_all()
.to_pylist()
)
assert isinstance(raw_objects, list)
raw_child = _find_get_objects_table(raw_objects, "gizmosql_dd_child_adbc")
assert raw_child is not None
assert {column["column_name"] for column in raw_child.get("table_columns") or []} == {
"id",
"parent_id",
"amount",
"created_at",
}
constraints = raw_child.get("table_constraints") or []
if not constraints:
pytest.xfail("GizmoSQL FlightSQL GetObjects did not return constraints; SQLSpec must use central fallback")
assert any(str(constraint.get("constraint_type")).upper() == "FOREIGN KEY" for constraint in constraints)

table_names = {table["table_name"] for table in dictionary.get_tables(adbc_gizmosql_session, schema=schema_name)}
assert {"gizmosql_dd_parent_adbc", "gizmosql_dd_child_adbc"}.issubset(table_names)

Expand Down
Loading