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-37132][transform] validate meta schema in Multi Transform #3865

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

Conversation

MOBIN-F
Copy link
Contributor

@MOBIN-F MOBIN-F commented Jan 16, 2025

In Multi Transform, verify that column counts, metadata fields like primaryKeys, partitionKeys, and options are consistent

@MOBIN-F
Copy link
Contributor Author

MOBIN-F commented Jan 16, 2025

@yuxiqian Could you help review the code?

Copy link
Contributor

@yuxiqian yuxiqian 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 @MOBIN-F's nice work, just left some minor comments.

}
}

public static void isMetaSchemaCompatible(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this is not a pure function returning Boolean, so validateSchemaMetadataCompatibility might be a better name.

@@ -452,6 +455,43 @@ public static Schema inferWiderSchema(@Nullable Schema lSchema, Schema rSchema)
return lSchema.copy(mergedColumns);
}

public static void validateMetaSchemaCompatibility(LinkedHashSet<Schema> schemas) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if is this method really reusable enough to be a utility method?

Seems the argument type is quite specific (it must be a LinkedHashSet instead of a generic schemas' collection). Also, it didn't return a "Yes or No" boolean and let the caller to decide what to do, but throws an exception if it's incompatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[but throws an exception if it's incompatible]
yeal,I think this kind of check is mandatory and cannot be ignored, and the exception is fatal, so I designed it to return void, but returning boolean seems to be good too. What do you think?

Copy link
Contributor

@yuxiqian yuxiqian Jan 20, 2025

Choose a reason for hiding this comment

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

My concern is if we're throwing an exception in the utility method, it might be less universal. But your implementation is more reasonable, because we can't return any reason message to indicate the incompatible reason by returning a boolean.

Let's just keep it as is, with just a few changes:

  • throwing a checked exception would be better and clearer for any method callers
  • change LinkedHashSet to more generic Collection

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 updated the code, could you please help review it again,thanks~

@@ -1116,6 +1117,27 @@ void testGetLeastCommonType() {
MAP));
}

@Test
void testTransformColumn() {
Assertions.assertThatCode(
Copy link
Contributor

Choose a reason for hiding this comment

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

We may use assertThatThrownBy as we're surely expecting an error

return null;
} else if (schemas.size() == 1) {
return schemas.get(0);
public static Schema getCommonSchema(LinkedHashSet<Schema> schemas) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking API change since the parameter type constraints are getting stricter. I think changing List => Collection is acceptable since it's getting wider.

@MOBIN-F MOBIN-F force-pushed the release-FLINK-37132 branch from cb2de5d to 866f0ab Compare January 21, 2025 02:06
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