@@ -55,24 +55,54 @@ public io.trino.spi.type.Type getTrinoType(Type type) {
55
55
}
56
56
57
57
private static TimestampWithTimeZoneType getTimestampWithTimeZoneType (int precision ) {
58
- if (precision == 0 ) return TimestampWithTimeZoneType .TIMESTAMP_TZ_SECONDS ;
59
- if (precision <= 3 ) return TimestampWithTimeZoneType .TIMESTAMP_TZ_MILLIS ;
60
- if (precision <= 6 ) return TimestampWithTimeZoneType .TIMESTAMP_TZ_MICROS ;
61
- return TimestampWithTimeZoneType .TIMESTAMP_TZ_NANOS ;
58
+ switch (precision ) {
59
+ case 0 :
60
+ return TimestampWithTimeZoneType .TIMESTAMP_TZ_SECONDS ;
61
+ case 3 :
62
+ return TimestampWithTimeZoneType .TIMESTAMP_TZ_MILLIS ;
63
+ case 6 :
64
+ return TimestampWithTimeZoneType .TIMESTAMP_TZ_MICROS ;
65
+ case 9 :
66
+ return TimestampWithTimeZoneType .TIMESTAMP_TZ_NANOS ;
67
+ default :
68
+ throw new TrinoException (
69
+ GravitinoErrorCode .GRAVITINO_ILLEGAL_ARGUMENT ,
70
+ "Invalid timestamp precision: " + precision + ". Valid values are 0, 3, 6, 9" );
71
+ }
62
72
}
63
73
64
74
private static TimestampType getTimestampType (int precision ) {
65
- if (precision == 0 ) return TimestampType .TIMESTAMP_SECONDS ;
66
- if (precision <= 3 ) return TimestampType .TIMESTAMP_MILLIS ;
67
- if (precision <= 6 ) return TimestampType .TIMESTAMP_MICROS ;
68
- return TimestampType .TIMESTAMP_NANOS ;
75
+ switch (precision ) {
76
+ case 0 :
77
+ return TimestampType .TIMESTAMP_SECONDS ;
78
+ case 3 :
79
+ return TimestampType .TIMESTAMP_MILLIS ;
80
+ case 6 :
81
+ return TimestampType .TIMESTAMP_MICROS ;
82
+ case 9 :
83
+ return TimestampType .TIMESTAMP_NANOS ;
84
+ default :
85
+ throw new TrinoException (
86
+ GravitinoErrorCode .GRAVITINO_ILLEGAL_ARGUMENT ,
87
+ "Invalid timestamp precision: " + precision + ". Valid values are 0, 3, 6, 9" );
88
+ }
69
89
}
70
90
71
91
private static TimeType getTimeType (int precision ) {
72
- if (precision == 0 ) return TimeType .TIME_SECONDS ;
73
- if (precision <= 3 ) return TimeType .TIME_MILLIS ;
74
- if (precision <= 6 ) return TimeType .TIME_MICROS ;
75
- return TimeType .TIME_NANOS ;
92
+ switch (precision ) {
93
+ case 0 :
94
+ return TimeType .TIME_SECONDS ;
95
+ case 3 :
96
+ return TimeType .TIME_MILLIS ;
97
+ case 6 :
98
+ return TimeType .TIME_MICROS ;
99
+ case 9 :
100
+ return TimeType .TIME_NANOS ;
101
+ default :
102
+ throw new TrinoException (
103
+ GravitinoErrorCode .GRAVITINO_ILLEGAL_ARGUMENT ,
104
+ "Invalid time precision: " + precision + ". Valid values are 0, 3, 6, 9" );
105
+ }
76
106
}
77
107
78
108
@ Override
0 commit comments