Skip to content

Fix truncateStringMax in UnicodeUtil.#334

Closed
vgankidi wants to merge 1 commit intoapache:masterfrom
vgankidi:parquetmetricstruncate
Closed

Fix truncateStringMax in UnicodeUtil.#334
vgankidi wants to merge 1 commit intoapache:masterfrom
vgankidi:parquetmetricstruncate

Conversation

@vgankidi
Copy link
Copy Markdown
Contributor

Index to codePointAt should be the offset calculated by code points.
I incorrectly assumed that the index in codePointAt(index) refers to the index in terms of code points. It actually refers to the index of characters in the string.
resolves #328 #329

@rdblue
Copy link
Copy Markdown
Contributor

rdblue commented Jul 31, 2019

Thanks for fixing this, @vgankidi!

@ikosyaneko, can you confirm that this fixes the issue as well? The fix in #329 avoids the problem, but we think that the underlying problem was the way the index was calculated.

@vgankidi
Copy link
Copy Markdown
Contributor Author

Also with the fix in #329, output of truncateStringMax(Literal.of(test7), 2) equals test7_1_expected instead of test7_2_expected.codePointAt gives the expected result if the index points to a high surrogate and the following character is a low surrogate. It computes the code point for the surrogate pair. Otherwise it returns the codepoint of the character in the given index as is.

@ikosyanenko Can you test your long input in #328 with this fix as well? Thanks!

@rdblue
Copy link
Copy Markdown
Contributor

rdblue commented Aug 1, 2019

Looks like this needs to be rebased.

rdblue pushed a commit that referenced this pull request Aug 1, 2019
Fixes #328, fixes #329.

Index to codePointAt should be the offset calculated by code points
@rdblue
Copy link
Copy Markdown
Contributor

rdblue commented Aug 1, 2019

I rebased and merged by hand, so I'm closing this. Thanks for fixing it, @vgankidi!

@rdblue rdblue closed this Aug 1, 2019
danielcweeks pushed a commit that referenced this pull request Aug 1, 2019
* Add argument validation to HadoopTables#create (#298)

* Install source JAR when running install target (#310)

* Add projectStrict for Dates and Timestamps (#283)

* Correctly publish artifacts on JitPack (#321)

The Gradle install target produces invalid POM files that are missing
the dependencyManagement section and versions for some dependencies.
Instead, we directly tell JitPack to run the correct Gradle target.

* Add build info to README.md (#304)

* Convert Iceberg time type to Hive string type (#325)

* Add overwrite option to write builders (#318)

* Fix out of order Pig partition fields (#326)

* Add mapping to Iceberg for external name-based schemas (#338)

* Site: Fix broken link to Iceberg API (#333)

* Add forTable method for Avro WriteBuilder (#322)

* Remove multiple literal strings check rule for scala (#335)

* Fix invalid javadoc url in README.md (#336)

* Use UnicodeUtil.truncateString for Truncate transform. (#340)

This truncates by unicode codepoint instead of Java chars.

* Refactor metrics tests for reuse (#331)

* Spark: Add support for write-audit-publish workflows (#342)

* Avoid write failures if metrics mode is invalid (#301)

* Fix truncateStringMax in UnicodeUtil (#334)

Fixes #328, fixes #329.

Index to codePointAt should be the offset calculated by code points

* [Vectorization] Added batch sizing, switched to BufferAllocator, other minor style fixes.
@vgankidi
Copy link
Copy Markdown
Contributor Author

vgankidi commented Aug 2, 2019

Thanks @rdblue!

rdblue pushed a commit to rdblue/iceberg that referenced this pull request Aug 22, 2019
Fixes apache#328, fixes apache#329.

Index to codePointAt should be the offset calculated by code points
rdblue pushed a commit to rdblue/iceberg that referenced this pull request Sep 5, 2019
Fixes apache#328, fixes apache#329.

Index to codePointAt should be the offset calculated by code points
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.

Getting java.nio.charset.MalformedInputException: Input length = 1 while converting parquets to Iceberg

2 participants