Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-20539][table-planner] Fix type mismatch when casting ROW #24994

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xuyangzhong
Copy link
Contributor

What is the purpose of the change

When using cast, Flink uses ExtendedSqlRowTypeNameSpec to derive the row type, and we should change the StructKind from FULLY_QUALIFIED in Calcite to PEEK_FIELDS_NO_EXPAND in Flink.

Brief change log

  • Return a Row type with PEEK_FIELDS_NO_EXPAND as the target type in CAST
  • Add tests to verify this pr.

Verifying this change

Some tests are added to verify this pr.

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?

@flinkbot
Copy link
Collaborator

flinkbot commented Jun 28, 2024

CI report:

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

createTestItem(
"ROW<f0 INT NOT NULL, f1 BOOLEAN>",
DataTypes.ROW(
DataTypes.FIELD("f0", DataTypes.INT()),
DataTypes.FIELD("f0", DataTypes.INT().notNull()),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This hits the previous fix in

case rt: RelRecordType if rt.getStructKind == StructKind.PEEK_FIELDS_NO_EXPAND =>

// nullable and the cast does not allow setting the outer
// nullability but derives it from the source operand
DataTypes.of("ROW<r ROW<s STRING, b BOOLEAN, i INT>, s STRING>")),
// For nested rows we keep the nullability property.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto

@@ -93,16 +93,18 @@ Stream<TestSetSpec> getTestSetSpecs() {
FIELD(
"r",
ROW(
FIELD("s", STRING()),
FIELD(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed here to keep types in sql and types in table api equivalent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants