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,14 +76,17 @@ 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 :
89
+ return row .getShort (ordinal );
84
90
case INTEGER :
85
91
return row .getInt (ordinal );
86
92
case BIGINT :
@@ -90,12 +96,15 @@ public static Object SafeGetRowData(DataField fieldType, InternalRow row, int or
90
96
case DOUBLE :
91
97
return row .getDouble (ordinal );
92
98
case DATE :
93
- int timeInt = row .getInt (ordinal );
94
- return LocalDate .of (1970 , 1 , 1 ).plusDays (timeInt );
99
+ int dateInt = row .getInt (ordinal );
100
+ return LocalDate .of (1970 , 1 , 1 ).plusDays (dateInt );
95
101
case TIME_WITHOUT_TIME_ZONE :
102
+ int timeInt = row .getInt (ordinal );
103
+ return LocalTime .ofSecondOfDay (timeInt / 1000 );
96
104
case TIMESTAMP_WITHOUT_TIME_ZONE :
97
105
case TIMESTAMP_WITH_LOCAL_TIME_ZONE :
98
- return row .getTimestamp (ordinal , 3 ).toLocalDateTime ();
106
+ TimestampType timestampType = (TimestampType ) fieldType .type ();
107
+ return row .getTimestamp (ordinal , timestampType .getPrecision ()).toLocalDateTime ();
99
108
case ARRAY :
100
109
case MULTISET :
101
110
return row .getArray (ordinal ).toString ();
0 commit comments