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

SQL: Add option to provide the delimiter for the CSV format #59907

Merged
merged 9 commits into from
Jul 29, 2020

Conversation

bpintea
Copy link
Contributor

@bpintea bpintea commented Jul 20, 2020

This PR adds the option to provide the desired character as the separator
for the CSV format (the default remains comma).
A set of characters are excluded though - like CR, LF, " - to avoid
slipping onto the CSV-dialects slope. The tab is also forbidden, the
user needs to choose the tsv format explicitely.

Closes #41634.

This adds the option to provide the desired character as the separator
for the CSV format (the default remains comma).
A set of characters are excluded though - like CR, LF, `"` - to avoid
slipping onto the CSV-dialects slope. The tab is also forbidden, the
user needs to choose the "tsv" format explicitely.

The TSV format also gets a needed supplemental escaping, that of the '\'
character.
@bpintea
Copy link
Contributor Author

bpintea commented Jul 20, 2020

@elasticmachine run elasticsearch-ci/2

@bpintea bpintea marked this pull request as ready for review July 20, 2020 17:43
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (:Query Languages/SQL)

@elasticmachine elasticmachine added the Team:QL (Deprecated) Meta label for query languages team label Jul 20, 2020
@bpintea bpintea requested review from matriv and astefan July 20, 2020 17:44
Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

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

Looks good, left a few comments, but additionally should something be adjusted in docs?

Fix the way the delimiter is being passed around, removing the CSV
member - since its instantiation is a singleton - and pushing it through
function arguments.

The commit fixes a few issues with the "header" URL attribute:
- these was no longer usable, since it wasn't "consumed" by
RestSqlQueryAction before generating the answer (triggering an error
responce on use);
- its value was only checked against "absent", so an incorrect value
(typo like "abaent") could have silently generated an unexpected reply.
- missing

Documentation for the "delimiter" attribute has also been added.
@bpintea
Copy link
Contributor Author

bpintea commented Jul 22, 2020

should something be adjusted in docs?

Of course, missed that, thanks for pointing it out.

@bpintea bpintea added v7.10.0 and removed v7.9.1 labels Jul 22, 2020
Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

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

LGTM. Left a few more minor comments.

The commit unescapes the deliter param. This is required for the
doc-sourced tests.

Also, implement a switch for param value validation and fix docs.
@bpintea
Copy link
Contributor Author

bpintea commented Jul 23, 2020

@elasticmachine update branch

Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

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

LGTM, Thx!
Left one more minor comment in docs.

Co-authored-by: Marios Trivyzas <matriv@gmail.com>
Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM in general, but I have doubts about adding the header request parameter.

- rip out anything which isn't Delimiter-related.
- undo 'hasHeader' method renaming.
@bpintea
Copy link
Contributor Author

bpintea commented Jul 28, 2020

@elasticmachine update branch

elasticmachine and others added 2 commits July 28, 2020 03:34
Update the doc to make it clear that the textual CSV, TSV and TXT
formats pass the cursor back to the user through the Cursor HTTP header.
@bpintea
Copy link
Contributor Author

bpintea commented Jul 29, 2020

@elasticmachine update branch

1 similar comment
@bpintea
Copy link
Contributor Author

bpintea commented Jul 29, 2020

@elasticmachine update branch

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM

@bpintea bpintea merged commit 3a8b00c into elastic:master Jul 29, 2020
@bpintea bpintea deleted the enh/csv_delimiter branch July 29, 2020 14:08
bpintea added a commit to bpintea/elasticsearch that referenced this pull request Jul 29, 2020
…59907)

* Add option to provide the delimiter to the CSV fmt

This adds the option to provide the desired character as the separator
for the CSV format (the default remains comma).
A set of characters are excluded though - like CR, LF, `"` - to avoid
slipping onto the CSV-dialects slope. The tab is also forbidden, the
user needs to choose the "tsv" format explicitely.

Update the doc to make it clear that the textual CSV, TSV and TXT
formats pass the cursor back to the user through the Cursor HTTP header.

(cherry picked from commit 3a8b00c)
bpintea added a commit that referenced this pull request Jul 29, 2020
…60420)

* SQL: Add option to provide the delimiter for the CSV format (#59907)

* Add option to provide the delimiter to the CSV fmt

This adds the option to provide the desired character as the separator
for the CSV format (the default remains comma).
A set of characters are excluded though - like CR, LF, `"` - to avoid
slipping onto the CSV-dialects slope. The tab is also forbidden, the
user needs to choose the "tsv" format explicitely.

Update the doc to make it clear that the textual CSV, TSV and TXT
formats pass the cursor back to the user through the Cursor HTTP header.

(cherry picked from commit 3a8b00c)

* Java8 fixes

- replace Set#of();
- URLDecoder#decode() requires a string (vs a charset) as 2nd arg.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL: Add CSV Separator option
5 participants