Skip to content

Conversation

@piotrrzysko
Copy link
Member

Description

Previously, providing a negative grace period resulted in a low-level internal exception:

Caused by: java.lang.IllegalArgumentException: gracePeriod cannot be negative: Optional[PT-1H]
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:217)
	at io.trino.metadata.MaterializedViewDefinition.<init>(MaterializedViewDefinition.java:49)

Additional context and related issues

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label Dec 1, 2025
@piotrrzysko piotrrzysko requested a review from findepi December 1, 2025 11:30
if (context.GRACE() != null) {
gracePeriod = Optional.of((IntervalLiteral) visit(context.interval()));
IntervalLiteral interval = (IntervalLiteral) visit(context.interval());
if (interval.getSign() == IntervalLiteral.Sign.NEGATIVE) {
Copy link
Member

Choose a reason for hiding this comment

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

This should be done in the semantic analyzer, not in the AST builder.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed. I think I understand the reason. Just out of curiosity: if we had an unsigned interval type and used it for GRACE PERIOD, would that be a syntax error then?

Copy link
Member

Choose a reason for hiding this comment

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

Correct. But that would be handled in the grammar. Syntax checks in the AST builder should be limited to extreme cases that cannot handled easily via antlr4 rules.

Previously, providing a negative grace period resulted in a low-level
internal exception:

Caused by: java.lang.IllegalArgumentException: gracePeriod cannot be negative: Optional[PT-1H]
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:217)
	at io.trino.metadata.MaterializedViewDefinition.<init>(MaterializedViewDefinition.java:49)
@piotrrzysko piotrrzysko force-pushed the negative_grace_period branch from 2a42eb7 to 0dbcd6e Compare December 1, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants