Skip to content
Open
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 examples/duckdb_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# /// script
# dependencies = [
# "pyarrow==20.0.0",
# "duckdb==1.2.1",
# "duckdb==1.5.6",
# "substrait[extensions] @ file:///${PROJECT_ROOT}/"
# ]
# ///
Expand All @@ -18,7 +18,7 @@

try:
duckdb.install_extension("substrait")
except duckdb.duckdb.HTTPException:
except duckdb.HTTPException:
Comment thread
tokoko marked this conversation as resolved.
Resolved
duckdb.install_extension("substrait", repository="community")
duckdb.load_extension("substrait")

Expand All @@ -31,7 +31,7 @@


def read_duckdb_named_table(name: str, conn):
pa_schema = conn.sql(f"SELECT * FROM {name} LIMIT 0").arrow().schema
pa_schema = conn.sql(f"SELECT * FROM {name} LIMIT 0").to_arrow_table().schema
substrait_schema = (
pa_substrait.serialize_schema(pa_schema).to_pysubstrait().base_schema
)
Expand Down
65 changes: 65 additions & 0 deletions pixi.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extensions = ["substrait-antlr==0.106.0", "pyyaml"]
sql = ["sqloxide", "deepdiff"]

[dependency-groups]
dev = ["pytest >= 7.0.0", "substrait-antlr==0.106.0", "pyyaml", "sqloxide", "deepdiff", "duckdb<=1.2.2; python_version < '3.14'", "datafusion"]
dev = ["pytest >= 7.0.0", "substrait-antlr==0.106.0", "pyyaml", "sqloxide", "deepdiff", "duckdb>=1.5,<1.6", "datafusion"]

[tool.pytest.ini_options]
pythonpath = "src"
Expand Down
16 changes: 9 additions & 7 deletions tests/integration/test_sql_engine_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ def assert_query_duckdb(query: str, ignore_order=True):
conn = duckdb.connect(db)

def duckdb_schema_resolver(name: str):
pa_schema = conn.sql(f"SELECT * FROM {name} LIMIT 0").arrow().schema
pa_schema = (
conn.sql(f"SELECT * FROM {name} LIMIT 0").to_arrow_table().schema
)
return pa_substrait.serialize_schema(pa_schema).to_pysubstrait().base_schema

conn.register("stores", data)
conn.register("sales", sales_data)
conn.from_arrow(data).create("stores")
conn.from_arrow(sales_data).create("sales")

plan = convert(query, "duckdb", duckdb_schema_resolver, registry)

Expand All @@ -115,8 +117,8 @@ def duckdb_schema_resolver(name: str):

sql_out = conn.sql(query)

substrait_arrow = substrait_out.arrow()
sql_arrow = sql_out.arrow()
substrait_arrow = substrait_out.to_arrow_table()
sql_arrow = sql_out.to_arrow_table()

if ignore_order:
substrait_arrow = sort_arrow(substrait_arrow)
Expand Down Expand Up @@ -283,12 +285,12 @@ def test_order_by(engine: str):
)


@pytest.mark.parametrize("engine", engines_duckdb_xfail)
@pytest.mark.parametrize("engine", engines)
def test_select_limit(engine: str):
assert_query("""SELECT store_id FROM stores ORDER BY store_id LIMIT 2""", engine)


@pytest.mark.parametrize("engine", engines_duckdb_xfail)
@pytest.mark.parametrize("engine", engines)
def test_select_limit_offset(engine: str):
assert_query(
"""SELECT store_id FROM stores ORDER BY store_id LIMIT 2 OFFSET 2""", engine
Expand Down
Loading
Loading