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

Fix incorrect results when ascii-control characters are used as Quote and Escape #533

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

y-wei
Copy link

@y-wei y-wei commented Feb 29, 2024

As titled, without this fix incorrect results are created:

final Reader csv = new StringReader("\u00127\u0012," +
				"\u0012EmbeddedDouble\u0012," +
				"\u0012field\u0012\u0012 t\u0012\u0012ext\u0012," +
				"\u0012field\u0012\u0012 t\u0012\u0012ext\u0012");
final CsvParserSettings settings = new CsvParserSettings();
settings.getFormat().setQuote('\u0012');
settings.getFormat().setQuoteEscape('\u0012');
settings.setUnescapedQuoteHandling(UnescapedQuoteHandling.STOP_AT_CLOSING_QUOTE);
final CsvParser csvParser = new CsvParser(settings);
final String[] row = csvParser.parseAll(csv).get(0);
// row: ["7", "EmbeddedDouble", "field\u0012\u0012 t\u0012\u0012ext", "field\u0012\u0012 t\u0012\u0012ext"]
// expect ["7", "EmbeddedDouble", "field\u0012 t\u0012ext", "field\u0012 t\u0012ext"]

while it should be the one in the added unit test.

MaxGekk pushed a commit to apache/spark that referenced this pull request Feb 29, 2024
### What changes were proposed in this pull request?

This PR proposes to change signature `CsvParser` to `AbstractParser` (its parent class).

### Why are the changes needed?

- It's better to use higher classes if they fit for better extendibility and maintenance.
- Univocity parser became inactive for the last three years, and we're missing bug fixes such as uniVocity/univocity-parsers#533. We should probably leverage their interface, and implement it in Spark for bug fixes and further performance improvement. This is a basework.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Existing test cases should cover.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #45328 from HyukjinKwon/SPARK-47221.

Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
TakawaAkirayo pushed a commit to TakawaAkirayo/spark that referenced this pull request Mar 4, 2024
### What changes were proposed in this pull request?

This PR proposes to change signature `CsvParser` to `AbstractParser` (its parent class).

### Why are the changes needed?

- It's better to use higher classes if they fit for better extendibility and maintenance.
- Univocity parser became inactive for the last three years, and we're missing bug fixes such as uniVocity/univocity-parsers#533. We should probably leverage their interface, and implement it in Spark for bug fixes and further performance improvement. This is a basework.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Existing test cases should cover.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#45328 from HyukjinKwon/SPARK-47221.

Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
ericm-db pushed a commit to ericm-db/spark that referenced this pull request Mar 5, 2024
### What changes were proposed in this pull request?

This PR proposes to change signature `CsvParser` to `AbstractParser` (its parent class).

### Why are the changes needed?

- It's better to use higher classes if they fit for better extendibility and maintenance.
- Univocity parser became inactive for the last three years, and we're missing bug fixes such as uniVocity/univocity-parsers#533. We should probably leverage their interface, and implement it in Spark for bug fixes and further performance improvement. This is a basework.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Existing test cases should cover.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#45328 from HyukjinKwon/SPARK-47221.

Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
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.

1 participant