Skip to content

Comments

[FLINK-38624][table] Type Mismatch Exception in StreamPhysicalOverAggregateRule#27616

Closed
snuyanzin wants to merge 4 commits intoapache:masterfrom
snuyanzin:flink38624
Closed

[FLINK-38624][table] Type Mismatch Exception in StreamPhysicalOverAggregateRule#27616
snuyanzin wants to merge 4 commits intoapache:masterfrom
snuyanzin:flink38624

Conversation

@snuyanzin
Copy link
Contributor

@snuyanzin snuyanzin commented Feb 15, 2026

What is the purpose of the change

The PR is going to fix type mismatch issue in case of join 2 streams (each with watermark)

In that case one for of them rel time indicator will be materialized and this was not taken into account while fixing of FLINK-27519, before that it was working, so it is a regression starting 2.0 (or 2.0-preview)

case to reproduce: see test

Brief change log

StreamPhysicalOverAggregateRule

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 )

@snuyanzin
Copy link
Contributor Author

@lincoln-lil fyi , since you participated in FLINK-27519

@flinkbot
Copy link
Collaborator

flinkbot commented Feb 15, 2026

CI report:

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

val windowInputTypes =
logicWindow.getInput.getRowType.getFieldList.asScala.map(f => f.getType).toList.asJava

// Type might be different because of RelTimeIndicatorConverter#materializeTimeIndicators
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we fix in the RelTimeIndicatorConverter instead? The output of the materializeTimeIndicators should be consistent and correct for all RexNode but also for RelNode data types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Finally fixed in RelTimeIndicatorConverter
Also seems fixed another similar issue when window function applied to watermark column (in this case it is actual for 1.20 as well), covered with tests

@snuyanzin snuyanzin force-pushed the flink38624 branch 5 times, most recently from 4003c16 to 0c1274f Compare February 22, 2026 21:27
* Sub-class of {@link Window} that is a relational expression which represents a set of over window
* aggregates in Flink.
*/
public class FlinkLogicalOverAggregate extends Window implements FlinkLogicalRel {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converted to java since this class was touched

Comment on lines +495 to 500
assertThatExceptionOfType(classOf[RuntimeException])
.isThrownBy(() => util.verifyExecPlan(sql))
.havingRootCause()
.withMessage("CHARACTER type is not allowed for window boundary")
.isExactlyInstanceOf(classOf[ValidationException])
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like the previous approach didn't check the last statement

.hasRootCauseInstanceOf(classOf[ValidationException])

it was just ignored...

Copy link
Contributor Author

@snuyanzin snuyanzin Feb 23, 2026

Choose a reason for hiding this comment

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

I noticed this weird behavior only for tests in scala
in java everything is ok

return context.getRelBuilder().getRexBuilder().makeAbstractCast(targetRelDataType, child);
return context.getRelBuilder()
.getRexBuilder()
.makeAbstractCast(targetRelDataType, child, false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

now this method with 2 args is deprecated

false means do not use SAFE_CAST (similar to Flink's TRY_CAST)

}

@Test
def testTemporalJoinWithWatermarksWithMaterializedTimeArg(): Unit = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Last 2 tests are. not regression,
Seems they just didn't work for long time even for 1.20

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for heavily looking into this!

Copy link
Contributor

@twalthr twalthr left a comment

Choose a reason for hiding this comment

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

LGTM

snuyanzin added a commit to snuyanzin/flink that referenced this pull request Feb 23, 2026
@snuyanzin snuyanzin closed this in a5223c4 Feb 23, 2026
snuyanzin added a commit to snuyanzin/flink that referenced this pull request Feb 23, 2026
snuyanzin added a commit to snuyanzin/flink that referenced this pull request Feb 23, 2026
snuyanzin added a commit to snuyanzin/flink that referenced this pull request Feb 23, 2026
snuyanzin added a commit to snuyanzin/flink that referenced this pull request Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants