-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from pdet/main
Fix R CI. Add Substrait-ADBC Test
- Loading branch information
Showing
8 changed files
with
175 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule duckdb
updated
1993 files
Submodule duckdb-r
updated
1527 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule substrait
updated
23 files
+4 −4 | .github/workflows/pr.yml | |
+1 −1 | .github/workflows/pr_breaking.yml | |
+1 −1 | .github/workflows/release.yml | |
+1 −1 | .github/workflows/site.yml | |
+45 −0 | CHANGELOG.md | |
+1 −0 | ci/release/dry_run.sh | |
+1 −0 | ci/release/prepare.sh | |
+1 −0 | ci/release/publish.sh | |
+1 −0 | ci/release/run.sh | |
+1 −0 | ci/release/verify.sh | |
+32 −14 | extensions/functions_arithmetic.yaml | |
+16 −0 | extensions/functions_arithmetic_decimal.yaml | |
+22 −12 | extensions/functions_comparison.yaml | |
+47 −2 | extensions/functions_datetime.yaml | |
+10 −10 | extensions/functions_logarithmic.yaml | |
+12 −1 | extensions/functions_string.yaml | |
+8 −2 | proto/substrait/algebra.proto | |
+18 −2 | proto/substrait/parameterized_types.proto | |
+20 −2 | proto/substrait/type.proto | |
+18 −2 | proto/substrait/type_expressions.proto | |
+30 −28 | site/docs/extensions/index.md | |
+1 −0 | site/docs/governance.md | |
+14 −12 | site/docs/types/type_classes.md |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
import duckdb | ||
import pytest | ||
import sys | ||
import datetime | ||
import os | ||
from os.path import abspath, join, dirname, normpath | ||
import glob | ||
|
||
|
||
adbc_driver_manager = pytest.importorskip("adbc_driver_manager.dbapi") | ||
adbc_driver_manager_lib = pytest.importorskip("adbc_driver_manager._lib") | ||
json_format = pytest.importorskip("google.protobuf.json_format") | ||
plan_pb2 = pytest.importorskip("substrait.gen.proto.plan_pb2") | ||
pyarrow = pytest.importorskip("pyarrow") | ||
|
||
# When testing local, if you build via BUILD_PYTHON=1 make, you need to manually set up the | ||
# dylib duckdb path. | ||
driver_path = duckdb.duckdb.__file__ | ||
|
||
def find_substrait(): | ||
# Paths to search for extensions | ||
build = normpath(join(dirname(__file__), "../../duckdb/build/")) | ||
extension = "extension/*/*.duckdb_extension" | ||
|
||
extension_search_patterns = [ | ||
join(build, "release", extension), | ||
join(build, "debug", extension), | ||
] | ||
|
||
# DUCKDB_PYTHON_TEST_EXTENSION_PATH can be used to add a path for the extension test to search for extensions | ||
if 'DUCKDB_PYTHON_TEST_EXTENSION_PATH' in os.environ: | ||
env_extension_path = os.getenv('DUCKDB_PYTHON_TEST_EXTENSION_PATH') | ||
env_extension_path = env_extension_path.rstrip('/') | ||
extension_search_patterns.append(env_extension_path + '/*/*.duckdb_extension') | ||
extension_search_patterns.append(env_extension_path + '/*.duckdb_extension') | ||
|
||
extension_paths_found = [] | ||
for pattern in extension_search_patterns: | ||
extension_pattern_abs = abspath(pattern) | ||
for path in glob.glob(extension_pattern_abs): | ||
extension_paths_found.append(path) | ||
|
||
for path in extension_paths_found: | ||
if path.endswith("substrait.duckdb_extension"): | ||
return path | ||
pytest.skip(f'could not load substrait') | ||
|
||
return "Fail" | ||
|
||
|
||
@pytest.fixture | ||
def duck_conn(): | ||
with adbc_driver_manager.connect(driver=driver_path, entrypoint="duckdb_adbc_init", db_kwargs={"allow_unsigned_extensions": "true"}) as conn: | ||
yield conn | ||
|
||
file_path = os.path.dirname(os.path.abspath(__file__)) | ||
file_path = os.path.join(file_path,'data','somefile.parquet') | ||
|
||
PLAN_PROTOTEXT = '''{ | ||
"relations":[ | ||
{ | ||
"root":{ | ||
"input":{ | ||
"project":{ | ||
"input":{ | ||
"read":{ | ||
"baseSchema":{ | ||
"names":[ | ||
"mbid", | ||
"artist_mb" | ||
], | ||
"struct":{ | ||
"types":[ | ||
{ | ||
"string":{ | ||
"nullability":"NULLABILITY_NULLABLE" | ||
} | ||
}, | ||
{ | ||
"string":{ | ||
"nullability":"NULLABILITY_NULLABLE" | ||
} | ||
} | ||
], | ||
"nullability":"NULLABILITY_REQUIRED" | ||
} | ||
}, | ||
"projection":{ | ||
"select":{ | ||
"structItems":[ | ||
{ | ||
}, | ||
{ | ||
"field":1 | ||
} | ||
] | ||
}, | ||
"maintainSingularStruct":true | ||
}, | ||
"localFiles":{ | ||
"items":[ | ||
{ | ||
"uriFile":"''' + file_path + '''", | ||
"parquet":{ | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"expressions":[ | ||
{ | ||
"selection":{ | ||
"directReference":{ | ||
"structField":{ | ||
} | ||
}, | ||
"rootReference":{ | ||
} | ||
} | ||
}, | ||
{ | ||
"selection":{ | ||
"directReference":{ | ||
"structField":{ | ||
"field":1 | ||
} | ||
}, | ||
"rootReference":{ | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"names":[ | ||
"mbid", | ||
"artist_mb" | ||
] | ||
} | ||
} | ||
], | ||
"version":{ | ||
"minorNumber":39, | ||
"producer":"DuckDB" | ||
} | ||
}''' | ||
|
||
def test_substrait_over_adbc(duck_conn): | ||
plan = json_format.Parse(PLAN_PROTOTEXT, plan_pb2.Plan()) | ||
cur = duck_conn.cursor() | ||
substrait_path = find_substrait() | ||
cur.execute("LOAD '"+ substrait_path + "'") | ||
|
||
plan_data = plan.SerializeToString() | ||
cur.execute(plan_data) | ||
result_table = cur.fetch_arrow_table() | ||
correct_table = pyarrow.Table.from_pydict({ | ||
'mbid': pyarrow.array(["1"], type=pyarrow.string()), | ||
'artist_mb': pyarrow.array(["Tenacious D"], type=pyarrow.string()) | ||
}) | ||
assert result_table.equals(correct_table) |