Skip to content

Commit cfb9450

Browse files
rustyconoverclaude
andcommitted
tests: route reference workers' to_arrow_table through arrow_table()
DuckDB 2.0 types to_arrow_table() as optional; the mypy tests/ gate in CI's Lint job caught four files the vgi/ pass did not cover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent bd6b987 commit cfb9450

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎tests/catalog/column_paths_reference.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import pyarrow as pa
2525
import pyarrow.compute as pc
2626

27+
from vgi._duckdb import arrow_table
2728
from vgi.catalog import TableInfo
2829
from vgi.catalog.capabilities import (
2930
COLUMN_NESTED_ADD,
@@ -106,7 +107,7 @@ def _eval(
106107
role="using" if schema is not None else "default",
107108
)
108109
query = f"SELECT ({expression.sql}) AS v" + (" FROM input_data" if schema is not None else "")
109-
return connection.execute(query).to_arrow_table().column(0).combine_chunks()
110+
return arrow_table(connection.execute(query)).column(0).combine_chunks()
110111

111112

112113
def _fields(fields: Any, path: list[str]) -> None:

‎tests/catalog/expression_reference.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import duckdb
1616
import pyarrow as pa
1717

18+
from vgi._duckdb import arrow_table
1819
from vgi.catalog._expression_grammar import _cast_type_id, _constant_type_id, _function_arguments, _has_named_argument
1920
from vgi.catalog.capabilities import ROW_SCALAR_EXPRESSION
2021
from vgi.catalog.evaluation_context import QueryEvaluationContext
@@ -150,7 +151,7 @@ def evaluate_expression(
150151
connection.execute("SET preserve_insertion_order=true")
151152
connection.register("input_data", table)
152153
validate_expression(connection, expr, owner_path, role=role)
153-
result = connection.execute(f"SELECT ({expr.sql}) AS v FROM input_data").to_arrow_table().column(0)
154+
result = arrow_table(connection.execute(f"SELECT ({expr.sql}) AS v FROM input_data")).column(0)
154155
if not _primitive(result.type) or (role == "check" and not pa.types.is_boolean(result.type)):
155156
raise ValueError("expression result has an unsupported type for its role")
156157
return result

‎tests/catalog/table_layout_reference.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import duckdb
2222
import pyarrow as pa
2323

24+
from vgi._duckdb import arrow_table
2425
from vgi.catalog import SchemaInfo, TableInfo
2526
from vgi.catalog.capabilities import (
2627
ROW_SCALAR_EXPRESSION,
@@ -83,9 +84,9 @@ def arrange_rows(rows: list[dict[str, Any]], info: TableInfo) -> list[dict[str,
8384
_validate_expression(connection, expr, info.schema_path)
8485
select = "*" + "".join(f", ({expr.sql}) AS __vgi_partition_{i}" for i, expr in enumerate(partitions))
8586
order = ", ".join(f"({key.expression.sql}) {key.direction.value} NULLS {key.null_order.value}" for key in sorts)
86-
result = connection.execute(
87-
f"SELECT {select} FROM input_data" + (f" ORDER BY {order}" if order else "")
88-
).to_arrow_table()
87+
result = arrow_table(
88+
connection.execute(f"SELECT {select} FROM input_data" + (f" ORDER BY {order}" if order else ""))
89+
)
8990
groups: dict[str, dict[str, Any]] = {}
9091
for row in range(len(result)):
9192
key = [result.column(len(columns) + i)[row].as_py() for i in range(len(partitions))]

‎tests/catalog/test_column_statistics.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import pytest
1010
from vgi_rpc.utils import deserialize_record_batch
1111

12+
from vgi._duckdb import arrow_table
1213
from vgi.catalog.catalog_interface import (
1314
ColumnStatistics,
1415
TableColumnStatisticsResult,
@@ -736,7 +737,7 @@ def test_resolves_for_table_descriptor(self) -> None:
736737
conn.execute("CREATE TABLE t AS SELECT unnest(range(10)) AS val")
737738

738739
stats = statistics_from_duckdb(conn, "t")
739-
schema: pa.Schema = conn.execute("SELECT * FROM t LIMIT 0").to_arrow_table().schema
740+
schema: pa.Schema = arrow_table(conn.execute("SELECT * FROM t LIMIT 0")).schema
740741

741742
table = Table(name="t", columns=schema, statistics=stats)
742743
result = table.resolve_column_statistics()

0 commit comments

Comments
 (0)