|
52 | 52 |
|
53 | 53 | import java.math.BigDecimal; |
54 | 54 | import java.nio.charset.Charset; |
55 | | -import java.util.AbstractList; |
56 | | -import java.util.ArrayList; |
57 | | -import java.util.Collection; |
58 | | -import java.util.List; |
59 | | -import java.util.Map; |
| 55 | +import java.util.*; |
60 | 56 | import java.util.function.Function; |
61 | 57 | import java.util.stream.Collectors; |
62 | 58 |
|
63 | 59 | import static org.apache.calcite.rel.type.RelDataTypeImpl.NON_NULLABLE_SUFFIX; |
64 | 60 | import static org.apache.calcite.sql.type.NonNullableAccessors.getCharset; |
65 | 61 | import static org.apache.calcite.sql.type.NonNullableAccessors.getCollation; |
66 | 62 | import static org.apache.calcite.sql.type.NonNullableAccessors.getComponentTypeOrThrow; |
| 63 | +import static org.apache.calcite.sql.type.SqlTypeName.TIME; |
| 64 | +import static org.apache.calcite.sql.type.SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE; |
67 | 65 | import static org.apache.calcite.util.Static.RESOURCE; |
68 | 66 |
|
69 | 67 | import static java.util.Objects.requireNonNull; |
@@ -387,6 +385,13 @@ public static boolean isDate(RelDataType type) { |
387 | 385 | return type.getSqlTypeName() == SqlTypeName.DATE; |
388 | 386 | } |
389 | 387 |
|
| 388 | + public static boolean isTime(RelDataType type) { |
| 389 | + return Optional.ofNullable(type) |
| 390 | + .map(RelDataType::getSqlTypeName) |
| 391 | + .map(sqlTypeName -> sqlTypeName == TIME || sqlTypeName == TIME_WITH_LOCAL_TIME_ZONE) |
| 392 | + .orElse(false); |
| 393 | + } |
| 394 | + |
390 | 395 | /** Returns whether a type is TIMESTAMP. */ |
391 | 396 | public static boolean isTimestamp(RelDataType type) { |
392 | 397 | return SqlTypeFamily.TIMESTAMP.contains(type); |
|
0 commit comments