gortiz commented on issue #12705:
URL: https://github.com/apache/pinot/issues/12705#issuecomment-2553219911

   The problem here is that the engine is using two different operators.
   
   I was able to replicate the issue with the following quickstart query:
   ```sql
   select min(cast(AirTime as DECIMAL)) from airlineStats limit 10
   ```
   
   Which produces the following plan:
   ```
   Execution Plan
   LogicalSort(fetch=[10])
     PinotLogicalSortExchange(distribution=[hash], collation=[[]], 
isSortOnSender=[false], isSortOnReceiver=[false])
       PinotLogicalAggregate(group=[{}], agg#0=[MIN($0)], aggType=[FINAL])  <-- 
whose return type is DECIMAL
         PinotLogicalExchange(distribution=[hash]) <-- whose return type is 
double
           PinotLogicalAggregate(group=[{}], agg#0=[MIN($0)], aggType=[LEAF]) 
<-- whose return type is DOUBLE
             LogicalProject($f0=[CAST($4):DECIMAL(1000, 0) NOT NULL])
               LogicalTableScan(table=[[default, airlineStats]])
   ```
   
   Therefore the leaf stage sends doubles while the intermediate state expects 
big decimals. Therefore the issue here is not SSE (aka V1) but the way we 
resolve functions. I still don't know where, but it looks like at some point 
one of our rules has to be breaking the type matching. Ideally we should always 
use the correct aggregate function (AFAIK we should be able to do that now that 
the registry has been unified) but in case we are not, at least we should add a 
transformation node that automatically converts (aka casts) values.


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