[fix](paimon)fix type convert for paimon (#28774)
fix type convert for paimon
This commit is contained in:
@ -24,16 +24,17 @@ import org.apache.paimon.data.DataGetters;
|
||||
import org.apache.paimon.data.InternalArray;
|
||||
import org.apache.paimon.data.InternalMap;
|
||||
import org.apache.paimon.data.InternalRow;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
|
||||
public class PaimonColumnValue implements ColumnValue {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PaimonColumnValue.class);
|
||||
private int idx;
|
||||
private DataGetters record;
|
||||
private ColumnType dorisType;
|
||||
@ -118,13 +119,12 @@ public class PaimonColumnValue implements ColumnValue {
|
||||
|
||||
@Override
|
||||
public LocalDate getDate() {
|
||||
return LocalDate.ofEpochDay(record.getLong(idx));
|
||||
return LocalDate.ofEpochDay(record.getInt(idx));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getDateTime() {
|
||||
return Instant.ofEpochMilli(record.getTimestamp(idx, 3)
|
||||
.getMillisecond()).atZone(ZoneOffset.ofHours(0)).toLocalDateTime();
|
||||
return record.getTimestamp(idx, dorisType.getPrecision()).toLocalDateTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -98,7 +98,16 @@ public class PaimonTypeUtils {
|
||||
|
||||
@Override
|
||||
public PaimonColumnType visit(DecimalType decimalType) {
|
||||
return new PaimonColumnType(Type.DECIMAL128, decimalType.getPrecision(), decimalType.getScale());
|
||||
int precision = decimalType.getPrecision();
|
||||
Type type;
|
||||
if (precision <= ColumnType.MAX_DECIMAL32_PRECISION) {
|
||||
type = Type.DECIMAL32;
|
||||
} else if (precision <= ColumnType.MAX_DECIMAL64_PRECISION) {
|
||||
type = Type.DECIMAL64;
|
||||
} else {
|
||||
type = Type.DECIMAL128;
|
||||
}
|
||||
return new PaimonColumnType(type, decimalType.getPrecision(), decimalType.getScale());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -54,7 +54,8 @@ suite("test_paimon_catalog", "p0,external,doris,external_docker,external_docker_
|
||||
|
||||
String enabled = context.config.otherConfigs.get("enablePaimonTest")
|
||||
if (enabled != null && enabled.equalsIgnoreCase("true")) {
|
||||
def all = """select * from all_table;"""
|
||||
def all = """select * from all_table order by c1;"""
|
||||
def all_with_parquet = """select * from all_table_with_parquet order by c1;"""
|
||||
def c1 = """select * from all_table where c1=1;"""
|
||||
def c2 = """select * from all_table where c2=2;"""
|
||||
def c3 = """select * from all_table where c3=3;"""
|
||||
@ -173,6 +174,7 @@ suite("test_paimon_catalog", "p0,external,doris,external_docker,external_docker_
|
||||
sql """use `${catalog_name}`.`db1`"""
|
||||
|
||||
qt_all all
|
||||
qt_all_with_parquet all_with_parquet
|
||||
qt_c1 c1
|
||||
qt_c2 c2
|
||||
qt_c3 c3
|
||||
|
||||
Reference in New Issue
Block a user