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 quote and escape attributes to create csv external table #8351

Merged
merged 27 commits into from
Nov 29, 2023

Conversation

Asura7969
Copy link
Contributor

@Asura7969 Asura7969 commented Nov 29, 2023

Which issue does this PR close?

Closes #8310.

Rationale for this change

Create csv table in sql mode, support quote & escape

What changes are included in this PR?

Add quote and escape attributes to create csv external table

CREATE EXTERNAL TABLE custom(
    c1  VARCHAR DEFAULT NULL,
    c2  VARCHAR DEFAULT NULL
)
STORED AS CSV
DELIMITER ','
WITH HEADER ROW
OPTIONS ('escape' '\', 'quote' '~')
LOCATION 'custom.csv';

Are these changes tested?

yes, csv_files.slt

Are there any user-facing changes?

Add quote & escape attributes to OPTIONS.

@github-actions github-actions bot added core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Nov 29, 2023
WITH HEADER ROW
DELIMITER ','
OPTIONS ('escape' '\"')
LOCATION '../core/tests/data/escape.csv';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To CREATE EXTERNAL TABLE syntax coverage, I add this file

@Asura7969 Asura7969 changed the title Extend csv sql Add quote & escape for create external table Nov 29, 2023
@Asura7969 Asura7969 changed the title Add quote & escape for create external table Add quote and escape attributes to create csv external table Nov 29, 2023
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Asura7969 -- this looks great. I had a suggestion related to settings and it would be nice to add a reference to the comments, but I also think we could merge this PR as is and do them as a follow on.

Let me know what you would like to do.

Thanks again!

datafusion/core/src/datasource/listing_table_factory.rs Outdated Show resolved Hide resolved
@Asura7969
Copy link
Contributor Author

Thank you @Asura7969 -- this looks great. I had a suggestion related to settings and it would be nice to add a reference to the comments, but I also think we could merge this PR as is and do them as a follow on.

Let me know what you would like to do.

Thanks again!

I will follow your suggestions

@alamb
Copy link
Contributor

alamb commented Nov 29, 2023

Thank you @Asura7969 !

@alamb alamb merged commit aeb012e into apache:main Nov 29, 2023
22 checks passed
@Asura7969 Asura7969 deleted the extend_csv_sql branch November 30, 2023 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add quote & escape for create external table
2 participants