Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public int getMaxPrecision(final SqlTypeName typeName) {
case INTERVAL_YEAR:
case INTERVAL_YEAR_MONTH:
case TIME:
case TIME_WITH_LOCAL_TIME_ZONE:
case TIMESTAMP:
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
return 6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static io.substrait.isthmus.SubstraitTypeSystem.TYPE_FACTORY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeSystem;
Expand Down Expand Up @@ -42,6 +43,20 @@ void timeMaxPrecision() {
assertEquals(6, typeSystem.getMaxPrecision(SqlTypeName.TIME));
}

@Test
void timeWithLocalTimeZoneHasNoSubstraitMaxPrecision() {
// Substrait has precision_timestamp_tz but no time-with-timezone counterpart, so this type
// converts in neither direction and there is no Substrait maximum to report for it.
assertThrows(
UnsupportedOperationException.class,
() ->
TypeConverter.DEFAULT.toSubstrait(
TYPE_FACTORY.createSqlType(SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE, 3)));
assertEquals(
RelDataTypeSystem.DEFAULT.getMaxPrecision(SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE),
typeSystem.getMaxPrecision(SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE));
}

@Test
void canCreateDecimalWithMaxPrecision() {
RelDataType decimalType = TYPE_FACTORY.createSqlType(SqlTypeName.DECIMAL, 38, 10);
Expand Down
Loading