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

Add a hint about expected extension in error message in register_csv, register_parquet, register_json #14144

Open
cj-zhukov opened this issue Jan 16, 2025 · 1 comment · May be fixed by #14168
Assignees
Labels
bug Something isn't working

Comments

@cj-zhukov
Copy link
Contributor

Describe the bug

When attempting to register an existing file with different format using the register_csv, register_json, register_parquet, instead of receiving an error, the operation silently returns an empty dataframe.

To Reproduce

let file = "foo.parquet"; // foo.parquet does exist
let ctx = SessionContext::new();
ctx.register_csv("foo", file, CsvReadOptions::default()).await?; // trying to register parquet file with register_csv
// ctx.register_json("foo", file, NdJsonReadOptions::default()).await?; // or same using register_json
let res = ctx.sql("select * from foo").await?;
res.show().await?;
// Observe that no error is raised, but an empty DataFrame is returned.
// ++
// ++

Expected behavior

Introduce a validation step in register_csv, register_json, register_parquet to check the file extension or validate the file's format. If the file does not match the expected format, return a clear error message:

Error: Execution("File path 'path/to/file' does not match the expected extension '.extension'")

Additional context

No response

@cj-zhukov cj-zhukov added the bug Something isn't working label Jan 16, 2025
@cj-zhukov
Copy link
Contributor Author

take

cj-zhukov pushed a commit to cj-zhukov/datafusion that referenced this issue Jan 17, 2025
… register_parquet, register_json, register_avro (apache#14144)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant