raminqaf commented on code in PR #28277:
URL: https://github.com/apache/flink/pull/28277#discussion_r3324210564


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/SqlNodeConvertContext.java:
##########
@@ -110,6 +127,55 @@ public String toQuotedSqlString(SqlNode sqlNode) {
         return sqlNode.toSqlString(getSqlDialect()).getSql();
     }
 
+    @Override
+    public Optional<String> toRawSqlString(SqlNode node) {

Review Comment:
     No, and that's expected. I ran your exact snippet:                         
                                                                      
      
   ```                                                                          
                                                                      
     outer statement "CREATE TABLE x AS SELECT a FROM t1"                       
                                                                      
     innerAsQuery.getParserPosition() -> line 1, column 19                      
                                                                      
                                                                                
                                                                      
     new SqlNodeConvertContext(planner, catalogManager, 
outerStatement).toRawSqlString(innerAsQuery)                                    
              
       -> Optional[SELECT a FROM t1]                                            
                                                                      
                                                                                
                                                                      
     new SqlNodeConvertContext(planner, catalogManager, "SELECT a FROM 
t1").toRawSqlString(innerAsQuery)                                              
       -> Optional.empty
   ```
   
   the method has a precondition: the statement passed to the context must be 
the same text the node was parsed from. When that holds, the slice is correct. 
It  fails safe. It never returns a wrong substring and never throws.
   
   I will update the javaDocs with better explanation of this case.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to