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 @@ -648,9 +648,11 @@ object FlinkTypeFactory {
case typeName if YEAR_INTERVAL_TYPES.contains(typeName) =>
DataTypes.INTERVAL(DataTypes.MONTH).getLogicalType
case typeName if DAY_INTERVAL_TYPES.contains(typeName) =>
if (relDataType.getPrecision > 3) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was wrong precision to check

// In INTERVAL getScale tells about fractional second precision
// See org.apache.calcite.sql.SqlIntervalQualifier
if (relDataType.getScale > 3) {
throw new TableException(
s"DAY_INTERVAL_TYPES precision is not supported: ${relDataType.getPrecision}")
s"DAY_INTERVAL_TYPES precision is not supported: ${relDataType.getScale}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits:
s"DAY_INTERVAL_TYPES precision is not supported: ${relDataType.getScale} (max supported: 3)"
or
s"Fractional second precision ${relDataType.getScale} is not supported for day-time interval types (max supported: 3)"

}
DataTypes.INTERVAL(DataTypes.SECOND(3)).getLogicalType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ class ScalarFunctionsValidationTest extends ScalarTypesTestBase {
() => testSqlApi("TIMESTAMPADD(YEAR, 1.0, timestamp '2016-02-24 12:42:25')", "2016-06-16"))
}

@Test
def testTimestampAddWithUnsupportedPrecision(): Unit = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can add testTimestampAddWithSupportedPrecision
add testSqlApi("TIMESTAMPADD(MILLISECOND, 1, timestamp '2016-02-24 12:42:25')", "2016-02-24 12:42:25.001") test is supported.

assertThatExceptionOfType(classOf[TableException])
.isThrownBy(
() =>
testSqlApi("TIMESTAMPADD(MICROSECOND, 1, timestamp '2016-02-24 12:42:25')", "2016-06-16"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.withMessageContaining("not supported")
or
.withMessageContaining("precision is not supported")


assertThatExceptionOfType(classOf[TableException])
.isThrownBy(
() =>
testSqlApi("TIMESTAMPADD(NANOSECOND, 1, timestamp '2016-02-24 12:42:25')", "2016-06-16"))
}

// ----------------------------------------------------------------------------------------------
// Sub-query functions
// ----------------------------------------------------------------------------------------------
Expand Down