-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
[hotfix][docs]fix flink sql Cascading Window TVF Aggregation exception #18414
Conversation
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit 3c3aede (Thu Jan 20 07:11:16 UTC 2022) ✅no warnings Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
@MartijnVisser Can you review it for me? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simenliuxing Thanks for contribution. LGTM.
Only left a few comments here.
@@ -199,7 +199,7 @@ The following shows a cascading window aggregation where the first window aggreg | |||
```sql | |||
-- tumbling 5 minutes for each supplier_id | |||
CREATE VIEW window1 AS | |||
SELECT window_start, window_end, window_time as rowtime, SUM(price) as partial_price | |||
SELECT window_start as window1_start, window_end as window1_end, window_time as rowtime, SUM(price) as partial_price |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some comments here to explain that we need alias here to avoid name conflict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When i use sql as below:
-- tumbling 5 minutes for each supplier_id
CREATE VIEW window1 AS
SELECT window_start as window1_start, window_end as window1_end, window_time as rowtime, SUM(price) as partial_price
FROM TABLE(
TUMBLE(TABLE Bid, DESCRIPTOR(bidtime), INTERVAL '5' MINUTES))
GROUP BY supplier_id, window_start, window_end, window_time;
-- tumbling 10 minutes on the first window
SELECT window_start, window_end, SUM(partial_price) as total_price
FROM TABLE(
TUMBLE(TABLE window1, DESCRIPTOR(rowtime), INTERVAL '10' MINUTES))
GROUP BY window_start, window_end;
The following exception occurs:
Caused by: org.apache.calcite.sql.validate.SqlValidatorException: Column 'window_start' is ambiguous
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:467)
at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:560)
... 41 more
I think the following piece of sql cannot identify whether window_start is from window1 or from built-in.
But the following sql is for Group Window Aggregation, the required window_start and window_end are not from window1, So I renamed window_start and window_end in the above sql.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that a proper fix is changing the documentation. I would expect that we should address the issue to avoid getting the exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i see. this is the result of other communication with me
https://issues.apache.org/jira/browse/FLINK-25700?filter=-2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. If that's the case, then I guess we should indeed update this documentation :) I would then only slightly modify the alias to make it more clearer, something like:
SELECT window_start as window1_start, window_end as window1_end, window_time as rowtime, SUM(price) as partial_price | |
SELECT window_start as window_5mintumble_start, window_end as window_5mintumble_end, window_time as rowtime, SUM(price) as partial_price |
or
SELECT window_start as window1_start, window_end as window1_end, window_time as rowtime, SUM(price) as partial_price | |
SELECT window_start as window_5mintumblepersupplier_start, window_end as window_5mintumblepersupplier_end, window_time as rowtime, SUM(price) as partial_price |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestion, I have revised
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, what do you think @beyond1920 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simenliuxing Thanks for explain.
I mean to add some comments in documents to explain that we need alias here to avoid name conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@beyond1920
Sorry for misunderstanding, I have added the comment
@@ -199,7 +199,8 @@ The following shows a cascading window aggregation where the first window aggreg | |||
```sql | |||
-- tumbling 5 minutes for each supplier_id | |||
CREATE VIEW window1 AS | |||
SELECT window_start, window_end, window_time as rowtime, SUM(price) as partial_price | |||
-- under the Cascading Window Aggregation to avoid field ambiguity window_start and window_end need to be renamed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- under the Cascading Window Aggregation to avoid field ambiguity window_start and window_end need to be renamed | |
-- Note: The window start and window end fields of inner Window TVF are optional in the select clause. However, if they appear in the clause, they need to be aliased to prevent name conflicting with the window start and window end of the outer Window TVF. |
WDTY?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I have revised
…void name conflict
Merged. Thanks for contribution @simenliuxing |
What is the purpose of the change
Aliases need to be used under Cascading Window Aggregation, otherwise an error will be reported, but there is no such thing in the documentation, so I fixed it
Brief change log
Fix errors in documentation, add aliases
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation