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-8650] Tests for WINDOW clause and documentation update #6226

Closed
wants to merge 1 commit into from

Conversation

snuyanzin
Copy link
Contributor

@snuyanzin snuyanzin commented Jun 28, 2018

What is the purpose of the change

This PR adds test and documentation coverage of WINDOW clause

Brief change log

  • Test that the same queries but with different specification of windows have the same plan
  • Mentioning in doc WINDOW syntax

Verifying this change

This change added tests and can be verified as follows:
via running of org.apache.flink.table.api.stream.sql.OverWindowTest

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, Yarn/Mesos, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (no)

@@ -139,7 +143,8 @@ select:
[ WHERE booleanExpression ]
[ GROUP BY { groupItem [, groupItem ]* } ]
[ HAVING booleanExpression ]

[ WINDOW windowName AS windowSpec [, windowName AS windowSpec ]* ]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in a way Calcite does it

@@ -115,6 +115,10 @@ The following BNF-grammar describes the superset of supported SQL features in ba

{% highlight sql %}

insert:
INSERT INTO tableReference
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move up to be sync with the similar Calcite's doc

Copy link
Contributor

@fhueske fhueske 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 the PR @snuyanzin.

I've left a few comments. Let me know what you think.
Best, Fabian

[ ORDER BY orderItem [, orderItem ]* ]
[ PARTITION BY expression [, expression ]* ]
[
RANGE numericOrIntervalExpression { PRECEDING | FOLLOWING }
Copy link
Contributor

Choose a reason for hiding this comment

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

Flink does not support FOLLOWING yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes agree I've removed it

[ PARTITION BY expression [, expression ]* ]
[
RANGE numericOrIntervalExpression { PRECEDING | FOLLOWING }
| ROWS numericExpression { PRECEDING | FOLLOWING }
Copy link
Contributor

Choose a reason for hiding this comment

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

Flink does not support FOLLOWING yet

windowName
| windowSpec

windowSpec:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also add a WINDOW example to the Over Window aggregation section in https://ci.apache.org/projects/flink/flink-docs-release-1.5/dev/table/sql.html#aggregations ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes sure, done

@@ -44,7 +44,26 @@ class OverWindowTest extends TableTestBase {
"sum(DISTINCT c) OVER (PARTITION BY b ORDER BY proctime ROWS BETWEEN 2 preceding AND " +
"CURRENT ROW) as sum2 " +
"from MyTable"

val sql2 = "SELECT " +
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can reduce the number of tests is a bit.
We are basically testing Calcite's parser / validator multiple times with very similar queries. For example, Calcite does not distinguish between proctime and rowtime. One query with a WINDOW clause per test case should be sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. I've reduced number of queries per test case (one without WINDOW and one with). Please let me know if it looks good or not

@snuyanzin
Copy link
Contributor Author

@fhueske thank you for your review
I have left comments and done changes. Please let me know if it is required some more efforts

@fhueske
Copy link
Contributor

fhueske commented Jul 2, 2018

Thanks for the update @snuyanzin.

Looks good. Will merge it.

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