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: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ globset = "0.4"
mimalloc = { version = "0.1", default-features = false, features = ["local_dynamic_tls"] }
proc-macro2 = { version = "1", features = ["span-locations"] }
pyo3 = { version = "0.26", features = ["abi3-py312"] }
polyglot-sql = { git = "https://github.com/chio-labs/polyglot.git", rev = "a7413439c520d7949924149b7ea02fa3817463fc", default-features = false, features = [
polyglot-sql = { git = "https://github.com/chio-labs/polyglot.git", rev = "9ff0af282829d92efeeb36b6a820be2271e1da49", default-features = false, features = [
"ast-tools",
"builder",
"dialect-bigquery",
Expand All @@ -29,7 +29,7 @@ polyglot-sql = { git = "https://github.com/chio-labs/polyglot.git", rev = "a7413
"semantic",
"stacker",
] }
polyglot-sql-function-catalogs = { git = "https://github.com/chio-labs/polyglot.git", rev = "a7413439c520d7949924149b7ea02fa3817463fc", default-features = false, features = [
polyglot-sql-function-catalogs = { git = "https://github.com/chio-labs/polyglot.git", rev = "9ff0af282829d92efeeb36b6a820be2271e1da49", default-features = false, features = [
"dialect-duckdb",
] }
quote = "1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ class UnionFixtureCompileScalingTestCase:
expected_sql_tests: int
expected_errors: int
expected_max_scaling_ratio: float
input_fixture_row_separator: str = " UNION ALL\n"


@dataclass(frozen=True)
Expand Down
28 changes: 20 additions & 8 deletions tests/e2e/src/sqlbuild/cli/commands/main/compile/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2771,17 +2771,25 @@ class UnionFixtureCompileMeasurement(NamedTuple):
errors: int


def _union_all_fixture_rows(*, row_count: int, status: str) -> str:
return " UNION ALL\n".join(
def _union_all_fixture_rows(*, row_count: int, status: str, separator: str) -> str:
return separator.join(
f" SELECT {row} AS order_id, CAST({row} AS DOUBLE) AS amount, '{status}' AS status"
for row in range(row_count)
)


def write_union_fixture_test_project(
*, project_dir: Path, sql_test_count: int, fixture_row_count: int
*,
project_dir: Path,
sql_test_count: int,
fixture_row_count: int,
input_fixture_row_separator: str,
) -> None:
"""Write a DuckDB project whose SQL tests use long UNION ALL fixture chains."""
"""Write a DuckDB project whose SQL tests use long UNION ALL fixture chains.

`input_fixture_row_separator` joins the rows of the mocked input fixture; the
expected fixture always uses plain `UNION ALL`.
"""

files: dict[str, str] = {
"sqlbuild_project.toml": (
Expand All @@ -2798,13 +2806,17 @@ def write_union_fixture_test_project(
),
}
for index in range(sql_test_count):
fixture_rows: str = _union_all_fixture_rows(
row_count=fixture_row_count, status=f"status_{index:02d}"
status: str = f"status_{index:02d}"
input_rows: str = _union_all_fixture_rows(
row_count=fixture_row_count, status=status, separator=input_fixture_row_separator
)
expected_rows: str = _union_all_fixture_rows(
row_count=fixture_row_count, status=status, separator=" UNION ALL\n"
)
files[f"tests/unit/orders_case_{index:02d}.sql"] = (
f'TEST (name "orders_case_{index:02d}");\n\n'
f"WITH\n__ref__base_orders AS (\n{fixture_rows}\n),\n"
f"__expected__orders AS (\n{fixture_rows}\n)\nSELECT 1\n"
f"WITH\n__ref__base_orders AS (\n{input_rows}\n),\n"
f"__expected__orders AS (\n{expected_rows}\n)\nSELECT 1\n"
)
prepare_inline_project(
tmp_path=project_dir.parent, project_name=project_dir.name, repo_files=files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,18 @@ def test_given_wide_scan_heavy_projects_when_doubling_sql_size_then_compile_scal
expected_sql_tests=4,
expected_errors=0,
expected_max_scaling_ratio=6.0,
)
),
UnionFixtureCompileScalingTestCase(
description="quadrupling commented UNION ALL input fixture rows keeps SQL test analysis linear",
sql_test_count=4,
small_fixture_rows=50,
large_fixture_rows=200,
measured_runs=3,
expected_sql_tests=4,
expected_errors=0,
expected_max_scaling_ratio=6.0,
input_fixture_row_separator="\n -- fixture row\n UNION ALL\n",
),
],
ids=lambda case: case.description,
)
Expand All @@ -154,11 +165,13 @@ def test_given_sql_tests_with_union_all_fixtures_when_quadrupling_rows_then_anal
project_dir=small_project_dir,
sql_test_count=test_case.sql_test_count,
fixture_row_count=test_case.small_fixture_rows,
input_fixture_row_separator=test_case.input_fixture_row_separator,
)
write_union_fixture_test_project(
project_dir=large_project_dir,
sql_test_count=test_case.sql_test_count,
fixture_row_count=test_case.large_fixture_rows,
input_fixture_row_separator=test_case.input_fixture_row_separator,
)
small: UnionFixtureCompileMeasurement = measure_union_fixture_compile(
project_dir=small_project_dir, runs=test_case.measured_runs
Expand Down
Loading