alex-plekhanov commented on code in PR #11644: URL: https://github.com/apache/ignite/pull/11644#discussion_r1829812592
########## modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/DataTypesTest.java: ########## @@ -43,6 +44,76 @@ * 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("DECIMAL(5,4)", BigDecimal.valueOf(1.4999d), "DECIMAL(2,1)", BigDecimal.valueOf(1.5))); + lst.add(F.asList("DECIMAL(5,4)", BigDecimal.valueOf(-1.4999d), "DECIMAL(2,1)", BigDecimal.valueOf(-1.5))); Review Comment: Should be outside of `for` loop. -- 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