[lake/lance] Add tests for Decimal and Timestamp(LTZ) conversions#3573
Open
XuQianJin-Stars wants to merge 1 commit into
Open
[lake/lance] Add tests for Decimal and Timestamp(LTZ) conversions#3573XuQianJin-Stars wants to merge 1 commit into
XuQianJin-Stars wants to merge 1 commit into
Conversation
Extend Lance test coverage for Decimal and Timestamp/TimestampLtz mappings on both the Fluss RowType -> non-shaded Arrow schema layer (LanceArrowUtils) and the shaded -> non-shaded VectorSchemaRoot copy layer (ArrowDataConverter): - LanceArrowUtilsTest: assert Arrow type for DECIMAL(9,2) / DECIMAL(20,4) including precision and scale round-trip; assert TimeUnit selection for TIMESTAMP_LTZ(0/3/6/9) and TIMESTAMP(0/3/6/9). - ArrowDataConverterTest: end-to-end conversion of DECIMAL(20,4) values through ShadedArrowBatchWriter into a non-shaded DecimalVector, and TIMESTAMP_LTZ(3)/TIMESTAMP_LTZ(6) columns into TimeStampMilliVector and TimeStampMicroVector respectively, including sub-millisecond precision truncation semantics. These types are common in financial and event-time workloads; adding explicit coverage guards against future regressions in the Lance tiering path.
4949d21 to
001c893
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extend Lance test coverage for Decimal and Timestamp/TimestampLtz mappings on both the Fluss RowType -> non-shaded Arrow schema layer (
LanceArrowUtils) and the shaded -> non-shadedVectorSchemaRootcopy layer (ArrowDataConverter):LanceArrowUtilsTest: assert Arrow type forDECIMAL(9,2)/DECIMAL(20,4)including precision and scale round-trip; assertTimeUnitselection forTIMESTAMP_LTZ(0/3/6/9)andTIMESTAMP(0/3/6/9).ArrowDataConverterTest: end-to-end conversion ofDECIMAL(20,4)values throughShadedArrowBatchWriterinto a non-shadedDecimalVector, andTIMESTAMP_LTZ(3)/TIMESTAMP_LTZ(6)columns intoTimeStampMilliVectorandTimeStampMicroVectorrespectively, including sub-millisecond precision truncation semantics.These types are common in financial and event-time workloads; adding explicit coverage guards against future regressions in the Lance tiering path.
Purpose
Lance tiering already handles
DECIMAL,TIMESTAMPandTIMESTAMP_LTZin production code, but the existing unit tests did not directly exercise:DECIMALon the shaded -> non-shaded schema mapping,TimeUnitselection rules (SECOND / MILLISECOND / MICROSECOND / NANOSECOND) forTIMESTAMPandTIMESTAMP_LTZat every supported precision (0/3/6/9),Decimal/TimestampLtzthroughShadedArrowBatchWriterinto the corresponding non-shaded Arrow vectors (including sub-millisecond truncation forTIMESTAMP_LTZ(3)and microsecond preservation forTIMESTAMP_LTZ(6)).This PR closes that gap so that any future refactor of
LanceArrowUtilsorArrowDataConverterwill surface regressions on these two commonly-used-in-production types immediately.Linked issue: close #xxx
Brief change log
Test-only change. No production code is touched.
LanceArrowUtilsTest: add three tests (+65 lines)testToArrowSchemaWithDecimal— assertsArrowType.Decimal(9,2)andArrowType.Decimal(20,4)are produced for the corresponding Fluss types.testToArrowSchemaWithTimestampLtz— assertsTIMESTAMP_LTZ(0/3/6/9)maps to ArrowTimestampwithSECOND/MILLISECOND/MICROSECOND/NANOSECOND.testToArrowSchemaWithTimestampNtz— same coverage forTIMESTAMP(0/3/6/9)(no time zone).ArrowDataConverterTest: add three tests (+104 lines)testConvertDecimalColumn— writes threeDECIMAL(20,4)values (positive / negative / very small) viaShadedArrowBatchWriter, converts to a non-shadedVectorSchemaRoot, and verifies each value usingBigDecimal.compareToonDecimalVector#getObject.testConvertTimestampLtzMillisColumn— writes threeTIMESTAMP_LTZ(3)values built withTimestampLtz.fromEpochMillisand asserts round-trip viaTimeStampMilliVector#get.testConvertTimestampLtzMicrosColumn— writesTIMESTAMP_LTZ(6)values with sub-millisecond components (Instant.ofEpochMilli(...).plusNanos(...)) and asserts the expected microsecond value inTimeStampMicroVector(i.e.millis * 1_000 + nanoOfMillis / 1_000), locking in the truncation semantics.Tests
New tests are the deliverable of this PR. Verified locally:
./mvnw -pl fluss-lake/fluss-lake-lance test -Dspotless.check.skip— all Lance tests pass, including the 6 new ones../mvnw -pl fluss-lake/fluss-lake-lance checkstyle:check— 0 violations.No production behavior change; existing tests are unchanged.
API and Format
None. This PR only adds tests under
src/test/java. There are no changes to public Java API, table properties, wire format, or on-disk / Lance dataset format.Documentation
None. Test-only change; no user-facing documentation impact.