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

[feature] add stream load config to add double quotes for field when csv format. #119

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

CodeCooker17
Copy link
Contributor

…csv format.

Proposed changes

Issue Number: close #xxx

Problem Summary:

Describe the overview of changes.
add config "add_double_quotes" Add double quotes to filed before streamload, combined with "trim_double_quotes" to prevent CsvReader from failing to split data when the last character of the field data is the same as the first character of the field separator

image

Checklist(Required)

  1. Does it affect the original behavior: (Yes/No/I Don't know)
  2. Has unit tests been added: (Yes/No/No Need)
  3. Has document been added or modified: (Yes/No/No Need)
  4. Does it need to update dependencies: (Yes/No)
  5. Are there any changes that cannot be rolled back: (Yes/No)

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

FIELD_DELIMITER = EscapeHandler.escapeString(streamLoadProp.getOrDefault("column_separator", "\t"));
this.trimDoubleQuotes = Boolean.parseBoolean(streamLoadProp.getOrDefault("trim_double_quotes", "false"));
Copy link
Member

Choose a reason for hiding this comment

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

see #121

@JNSimba
Copy link
Member

JNSimba commented Aug 29, 2023

Thank you for your contribution, this error means that the delimiter is -->, and then ---> is not recognized?

@CodeCooker17
Copy link
Contributor Author

Thank you for your contribution, this error means that the delimiter is -->, and then ---> is not recognized?

yes,the problem occurs in the delimited implementation of CSVReader.

row.stream().map(field -> field == null ? NULL_VALUE : field.toString())
.collect(Collectors.joining(FIELD_DELIMITER))
).collect(Collectors.joining(LINE_DELIMITER));
if (addDoubleQuotes && trimDoubleQuotes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this feature only works if both add_double_quotes and trim_double_quotes are set to true. So is it necessary to enforce setting trim_double_quotes to true when add_double_quotes is true?

@CodeCooker17 CodeCooker17 force-pushed the add_double_quotes branch 2 times, most recently from df64983 to 5a2a72e Compare September 13, 2023 09:00
Copy link
Contributor

@gnehil gnehil left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@JNSimba JNSimba left a comment

Choose a reason for hiding this comment

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

LGTM

@JNSimba JNSimba merged commit 32ec6c0 into apache:master Sep 14, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants