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-29722][hive] Supports native hive max function for hive dialect #21605

Closed
wants to merge 5 commits into from

Conversation

lsyldliu
Copy link
Contributor

@lsyldliu lsyldliu commented Jan 5, 2023

What is the purpose of the change

Supports native hive max function for hive dialect. Due to flink doesn't support compare array and row type, so this implementation also doesn't max array and row type, but hive udaf supports it.

Brief change log

  • Supports native hive max function for hive dialect

Verifying this change

This change added tests and can be verified as follows:

  • Added integration tests in HiveDialectQueryITCase

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? (yes)
  • If yes, how is the feature documented? (JavaDocs)

@flinkbot
Copy link
Collaborator

flinkbot commented Jan 5, 2023

CI report:

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

@lsyldliu
Copy link
Contributor Author

cc @luoyuxia

@lsyldliu
Copy link
Contributor Author

cc @beyond1920

Copy link
Contributor

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

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

@lsyldliu Thanks for contribution. I left some comments. PTAL.

@Override
public void setArguments(CallContext callContext) {
if (resultType == null) {
// check argument type firstly
Copy link
Contributor

Choose a reason for hiding this comment

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

check the count of argument num?

|| logicalType.is(LogicalTypeRoot.ROW)) {
throw new TableException(
String.format(
"Hive native max aggregate function does not support type: '%s' now. Please re-check the data type.",
Copy link
Contributor

Choose a reason for hiding this comment

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

May need to remind user to fall back to hive's implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only after FLINK-30579 merged can we fallback to hive implementation.

List<Row> result8 =
CollectionUtil.iteratorToList(
tableEnv.executeSql("select max(ts) from test_max").collect());
assertThat(result8.toString()).isEqualTo("[+I[2021-08-10T16:26:33.400]]");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please verify the assertion in Hive3 as there's some difference in timestamp type between Hive2 and Hive3.
You can verify it in your local.

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've run it use Hive3, the test passed.

@lsyldliu
Copy link
Contributor Author

@flinkbot run azure

@lsyldliu
Copy link
Contributor Author

ping @luoyuxia, please see it again.

@Tartarus0zm
Copy link
Contributor

@lsyldliu Thanks for the contribution. LGTM

Copy link
Contributor

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

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

@lsyldliu LGTM. I only left one minor advice. It depends on you to take it or not.

|| logicalType.is(LogicalTypeRoot.ROW)) {
throw new TableException(
String.format(
"Native hive %s aggregate function does not support type: %s. Please set option '%s' to false.",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Will it better to tell why set the option to false? Something like Please set option '%s' to false to fall back to Hive's own %s aggregate?
It depends on you, current exception message also looks good to me.

@lsyldliu
Copy link
Contributor Author

@flinkbot run azure

@godfreyhe godfreyhe closed this in 74c7188 Jan 19, 2023
chucheng92 pushed a commit to chucheng92/flink that referenced this pull request Feb 3, 2023
akkinenivijay pushed a commit to krisnaru/flink that referenced this pull request Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants