HanumathRao commented on PR #3640:
URL: https://github.com/apache/calcite/pull/3640#issuecomment-1932905283

   > @HanumathRao could you please elaborate why we need in this PR the changes 
in `CassandraSchema.java` and `Prepare.java`? Is is related to the 
decorrelation problem, or could they be part of a separate issue?
   
   1. Changes to Prepare.java file, 
   Yes in a subtle way. The trimUnusedField ,in the prepareSql function call 
path, is called conditionally based on the configHolder's isTrimUnusedFields 
flag and due to this it results in trimUnusedFields getting called before 
decorrelateQuery is called. However, the same functionality in PlannerImpl.rel 
code path (most calcite users seem to use it), trimUnusedFields is set to false 
and this makes sure the decorrelateQuery is called before the trimUnusedFields.
   
   In both the cases the RelFieldTrimmer program is called in the optimize 
phase of the query, so essentially fields will get trimmed, but in the case of 
Prepare (which I believe is less used by users) doing so will result in a tree 
which will cause other issues due to lack of comprehensive handling of 
correlate subqueries.
   
   Essentially I am trying to make both the paths to behave same.
   
   2. The changes in CassandraSchema.java are done because earlier 
CassandraSchema Test code loaded the materializations using TRIMMED Hook. As 
this code path is no more available, I changed it to load on CONVERTED Hook. 
This way the materializations are available for the optimizations, otherwise 
the materializations are not loaded and MaterializedView optimization is 
skipped. 
   
   Hope the above description made it clear. Please let me know if you have any 
further questions/suggestions.


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