Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Infer and scan BSON files from file path #2410

Merged
merged 4 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions crates/datafusion_ext/src/planner/relation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ fn infer_func_for_file(path: &str) -> Result<OwnedTableReference> {
schema: "public".into(),
table: "ndjson_scan".into(),
},
"bson" => OwnedTableReference::Partial {
schema: "public".into(),
table: "read_bson".into(),
},
ext => {
return Err(DataFusionError::Plan(format!(
"unable to infer how to handle file extension: {ext}"
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test_bson.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_read_bson(
f"create external table bson_beatles from bson options ( location='{data_path}', file_type='bson')"
)

for from_clause in ["bson_beatles", f"read_bson('{data_path}')"]:
for from_clause in ["bson_beatles", f"read_bson('{data_path}')", f"'{data_path}'"]:
with glaredb_connection.cursor() as curr:
curr.execute(f"select count(*) from {from_clause}")
r = curr.fetchone()
Expand Down
Loading