DRILL-6472: Prevent using zero precision in CAST function
authorVolodymyr Vysotskyi <vvovyk@gmail.com>
Thu, 12 Jul 2018 16:00:48 +0000 (19:00 +0300)
committerArina Ielchiieva <arina.yelchiyeva@gmail.com>
Fri, 13 Jul 2018 12:54:57 +0000 (15:54 +0300)
commitc39ba74796d1f47887306ae81aa70ccf454effb3
tree425b4b67849ca95b211dd41ba358f4b8ac27fbb2
parenteb90ebdfd6e40fe1769bfedd320fabc1e57c723b
DRILL-6472: Prevent using zero precision in CAST function

- Add check for the correctness of scale value;
- Add check for fitting the value to the value with the concrete scale and precision;
- Implement negative UDF for VarDecimal
- Add unit tests for new checks and UDF.
14 files changed:
exec/java-exec/src/main/codegen/templates/Decimal/CastDecimalVarDecimal.java
exec/java-exec/src/main/codegen/templates/Decimal/CastFloatDecimal.java
exec/java-exec/src/main/codegen/templates/Decimal/CastIntDecimal.java
exec/java-exec/src/main/codegen/templates/Decimal/CastVarCharDecimal.java
exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
exec/java-exec/src/test/java/org/apache/drill/TestFunctionsQuery.java
exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java
exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestVarDecimalFunctions.java
exec/java-exec/src/test/resources/decimal/cast_decimal_int.json
exec/java-exec/src/test/resources/decimal/cast_decimal_vardecimal.json
exec/java-exec/src/test/resources/decimal/cast_int_decimal.json
exec/java-exec/src/test/resources/decimal/cast_vardecimal_decimal.json
exec/vector/src/main/java/org/apache/drill/exec/util/DecimalUtility.java