From cd5ff39facc7f45602e9a63d0f2d46bddfd3727a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20M=C3=BCller?= Date: Mon, 16 Dec 2024 09:33:44 +0100 Subject: [PATCH] feat: do TPC-H plan validation for DuckDB with `Producer` (#169) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR reuses the plan validation that is part of the `Producer` interface in the tests that check plan validity for the TPC-H queries for DuckDB. This leads to the same result in terms of validity; however, the error class is different in the one error case, so the outcome changes from one error to another for that query. Signed-off-by: Ingo Müller --- .../test_tpch_sql_18_outcome.txt | 2 +- .../tests/integration/test_tpch_plans_valid.py | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/substrait_consumer/tests/integration/snapshots/test_tpch_plans_valid/test_duckdb_substrait_plans_valid/test_tpch_sql_18/test_tpch_sql_18_outcome.txt b/substrait_consumer/tests/integration/snapshots/test_tpch_plans_valid/test_duckdb_substrait_plans_valid/test_tpch_sql_18/test_tpch_sql_18_outcome.txt index 9145b9be..2ee6126c 100644 --- a/substrait_consumer/tests/integration/snapshots/test_tpch_plans_valid/test_duckdb_substrait_plans_valid/test_tpch_sql_18/test_tpch_sql_18_outcome.txt +++ b/substrait_consumer/tests/integration/snapshots/test_tpch_plans_valid/test_duckdb_substrait_plans_valid/test_tpch_sql_18/test_tpch_sql_18_outcome.txt @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/substrait_consumer/tests/integration/test_tpch_plans_valid.py b/substrait_consumer/tests/integration/test_tpch_plans_valid.py index 15f9f2f0..a79fd6f9 100644 --- a/substrait_consumer/tests/integration/test_tpch_plans_valid.py +++ b/substrait_consumer/tests/integration/test_tpch_plans_valid.py @@ -2,7 +2,6 @@ import duckdb import pytest -import substrait_validator as sv from pytest_snapshot.plugin import Snapshot @@ -116,25 +115,12 @@ def test_duckdb_substrait_plans_valid( sql_query: SQL query. """ - config = sv.Config() - - # Duckdb plan overrides - # not yet implemented: typecast validation rules are not yet implemented - config.override_diagnostic_level(1, "info", "info") - # function definition unavailable: cannot check validity of call - config.override_diagnostic_level(6003, "info", "info") - # Function Anchor to YAML file - config.override_diagnostic_level(3001, "info", "info") - # too few field names - config.override_diagnostic_level(4003, "info", "info") # Format the sql query by inserting all the table names self.duckdb_producer.setup(self.db_connection, local_files, named_tables) try: - proto_bytes = self.duckdb_producer.produce_substrait(sql_query) - # TODO: failures in the validator obstruct an otherwise passing test! - sv.check_plan_valid(proto_bytes, config) + self.duckdb_producer.produce_substrait(sql_query, validate=True) except BaseException as e: snapshot.assert_match(str(type(e)), f"{test_name}_outcome.txt") return