Skip to content

Commit

Permalink
[fix](nereids) change defaultConcreteType function's return value for…
Browse files Browse the repository at this point in the history
… decimal (apache#20380)

1. add default decimalv2 and decimalv3 for NullType
2. change defaultConcreteType of decimalv3 to this
  • Loading branch information
starocean999 authored Jun 5, 2023
1 parent 90a5be9 commit c638784
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public class Nvl extends ScalarFunction
FunctionSignature.ret(IntegerType.INSTANCE).args(IntegerType.INSTANCE, IntegerType.INSTANCE),
FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE, BigIntType.INSTANCE),
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE, LargeIntType.INSTANCE),
FunctionSignature.ret(FloatType.INSTANCE).args(FloatType.INSTANCE, FloatType.INSTANCE),
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE),
FunctionSignature.ret(FloatType.INSTANCE).args(FloatType.INSTANCE, FloatType.INSTANCE),
FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, DateType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, DateTimeType.INSTANCE),
FunctionSignature.ret(DateTimeType.INSTANCE).args(DateType.INSTANCE, DateTimeType.INSTANCE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class DecimalV2Type extends FractionalType {
.put(DoubleType.INSTANCE, DOUBLE_DECIMAL)
.put(TimeType.INSTANCE, DOUBLE_DECIMAL)
.put(TimeV2Type.INSTANCE, DOUBLE_DECIMAL)
.put(NullType.INSTANCE, BOOLEAN_DECIMAL)
.build();

private final int precision;
Expand Down Expand Up @@ -137,7 +138,7 @@ public int getScale() {

@Override
public DataType defaultConcreteType() {
return SYSTEM_DEFAULT;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class DecimalV3Type extends FractionalType {
.put(LargeIntType.INSTANCE, LARGEINT_DECIMAL)
.put(FloatType.INSTANCE, FLOAT_DECIMAL)
.put(DoubleType.INSTANCE, DOUBLE_DECIMAL)
.put(NullType.INSTANCE, BOOLEAN_DECIMAL)
.build();

protected final int precision;
Expand Down Expand Up @@ -146,7 +147,7 @@ public int getRange() {

@Override
public DataType defaultConcreteType() {
return SYSTEM_DEFAULT;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,38 +326,38 @@
-- !coalesce3 --
\N \N
1 123.123
2 1243.5
3 24453.324
4 243243.33
2 1243.500
3 24453.325
4 243243.325
5 243.325
6 604587.0
6 604587.000
7 3.141
8 -0.123
9 -654.654
10 -258.369
11 0.666
12 243.325
13 100.001
14 0.0
15 0.0
14 0.000
15 0.000

-- !coalesce4 --
\N \N
1 123.123
2 1243.5
3 24453.324
4 243243.33
2 1243.500
3 24453.325
4 243243.325
5 243.325
6 604587.0
6 604587.000
7 3.141
8 -0.123
9 -654.654
10 -258.369
11 0.666
12 243.325
13 100.001
14 0.0
15 0.0
14 0.000
15 0.000

-- !coalesce1 --
\N \N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,13 @@ null NULL null NULLL

-- !if_nullif23 --
123.123
1243.5
24453.324
1243.500
24453.325

-- !if_nullif24 --
123.123
1243.5
24453.324
1243.500
24453.325

-- !if_nullif23 --
false
Expand Down

0 comments on commit c638784

Please sign in to comment.