dssysolyatin commented on PR #4491:
URL: https://github.com/apache/calcite/pull/4491#issuecomment-3164194589

   @mihaibudiu @suibianwanwank Please rereview PR
   
   Although I still believe the previous fix was correct in theory, but 
`RelToSqlConverter` does some things that, in my opinion, it shouldn’t and such 
things should be done by optimizer.
   
   One of such things, that RelToSqlConverter tries to “merge projections” and 
it is done using alias propogation which I restricted by my previous fix. 
However, since RelToSqlConverter already has this behavior and some users rely 
on it, I added a workaround instead. I don’t consider this a proper fix, but at 
least it doesn’t break anything.
   
   Some example
   If I pass the following plan to `RelToSqlConverter`:
   
   ```
   LogicalProject(EMPNO=[$0])
     LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
SAL=[$5], COMM=[$6], DEPTNO=[$7])
       LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], 
HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7])
         LogicalTableScan(table=[[scott, EMP]])
   ```
   
   It generates the following SQL:
   ```
   "SELECT \"EMP\".\"EMPNO\"\n"
       + "FROM \"scott\".\"EMP\" AS \"EMP\""
   ```
   With my previous fix, it produced:

   ```
   "SELECT \”t0\”.\”EMPNO\"\n"
       + "FROM \"scott\".\"EMP\" AS \"EMP\""
   ```
   But t0 doesn’t exist — which is incorrect.
   I’ve also added a couple of tests for these cases.


-- 
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