Vladsz83 commented on code in PR #11635: URL: https://github.com/apache/ignite/pull/11635#discussion_r1829819044
########## modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DataTypesTest.java: ########## @@ -43,6 +44,74 @@ * Test SQL data types. */ public class DataTypesTest extends AbstractBasicIntegrationTransactionalTest { + /** */ + @Test + public void testRoundingOfNumerics() { + doTestCoercionOfNumerics(numericsToRound(), false, false); + } + + /** */ + @Test + public void testRoundingOfNumericsPrecasted() { + doTestCoercionOfNumerics(numericsToRound(), false, true); + } + + /** */ + @Test + public void testRoundingOfDynamicNumerics() { + doTestCoercionOfNumerics(numericsToRound(), true, false); + } + + /** */ + @Test + public void testRoundingOfDynamicNumericsPrecasted() { + doTestCoercionOfNumerics(numericsToRound(), true, true); + } + + /** @return input type, input value, target type, expected result. */ + private static List<List<Object>> numericsToRound() { + List<List<Object>> lst = new ArrayList<>(50); + + lst.add(F.asList("DECIMAL(5,4)", BigDecimal.valueOf(1.4999d), "DECIMAL(1)", new BigDecimal(1))); + lst.add(F.asList("DECIMAL(5,4)", BigDecimal.valueOf(-1.4999d), "DECIMAL(1)", new BigDecimal(-1))); + lst.add(F.asList("DECIMAL(2,1)", BigDecimal.valueOf(1.5d), "DECIMAL(1)", new BigDecimal(2))); + lst.add(F.asList("DECIMAL(2,1)", BigDecimal.valueOf(-1.5d), "DECIMAL(1)", new BigDecimal(-2))); + + for (String numTypeName : F.asList("DOUBLE", "FLOAT")) { + lst.add(F.asList(numTypeName, floatingVal(1.4999f, numTypeName), "DECIMAL(1)", new BigDecimal(1))); + lst.add(F.asList(numTypeName, floatingVal(-1.4999f, numTypeName), "DECIMAL(1)", new BigDecimal(-1))); + lst.add(F.asList(numTypeName, floatingVal(1.5f, numTypeName), "DECIMAL(1)", new BigDecimal(2))); + lst.add(F.asList(numTypeName, floatingVal(-1.5f, numTypeName), "DECIMAL(1)", new BigDecimal(-2))); + + lst.add(F.asList(numTypeName, floatingVal(1.4999f, numTypeName), "BIGINT", 1L)); + lst.add(F.asList(numTypeName, floatingVal(-1.4999f, numTypeName), "BIGINT", -1L)); + lst.add(F.asList(numTypeName, floatingVal(1.5f, numTypeName), "BIGINT", 2L)); + lst.add(F.asList(numTypeName, floatingVal(-1.5f, numTypeName), "BIGINT", -2L)); + + lst.add(F.asList(numTypeName, floatingVal(1.4999f, numTypeName), "INT", 1)); + lst.add(F.asList(numTypeName, floatingVal(-1.4999f, numTypeName), "INT", -1)); + lst.add(F.asList(numTypeName, floatingVal(1.5f, numTypeName), "INT", 2)); + lst.add(F.asList(numTypeName, floatingVal(-1.5f, numTypeName), "INT", -2)); + + lst.add(F.asList(numTypeName, floatingVal(1.4999f, numTypeName), "SMALLINT", (short)1)); + lst.add(F.asList(numTypeName, floatingVal(-1.4999f, numTypeName), "SMALLINT", (short)-1)); + lst.add(F.asList(numTypeName, floatingVal(1.5f, numTypeName), "SMALLINT", (short)2)); + lst.add(F.asList(numTypeName, floatingVal(-1.5f, numTypeName), "SMALLINT", (short)-2)); + + lst.add(F.asList(numTypeName, floatingVal(1.4999f, numTypeName), "TINYINT", (byte)1)); + lst.add(F.asList(numTypeName, floatingVal(-1.4999f, numTypeName), "TINYINT", (byte)-1)); + lst.add(F.asList(numTypeName, floatingVal(1.5f, numTypeName), "TINYINT", (byte)2)); + lst.add(F.asList(numTypeName, floatingVal(-1.5f, numTypeName), "TINYINT", (byte)-2)); Review Comment: Fixed -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org