Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SNOW-1739096] Disallow detecting none select statement as repeated s…
…ubquery (#2467) <!--- Please answer these questions before creating your pull request. Thanks! ---> 1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR. <!--- In this section, please add a Snowflake Jira issue number. Note that if a corresponding GitHub issue exists, you should still include the Snowflake Jira issue number. For example, for GitHub issue #1400, you should add "SNOW-1335071" here. ---> SNOW-1739096 2. Fill out the following pre-review checklist: - [x] I am adding a new automated test(s) to verify correctness of my new code - [ ] If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing - [ ] I am adding new logging messages - [ ] I am adding a new telemetry message - [ ] I am adding new credentials - [ ] I am adding a new dependency - [ ] If this is a new feature/behavior, I'm adding the Local Testing parity changes. - [ ] I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: [Thread-safe Developer Guidelines](https://docs.google.com/document/d/162d_i4zZ2AfcGRXojj0jByt8EUq-DrSHPPnTa4QvwbA/edit#bookmark=id.e82u4nekq80k) 3. Please describe how your code solves the related issue. Repeated subquery elimination is only designed to eliminate subquery that is selectStatement. Since we do not distinguish query that is selectStatement and none selectStatement, we can incorrectly detect non selectstatement as candidate. for example, when we have ``` df1 = session.sql("show tables") df2 = session.sql("show tables") df_result = df1.union(df2) ``` The show table query its-self can be incorrectly detected as a common query and produced wrong query like ``` with_cte_xxx (show tables) xxxx ``` In this pr, we exclude none-selectstatment from the candidate node encoding to avoid count those node as candidate for repeated subquery elimination
- Loading branch information