gianm commented on PR #15626:
URL: https://github.com/apache/druid/pull/15626#issuecomment-1887989205

   Resolved conflicts and added two meaningful changes:
   
   1. Made FilterDecomposeConcatRule more flexible, by ignoring literal N + 1 
prior to the first appearance of literal N. This still gives us unambiguous 
decompositions, and makes it possible to handle situations like `CONCAT(a, ' 
(', b, 'x', ')') = 'xxx (2x4)'`.
   2. Made CalciteRulesManager apply expression reduction rules repeatedly as a 
group until fixpoint. This allows decomposition of complex structures of 
COALESCE, LOOKUP, and CONCAT.
   
   As an example of cool stuff that can happen, this query:
   
   ```
   SELECT CONCAT(COALESCE(LOOKUP(CONCAT(dim1, 'b', dim2), 'lookyloo'), 'N/A'), 
' (', CONCAT(dim1, 'b', dim2), ')'), COUNT(*)
   FROM foo
   WHERE CONCAT(COALESCE(LOOKUP(CONCAT(dim1, 'b', dim2), 'lookyloo'), 'N/A'), ' 
(', CONCAT(dim1, 'b', dim2), ')') = 'xabc (abc)'
   GROUP BY 1
   ```
   
   Is simplified to:
   
   ```
   SELECT
     'xabc (abc)',
     COUNT(*)
   FROM foo
   WHERE dim1 = 'a' AND dim2 = 'c'
   ```
   
   By application of concat decomposition, coalesce-into-lookup, reverse 
lookup, another concat decomposition, and finally Calcite's builtin 
ProjectReduceExpressionsRule, which pulls up the filter into the `SELECT`.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to