Skip to content

Commit

Permalink
fix: Infer and scan BSON files from file path (#2410)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrongmeal authored Jan 14, 2024
1 parent 4590005 commit c2131a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit c2131a3

Please sign in to comment.