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

[BEAM-8592] Adjusting ZetaSQL table resolution to standard #10021

Merged
merged 1 commit into from
Nov 24, 2019

Conversation

kennknowles
Copy link
Member

@kennknowles kennknowles commented Nov 7, 2019

Because I am developing on Mac and ZetaSQL does not support Mac I cannot run the required unit tests so easily. Uploading to run them.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- Build Status --- --- Build Status
Java Build Status Build Status Build Status Build Status
Build Status
Build Status
Build Status Build Status Build Status
Build Status
Python Build Status
Build Status
Build Status
Build Status
--- Build Status
Build Status
Build Status
Build Status
--- --- Build Status
XLang --- --- --- Build Status --- --- ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website
Non-portable Build Status Build Status
Build Status
Build Status Build Status
Portable --- Build Status --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

@kennknowles
Copy link
Member Author

run sql postcommit

@kennknowles
Copy link
Member Author

Amazingly, since I can't run the tests locally, the ZetaSQL precommit passed.

@kennknowles kennknowles changed the title WIP adjusting ZetaSQL table resolution to standard Adjusting ZetaSQL table resolution to standard Nov 7, 2019
@kennknowles
Copy link
Member Author

I'm expecting the data catalog postcommit to fail.

@kennknowles
Copy link
Member Author

s/amazingly/suspiciously/g

Investigating the gradle scans

@kennknowles
Copy link
Member Author

run sql postcommit

@kennknowles
Copy link
Member Author

OK, confirmed that it works at least for the test coverage we have. Pushing a tiny cleanup. I'm on Mac now so I cannot confirm it so quickly.

@kennknowles kennknowles force-pushed the TableResolverImpl branch 2 times, most recently from 6f47280 to 5733ce9 Compare November 8, 2019 02:28
@kennknowles
Copy link
Member Author

run sql postcommit

@kennknowles kennknowles changed the title Adjusting ZetaSQL table resolution to standard [BEAM-8592] Adjusting ZetaSQL table resolution to standard Nov 8, 2019
@kennknowles
Copy link
Member Author

run sql precommit

Copy link
Contributor

@amaliujia amaliujia left a comment

Choose a reason for hiding this comment

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

My only question is, as JoinCompoundIdentifiersTest.java will be deleted, seems like we will lose all unit tests on table resolution?

@kennknowles
Copy link
Member Author

"join compound identifiers" table resolver is removed. In fact, all uses of TableResolver are unused. There is just one form of table resolution. There is a lot of unused code that I did not get all the way to deleting because I was focused on getting it working first. I will now go and clear it up a bit more.

I will take another look at the test file and see if there are tests that should be in unit tests of some other class.

@kennknowles
Copy link
Member Author

I took another look and I think all the functionality tested by that file is gone.

@amaliujia
Copy link
Contributor

Let me ask in another way: do we need unit tests for table resolution? If so, can you add some?

@kennknowles
Copy link
Member Author

Thanks for clarifying. That makes sense. I will review the existing tests and make sure we have coverage of a few different situations. For example I noticed that SqlTransform.withDefaultTableProvider is different than how the unit tests are set up.

@kennknowles
Copy link
Member Author

Ah. Now that I have looked closer, these tests were running against ReadOnlyTableProvider which does not support real table resolution. So it used join components to just create a string for lookup.

Since ZetaSQL table reference (list of strings) is the same structure as a Calcite table reference (list of strings), the main thing that is helpful is just unit testing of the one real method of TableResolution. The only real logic there is doing a for loop over that list of strings. I will write a couple of tests for that.

@kennknowles kennknowles force-pushed the TableResolverImpl branch 3 times, most recently from 0b300b1 to e42343b Compare November 18, 2019 21:06
@kennknowles
Copy link
Member Author

run sql postcommit

@kennknowles
Copy link
Member Author

Please take another look. I have restored unit testing to ensure that TableResolution works as expected.

Copy link
Member

@apilloud apilloud left a comment

Choose a reason for hiding this comment

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

LGTM.

Might be worth adding a test for tables with dot in their name.

return TableResolver.DEFAULT_ASSUME_LEAF_IS_TABLE;
// Set up table providers that need to be pre-registered
// TODO: share this logic between dialects, set up tables on JDBC connection too

Copy link
Member

Choose a reason for hiding this comment

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

nit:Extra whitespace?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done & filed a Jira for this TODO

* the getSubschema() path until the second-to-last path element. We expect the path to be a table
* path, so the last element should be a valid table id, we don't expect anything else there.
*
* <p>This resembles a default Calcite planner strategy. One difference is that Calcite doesn't
Copy link
Member

Choose a reason for hiding this comment

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

A bit of this comment might still be useful in explaining what this is doing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -134,6 +136,11 @@ public RelRoot rel(String sql, Map<String, Value> params) {

QueryTrait trait = new QueryTrait();

// Set up table providers that need to be pre-registered
// TODO: share this logic between dialects, set up tables on JDBC connection too
Copy link
Member

Choose a reason for hiding this comment

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

Nit: JIRA for the todo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member Author

@kennknowles kennknowles left a comment

Choose a reason for hiding this comment

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

Good point about dots in names. Added tests for those in table name and also schema. It only tests the table resolution logic, not the parser. I feel it is probably not our job to test the parser.

* the getSubschema() path until the second-to-last path element. We expect the path to be a table
* path, so the last element should be a valid table id, we don't expect anything else there.
*
* <p>This resembles a default Calcite planner strategy. One difference is that Calcite doesn't
Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

return TableResolver.DEFAULT_ASSUME_LEAF_IS_TABLE;
// Set up table providers that need to be pre-registered
// TODO: share this logic between dialects, set up tables on JDBC connection too

Copy link
Member Author

Choose a reason for hiding this comment

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

Done & filed a Jira for this TODO

@@ -134,6 +136,11 @@ public RelRoot rel(String sql, Map<String, Value> params) {

QueryTrait trait = new QueryTrait();

// Set up table providers that need to be pre-registered
// TODO: share this logic between dialects, set up tables on JDBC connection too
Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@kennknowles
Copy link
Member Author

run sql postcommit

@kennknowles kennknowles merged commit 639fc24 into apache:master Nov 24, 2019
@kennknowles kennknowles deleted the TableResolverImpl branch November 24, 2019 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants