Skip to content

Commit

Permalink
feat: do TPC-H plan validation for DuckDB with Producer (#169)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ingomueller-net authored Dec 16, 2024
1 parent 888adc7 commit cd5ff39
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<class 'google.protobuf.json_format.ParseError'>
<class 'ValueError'>
16 changes: 1 addition & 15 deletions substrait_consumer/tests/integration/test_tpch_plans_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import duckdb
import pytest
import substrait_validator as sv

from pytest_snapshot.plugin import Snapshot

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cd5ff39

Please sign in to comment.