[bugfix](paimon)Fixed the reading of timestamp with time zone type data for 2.1 (#37716) (#38592)

bp: #37716
This commit is contained in:
wuwenchi
2024-08-01 10:23:06 +08:00
committed by GitHub
parent 9f1e41c623
commit 41fa7bc9fd
7 changed files with 400 additions and 51 deletions

View File

@ -88,6 +88,7 @@ public class PaimonExternalTable extends ExternalTable {
}
private Type paimonPrimitiveTypeToDorisType(org.apache.paimon.types.DataType dataType) {
int tsScale = 3; // default
switch (dataType.getTypeRoot()) {
case BOOLEAN:
return Type.BOOLEAN;
@ -114,20 +115,26 @@ public class PaimonExternalTable extends ExternalTable {
case DATE:
return ScalarType.createDateV2Type();
case TIMESTAMP_WITHOUT_TIME_ZONE:
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
int scale = 3; // default
if (dataType instanceof org.apache.paimon.types.TimestampType) {
scale = ((org.apache.paimon.types.TimestampType) dataType).getPrecision();
if (scale > 6) {
scale = 6;
tsScale = ((org.apache.paimon.types.TimestampType) dataType).getPrecision();
if (tsScale > 6) {
tsScale = 6;
}
} else if (dataType instanceof org.apache.paimon.types.LocalZonedTimestampType) {
scale = ((org.apache.paimon.types.LocalZonedTimestampType) dataType).getPrecision();
if (scale > 6) {
scale = 6;
tsScale = ((org.apache.paimon.types.LocalZonedTimestampType) dataType).getPrecision();
if (tsScale > 6) {
tsScale = 6;
}
}
return ScalarType.createDatetimeV2Type(scale);
return ScalarType.createDatetimeV2Type(tsScale);
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
if (dataType instanceof org.apache.paimon.types.LocalZonedTimestampType) {
tsScale = ((org.apache.paimon.types.LocalZonedTimestampType) dataType).getPrecision();
if (tsScale > 6) {
tsScale = 6;
}
}
return ScalarType.createDatetimeV2Type(tsScale);
case ARRAY:
ArrayType arrayType = (ArrayType) dataType;
Type innerType = paimonPrimitiveTypeToDorisType(arrayType.getElementType());