29
29
import org .apache .paimon .data .InternalRow ;
30
30
import org .apache .paimon .types .DataField ;
31
31
import org .apache .paimon .types .DataTypeRoot ;
32
+ import org .apache .paimon .types .DecimalType ;
33
+ import org .apache .paimon .types .TimestampType ;
32
34
33
35
import java .time .LocalDate ;
36
+ import java .time .LocalTime ;
34
37
import java .util .Optional ;
35
38
36
39
/**
@@ -63,7 +66,7 @@ public PaimonTypeConvert() {
63
66
register ("int" , ColumnType .INT , ColumnType .INTEGER );
64
67
}
65
68
66
- public static Object SafeGetRowData (DataField fieldType , InternalRow row , int ordinal ) {
69
+ public static Object getRowDataSafe (DataField fieldType , InternalRow row , int ordinal ) {
67
70
if (row .isNullAt (ordinal )) {
68
71
return null ;
69
72
}
@@ -73,12 +76,14 @@ public static Object SafeGetRowData(DataField fieldType, InternalRow row, int or
73
76
case VARCHAR :
74
77
return row .getString (ordinal ).toString ();
75
78
case BOOLEAN :
76
- return row .getBoolean (ordinal );
79
+ return String . valueOf ( row .getBoolean (ordinal ) );
77
80
case BINARY :
78
81
case VARBINARY :
79
82
return "<Binary Type>" ;
80
- // case DECIMAL:
81
- // return "<DECIMAL Type>";
83
+ case DECIMAL :
84
+ DecimalType decimalType = (DecimalType ) fieldType .type ();
85
+ return row .getDecimal (ordinal , decimalType .getPrecision (), decimalType .getScale ())
86
+ .toString ();
82
87
case TINYINT :
83
88
case SMALLINT :
84
89
case INTEGER :
@@ -90,12 +95,15 @@ public static Object SafeGetRowData(DataField fieldType, InternalRow row, int or
90
95
case DOUBLE :
91
96
return row .getDouble (ordinal );
92
97
case DATE :
93
- int timeInt = row .getInt (ordinal );
94
- return LocalDate .of (1970 , 1 , 1 ).plusDays (timeInt );
98
+ int dateInt = row .getInt (ordinal );
99
+ return LocalDate .of (1970 , 1 , 1 ).plusDays (dateInt );
95
100
case TIME_WITHOUT_TIME_ZONE :
101
+ int timeInt = row .getInt (ordinal );
102
+ return LocalTime .ofSecondOfDay (timeInt / 1000 );
96
103
case TIMESTAMP_WITHOUT_TIME_ZONE :
97
104
case TIMESTAMP_WITH_LOCAL_TIME_ZONE :
98
- return row .getTimestamp (ordinal , 3 ).toLocalDateTime ();
105
+ TimestampType timestampType = (TimestampType ) fieldType .type ();
106
+ return row .getTimestamp (ordinal , timestampType .getPrecision ()).toLocalDateTime ();
99
107
case ARRAY :
100
108
case MULTISET :
101
109
return row .getArray (ordinal ).toString ();
0 commit comments