zstan commented on code in PR #2220:
URL: https://github.com/apache/ignite-3/pull/2220#discussion_r1245226285
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDataTypesTest.java:
##########
@@ -315,6 +335,252 @@ public void testDecimalLiteral() {
assertQuery("SELECT id FROM tbl WHERE val = DECIMAL
'10.20'").returns(1).check();
}
+
+ /** decimal casts - cast literal to decimal. */
+ @ParameterizedTest(name = "{2}:{1} AS {3} = {4}")
+ @MethodSource("decimalCastFromLiterals")
+ public void testDecimalCastsNumericLiterals(CaseStatus status, RelDataType
inputType, Object input,
+ RelDataType targetType, Result<BigDecimal> result) {
+
+ Assumptions.assumeTrue(status == CaseStatus.RUN);
+
+ String literal = asLiteral(input, inputType);
+ String query = format("SELECT CAST({} AS {})", literal, targetType);
+
+ QueryChecker checker = assertQuery(query);
+ expectResult(checker, result);
+ }
+
+ private static Stream<Arguments> decimalCastFromLiterals() {
+ RelDataType varcharType = varcharType();
+ // ignored
+ RelDataType numeric = decimalType(4);
+
+ return Stream.of(
+ // String
+ arguments(CaseStatus.RUN, varcharType, "100", decimalType(3),
bigDecimalVal("100")),
Review Comment:
can u add additional tests (or may be already exist and i miss smt?)
```
String query = format("SELECT CAST(? AS DECIMAL(5, 1))");
BigDecimal bd = new BigDecimal("12345");
sql(query).withParams(bd) <- failed
bd = new BigDecimal("1234");
sql(query).withParams(bd) <- correct
```
--
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]