Skip to content

[FLINK-39498][table] Day time interval with unsupported precision should fail in planning time rather than code gen#27979

Open
snuyanzin wants to merge 2 commits intoapache:masterfrom
snuyanzin:flink39498
Open

[FLINK-39498][table] Day time interval with unsupported precision should fail in planning time rather than code gen#27979
snuyanzin wants to merge 2 commits intoapache:masterfrom
snuyanzin:flink39498

Conversation

@snuyanzin
Copy link
Copy Markdown
Contributor

What is the purpose of the change

The query like

SELECT TIMESTAMPADD(MICROSECOND, 1, timestamp '2016-02-24 12:42:25')

fails while code generation
at the same ime we have all the data to fail during planning

Brief change log

typefactory

Verifying this change

test added

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): ( no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): ( no)
  • The serializers: ( no)
  • The runtime per-record code paths (performance sensitive): (no )
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no )
  • The S3 file system connector: (no )

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not applicable )

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

…uld fail in planning time rather than code gen
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

@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented Apr 20, 2026

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Copy link
Copy Markdown
Contributor

@fhueske fhueske left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @snuyanzin.

+1 to merge!

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)"

}

@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")

@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants