Skip to content

Add quote and escape attributes to create csv external table - #8351

Merged
alamb merged 27 commits into
apache:mainfrom
Asura7969:extend_csv_sql
Nov 29, 2023
Merged

Add quote and escape attributes to create csv external table#8351
alamb merged 27 commits into
apache:mainfrom
Asura7969:extend_csv_sql

Conversation

@Asura7969

@Asura7969Asura7969 commented Nov 29, 2023

Copy link
Copy Markdown
Contributor

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-actionsgithub-actionsBot 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
Copy Markdown
ContributorAuthor

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

@Asura7969Asura7969 changed the title Extend csv sqlAdd quote & escape for create external tableNov 29, 2023
@Asura7969Asura7969 changed the title Add quote & escape for create external tableAdd quote and escape attributes to create csv external tableNov 29, 2023
Comment threaddatafusion/common/src/file_options/csv_writer.rs

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

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!

Comment threaddatafusion/core/src/datasource/listing_table_factory.rs Outdated
@Asura7969

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
Contributor

Thank you @Asura7969 !

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coreCore DataFusion cratesqllogictestSQL 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

@Asura7969@alamb