Skip to content

Commit 3c800a5

Browse files
committed
test: match kernel table-type filters by exact case
Align Kernel E2E with case-sensitive filtering from databricks-sql-kernel#393. Check uppercase matches and lowercase/mixed-case empty results, and update stale filter comments. Signed-off-by: Cathleen Yan <58714163+cathleeny@users.noreply.github.com>
1 parent dd8a639 commit 3c800a5

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

‎src/databricks/sql/backend/kernel/client.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,11 +1045,9 @@ def get_tables(
10451045
if self._kernel_session is None:
10461046
raise InterfaceError("get_tables requires an open session.")
10471047
try:
1048-
# ``table_types`` is filtered kernel-side (the kernel applies
1049-
# it to the reshaped result, case-insensitively as of the
1050-
# batch-3 kernel change), so we forward it and let the kernel
1051-
# do the work — no connector-side drain + refilter. Passing it
1052-
# through preserves streaming for large schemas.
1048+
# The kernel filters ``table_types`` with case-sensitive
1049+
# matching for Thrift parity. Forward the values unchanged
1050+
# to preserve those semantics and streaming for large schemas.
10531051
stream = self._kernel_session.metadata().list_tables(
10541052
catalog=escape_metadata_catalog_name(
10551053
_catalog_or_none(catalog_name), self._escape_catalog_name

‎tests/e2e/test_kernel_backend.py‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,12 @@ def test_columns_with_empty_string_filter_matches_nothing(conn, empty_filter):
383383
assert cur.fetchall() == []
384384

385385

386-
def test_tables_table_types_filter_is_case_insensitive(conn):
387-
"""Lowercase ``table_types=['view']`` / uppercase ``['TABLE']``
388-
each match the right object regardless of case — locks the
389-
kernel-side case-insensitive ``table_types`` match (batch-3 kernel
390-
B2) end-to-end plus the connector drain removal (the filter now
391-
runs kernel-side, not client-side).
386+
def test_tables_table_types_filter_is_case_sensitive(conn):
387+
"""Table types match exact case, consistent with Thrift.
388+
389+
Uppercase ``['VIEW']`` / ``['TABLE']`` match the corresponding
390+
object; lowercase and mixed-case values match no objects. The
391+
kernel applies the filter to values forwarded by the connector.
392392
393393
Self-contained: creates a table + a view over it in the session's
394394
default (writable) schema, scopes the lookup to a unique name
@@ -411,12 +411,12 @@ def _names_and_types():
411411
ni, ti = cols.index("TABLE_NAME"), cols.index("TABLE_TYPE")
412412
return {(r[ni], r[ti]) for r in rows}
413413

414-
# Lowercase 'view' must match the VIEW (and only it).
414+
# Uppercase 'VIEW' must match the VIEW (and only it).
415415
cur.tables(
416416
catalog_name=cat,
417417
schema_name=sch,
418418
table_name=name_pat,
419-
table_types=["view"],
419+
table_types=["VIEW"],
420420
)
421421
assert _names_and_types() == {(vw, "VIEW")}
422422

@@ -428,6 +428,16 @@ def _names_and_types():
428428
table_types=["TABLE"],
429429
)
430430
assert _names_and_types() == {(tbl, "TABLE")}
431+
432+
# Lowercase and mixed-case requests must not match either type.
433+
for table_type in ("view", "View", "table", "Table"):
434+
cur.tables(
435+
catalog_name=cat,
436+
schema_name=sch,
437+
table_name=name_pat,
438+
table_types=[table_type],
439+
)
440+
assert _names_and_types() == set(), table_type
431441
finally:
432442
cur.execute(f"DROP VIEW IF EXISTS {vw}")
433443
cur.execute(f"DROP TABLE IF EXISTS {tbl}")

‎tests/unit/test_kernel_client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ def _make_tables_stream() -> MagicMock:
16261626

16271627
def test_get_tables_forwards_table_types_to_kernel():
16281628
"""``table_types`` is forwarded verbatim to the kernel's
1629-
``list_tables`` (which filters case-insensitively) — the
1629+
``list_tables`` (which filters case-sensitively) — the
16301630
connector no longer drains + refilters client-side. The stream
16311631
flows back through the normal ``KernelResultSet`` path unchanged."""
16321632
c = _make_client()

0 commit comments

Comments
 (0)