[ https://issues.apache.org/jira/browse/IGNITE-22739?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pavel Pereslegin updated IGNITE-22739: -------------------------------------- Fix Version/s: 3.0.0-beta2 > Sql. Use modified version of the RexToLitTranslator > --------------------------------------------------- > > Key: IGNITE-22739 > URL: https://issues.apache.org/jira/browse/IGNITE-22739 > Project: Ignite > Issue Type: Improvement > Components: sql > Reporter: Maksim Zhuravkov > Assignee: Maksim Zhuravkov > Priority: Major > Labels: ignite-3 > Fix For: 3.0.0-beta2 > > Time Spent: 20m > Remaining Estimate: 0h > > AccumulatorsFactory use `RexToLitTranslator` from > `org.apache.ignite.internal.sql.engine.exec.exp` instead of the one provided > by calcite. Because the fixed version correctly handles cast overflows: > {noformat} > SELECT AVG(12345678::TINYINT) > {noformat} > Code generated by calcite: > {noformat} > inTypes: [TINYINT] // AVG argument cast > COMPILE > public Object apply(Object in) { > return Double.valueOf(org.apache.calcite.runtime.SqlFunctions.toByte(in)); > } > inType: DOUBLE, outType: TINYINT // AVG output cast > COMPILE > public Object apply(Object in) { > return (Double) in == null ? null : (Byte) > org.apache.calcite.linq4j.tree.Primitive.integerCast(org.apache.calcite.linq4j.tree.Primitive.BYTE, > ((Double) in).doubleValue()); > } > COMPILE > public void > execute(org.apache.ignite.internal.sql.engine.exec.ExecutionContext ctx, > Object in1, org.apache.ignite.internal.sql.engine.exec.RowHandler.RowBuilder > out) { > try { > > out.addField(org.apache.ignite.internal.sql.engine.util.IgniteMath.convertToByteExact(12345678)); > } catch (Exception e) { > throw new org.apache.ignite.sql.SqlException( > 262151, > e); > } > } > {noformat} > Code generated by the updated version of the RexToLitTranslator > {noformat} > inTypes: [TINYINT] > COMPILE > public Object apply(Object in) { > return Double.valueOf(org.apache.calcite.runtime.SqlFunctions.toByte(in)); > } > inType: DOUBLE, outType: TINYINT > COMPILE > public Object apply(Object in) { > return (Double) in == null ? null : > Byte.valueOf(org.apache.ignite.internal.sql.engine.util.IgniteMath.convertToByteExact(((Double) > in).doubleValue())); > } > COMPILE > public void > execute(org.apache.ignite.internal.sql.engine.exec.ExecutionContext ctx, > Object in1, org.apache.ignite.internal.sql.engine.exec.RowHandler.RowBuilder > out) { > try { > > out.addField(org.apache.ignite.internal.sql.engine.util.IgniteMath.convertToByteExact(12345678)); > } catch (Exception e) { > throw new org.apache.ignite.sql.SqlException( > 262151, > e); > } > } > {noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)