suxiaogang223 opened a new pull request, #58603:
URL: https://github.com/apache/doris/pull/58603
### What problem does this PR solve?
## Problem
When generating Iceberg data files, the code was directly using
human-readable partition value strings (e.g., "2025-01-01" for DATE,
"2025-01-25 10:00:00" for TIMESTAMP) as partition values. However, Iceberg's
`DataFiles.Builder.withPartitionValues()` expects partition values in their
internal format (e.g., epoch days for DATE, microseconds for TIMESTAMP), not
human-readable strings.
## Solution
This PR fixes the partition value conversion by:
1. **Added `parsePartitionValueFromString()` method in `IcebergUtils.java`**:
- Converts human-readable partition value strings to appropriate Java
types based on Iceberg type
- Supports all partition types: STRING, INTEGER, LONG, FLOAT, DOUBLE,
BOOLEAN, DATE, TIMESTAMP, DECIMAL
- For DATE: converts "yyyy-MM-dd" format to epoch days
- For TIMESTAMP: uses Doris's built-in datetime parser to handle various
timestamp formats and converts to microseconds
2. **Added `parseTimestampToMicros()` helper method**:
- Parses timestamp strings using Doris's `DateLiteral.parseDateTime()`
for format flexibility
- Converts parsed timestamps to microseconds since epoch
- Handles timezone-aware and timezone-naive timestamps
3. **Refactored `IcebergWriterHelper.java`**:
- Changed from using `List<String>` partition values to `PartitionData`
- Added `convertToPartitionData()` method to convert human-readable
partition values from Backend to Iceberg's `PartitionData` format
- Updated `genDataFile()` to use `PartitionData` instead of raw string
list
- Now correctly uses `DataFiles.Builder.withPartition()` instead of
`withPartitionValues()`
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]