caicancai commented on code in PR #3919:
URL: https://github.com/apache/calcite/pull/3919#discussion_r1720868477
##########
core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystem.java:
##########
@@ -297,6 +297,7 @@ default boolean
shouldUseDoubleMultiplication(RelDataTypeFactory typeFactory,
int six = Math.min(6, getMaxNumericScale());
int d = p1 - s1 + s2;
int scale = Math.max(six, s1 + p2 + 1);
+ scale = Math.min(scale, getMaxNumericScale());
Review Comment:
I don't quite understand the rules, but I see some paradoxes.
Assume the following scenario.
```
six = Math.min(6, getMaxNumericScale()) = getMaxNumericScale()
scale = Math.max(six, s1 + p2 + 1) = six = getMaxNumericScale()
scale = Math.min(scale, getMaxNumericScale()) = getMaxNumericScale()
```
Is this a repeated judgment?
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -2661,6 +2663,19 @@ void checkModOperatorDivByZero(SqlOperatorFixture f) {
f.checkNull("1e1 / cast(null as float)");
f.checkScalarExact("100.1 / 0.00000000000000001", "DECIMAL(19, 6) NOT
NULL",
"1.001E+19");
+ SqlOperatorFixture f0 = f.withFactory(tf ->
+ tf.withTypeSystem(typeSystem ->
+ new DelegatingTypeSystem(typeSystem) {
+ @Override public int getMaxNumericPrecision() {
+ return 28;
+ }
+
+ @Override public int getMaxNumericScale() {
+ return 10;
+ }
+ }));
+ f0.checkScalarExact("95.0 / 100", "DECIMAL(12, 10) NOT NULL", "0.95");
+ f0.checkScalarExact("95 / 100.0", "DECIMAL(17, 6) NOT NULL", "0.95");
Review Comment:
Maybe adding another test would be better such as` 95/100`
--
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]