diff --git a/Cargo.lock b/Cargo.lock index a92b67ef66..b869f3b195 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -329,7 +329,7 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "polyglot-sql" version = "0.13.8" -source = "git+https://github.com/chio-labs/polyglot.git?rev=a7413439c520d7949924149b7ea02fa3817463fc#a7413439c520d7949924149b7ea02fa3817463fc" +source = "git+https://github.com/chio-labs/polyglot.git?rev=9ff0af282829d92efeeb36b6a820be2271e1da49#9ff0af282829d92efeeb36b6a820be2271e1da49" dependencies = [ "polyglot-sql-ast-derive", "polyglot-sql-function-catalogs", @@ -344,7 +344,7 @@ dependencies = [ [[package]] name = "polyglot-sql-ast-derive" version = "0.13.8" -source = "git+https://github.com/chio-labs/polyglot.git?rev=a7413439c520d7949924149b7ea02fa3817463fc#a7413439c520d7949924149b7ea02fa3817463fc" +source = "git+https://github.com/chio-labs/polyglot.git?rev=9ff0af282829d92efeeb36b6a820be2271e1da49#9ff0af282829d92efeeb36b6a820be2271e1da49" dependencies = [ "proc-macro2", "quote", @@ -354,7 +354,7 @@ dependencies = [ [[package]] name = "polyglot-sql-function-catalogs" version = "0.13.8" -source = "git+https://github.com/chio-labs/polyglot.git?rev=a7413439c520d7949924149b7ea02fa3817463fc#a7413439c520d7949924149b7ea02fa3817463fc" +source = "git+https://github.com/chio-labs/polyglot.git?rev=9ff0af282829d92efeeb36b6a820be2271e1da49#9ff0af282829d92efeeb36b6a820be2271e1da49" [[package]] name = "portable-atomic" diff --git a/Cargo.toml b/Cargo.toml index 75ba4276c9..5dc0f8aca9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", @@ -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" diff --git a/tests/e2e/src/sqlbuild/cli/commands/main/compile/_test_types.py b/tests/e2e/src/sqlbuild/cli/commands/main/compile/_test_types.py index d6166840c1..3208cd0112 100644 --- a/tests/e2e/src/sqlbuild/cli/commands/main/compile/_test_types.py +++ b/tests/e2e/src/sqlbuild/cli/commands/main/compile/_test_types.py @@ -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) diff --git a/tests/e2e/src/sqlbuild/cli/commands/main/compile/helpers.py b/tests/e2e/src/sqlbuild/cli/commands/main/compile/helpers.py index 40ad9bd6cd..e203868234 100644 --- a/tests/e2e/src/sqlbuild/cli/commands/main/compile/helpers.py +++ b/tests/e2e/src/sqlbuild/cli/commands/main/compile/helpers.py @@ -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": ( @@ -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 diff --git a/tests/e2e/src/sqlbuild/cli/commands/main/compile/test_compile_performance.py b/tests/e2e/src/sqlbuild/cli/commands/main/compile/test_compile_performance.py index e74c6cfcee..81e5782b98 100644 --- a/tests/e2e/src/sqlbuild/cli/commands/main/compile/test_compile_performance.py +++ b/tests/e2e/src/sqlbuild/cli/commands/main/compile/test_compile_performance.py @@ -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, ) @@ -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