Replaces the BigQuery wrap-view pattern with a discovery + scoped-fetch toolkit driven by the analyst's Claude session. Adds /api/v2/{catalog,schema,sample,scan,scan/estimate}, da catalog/schema/describe/fetch/snapshot/disk-info CLI commands, sqlglot-backed WHERE validator, process-local quota tracker, agent rails skill (cli/skills/agnes-data-querying.md). BREAKING: BQ wrap views off by default — set data_source.bigquery.legacy_wrap_views=true for one cycle. Backward-compat field_validator on primary_key. Catalog cache now matches documented 300s TTL with RBAC fresh per request. Cuts release v0.14.0.
29 lines
888 B
Python
29 lines
888 B
Python
import io
|
|
import pyarrow as pa
|
|
import pytest
|
|
|
|
from app.api.v2_arrow import arrow_table_to_ipc_bytes, parse_ipc_bytes
|
|
|
|
|
|
def test_round_trip_simple_table():
|
|
src = pa.table({"a": [1, 2, 3], "b": ["x", "y", "z"]})
|
|
body = arrow_table_to_ipc_bytes(src)
|
|
assert isinstance(body, bytes) and len(body) > 0
|
|
got = parse_ipc_bytes(body)
|
|
assert got.equals(src)
|
|
|
|
|
|
def test_empty_table_round_trip():
|
|
src = pa.table({"a": pa.array([], type=pa.int64())})
|
|
body = arrow_table_to_ipc_bytes(src)
|
|
got = parse_ipc_bytes(body)
|
|
assert got.num_rows == 0
|
|
assert got.schema.equals(src.schema)
|
|
|
|
|
|
def test_round_trip_record_batch_reader():
|
|
src = pa.table({"a": [1, 2, 3], "b": ["x", "y", "z"]})
|
|
reader = pa.RecordBatchReader.from_batches(src.schema, src.to_batches())
|
|
body = arrow_table_to_ipc_bytes(reader)
|
|
got = parse_ipc_bytes(body)
|
|
assert got.equals(src)
|