You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/06/12 14:55:32 UTC

[GitHub] [flink] LadyForest opened a new pull request, #19940: [FLINK-27965][table-planner] Fix EXPLAIN PLAN produces wrong query sc…

LadyForest opened a new pull request, #19940:
URL: https://github.com/apache/flink/pull/19940

   ## What is the purpose of the change
   
   This pull request fixes the issue that the `EXPLAIN PLAN FOR INSERT` with static partition spec produces the wrong query schema.
   
   During the conversion phase, the query will be validated and rewritten by `PreValidateReWriter`, and `PreValidateReWriter#appendPartitionAndNullsProjects` will perform the following rewrite(https://github.com/apache/flink/blob/master/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/calcite/PreValidateReWriter.scala#L89).
   ```sql
   -- before rewrite
   insert into A partition(a='11',
    c='22') select b from B
   
   -- after rewrite
   insert into A partition(a='11', c='22') select cast('11' as tpe1), b, cast('22' as tpe2) from B
   ```
   However, the `SqlRichExplain` are first validated as a whole and then got its statement validated again, thus the insert query is rewritten twice, which causes the issue.
   
   ## Brief change log
     - For `SqlRichExplain`, let`FlinkPlannerImpl` validate the insert's source instead of insert.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - Add `TableEnvironmentTest#testExecuteSqlWithExplainInsertStaticPartition`
     - Add it case in `table.q`
    
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] JingsongLi commented on a diff in pull request #19940: [FLINK-27965][table-planner] Fix EXPLAIN PLAN produces wrong query sc…

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #19940:
URL: https://github.com/apache/flink/pull/19940#discussion_r895303364


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/calcite/FlinkPlannerImpl.scala:
##########
@@ -149,7 +149,20 @@ class FlinkPlannerImpl(
       }
       sqlNode match {
         case richExplain: SqlRichExplain =>
-          richExplain.setOperand(0, validate(richExplain.getStatement))
+          val validatedStatement = richExplain.getStatement match {
+            // only validate source here
+            case insert: RichSqlInsert =>
+              if (insert.isUpsert) {

Review Comment:
   Extract a method for reusing?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] flinkbot commented on pull request #19940: [FLINK-27965][table-planner] Fix EXPLAIN PLAN produces wrong query sc…

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #19940:
URL: https://github.com/apache/flink/pull/19940#issuecomment-1153196733

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "741b894b30d2c83598faea976d0b022342669762",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "741b894b30d2c83598faea976d0b022342669762",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 741b894b30d2c83598faea976d0b022342669762 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] LadyForest commented on pull request #19940: [FLINK-27965][table-planner] Fix EXPLAIN PLAN produces wrong query sc…

Posted by GitBox <gi...@apache.org>.
LadyForest commented on PR #19940:
URL: https://github.com/apache/flink/pull/19940#issuecomment-1153815454

   @flinkbot run azure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] JingsongLi merged pull request #19940: [FLINK-27965][table-planner] Fix EXPLAIN PLAN produces wrong query sc…

Posted by GitBox <gi...@apache.org>.
JingsongLi merged PR #19940:
URL: https://github.com/apache/flink/pull/19940


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org