abhioncbr commented on PR #10814:
URL: https://github.com/apache/pinot/pull/10814#issuecomment-1573990610

   > > I found that the CAST transformation will happen based on the evaluation 
of this 
[function](https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystemImpl.java#L62).
 The `CAST` transformation applies to the data type with lower precision. In 
the case of INT-LONG, Integer has lower precision(10) vs BigInt(19). However, 
In the case of FLOAT-DOUBLE, both have the same precision value and hence CAST 
applies to the RHS. I override the method in my latest commit by assigning 
`DOUBLE` more precision value than `FLOAT` to get the correct results.
   > 
   > hmm. this seems incorrect.
   > 
   > 1. according to `RelDataTypeFactoryImpl`
   > 
   > ```
   >     case FLOAT:
   >       return createSqlType(SqlTypeName.DECIMAL, 14, 7);
   >     case DOUBLE:
   >       // the default max precision is 19, so this is actually DECIMAL(19, 
15)
   >       // but derived system can override the max precision/scale.
   >       return createSqlType(SqlTypeName.DECIMAL, 30, 15);
   > ```
   > 
   > I think there are some discrepancy when we overwrite TypeSystem vs 
TypeFactory
   > 
   > 2. even if the precision is the same, not considering scale as a cast 
reason is still incorrect IMO
   
   Let me look into it. Thanks for the pointers.


-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to