diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/CastDecimalToFloat.java ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/CastDecimalToFloat.java new file mode 100644 index 0000000..4ef5422 --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/CastDecimalToFloat.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hive.ql.exec.vector.expressions; + +import org.apache.hadoop.hive.ql.exec.vector.DecimalColumnVector; +import org.apache.hadoop.hive.ql.exec.vector.DoubleColumnVector; + +/** + * Cast a decimal to float based on decimal to double function. + * + */ +public class CastDecimalToFloat extends FuncDecimalToDouble { + + private static final long serialVersionUID = 1L; + + public CastDecimalToFloat() { + super(); + } + + public CastDecimalToFloat(int inputCol, int outputColumnNum) { + super(inputCol, outputColumnNum); + } + + protected void func(DoubleColumnVector outV, DecimalColumnVector inV, int i) { + outV.vector[i] = inV.vector[i].floatValue(); + } +} diff --git ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToFloat.java ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToFloat.java index fd49d1f..2872ff2 100755 --- ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToFloat.java +++ ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToFloat.java @@ -20,7 +20,7 @@ import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.hive.ql.exec.vector.VectorizedExpressions; -import org.apache.hadoop.hive.ql.exec.vector.expressions.CastDecimalToDouble; +import org.apache.hadoop.hive.ql.exec.vector.expressions.CastDecimalToFloat; import org.apache.hadoop.hive.ql.exec.vector.expressions.CastStringToFloat; import org.apache.hadoop.hive.ql.exec.vector.expressions.gen.CastLongToFloatViaLongToDouble; import org.apache.hadoop.hive.ql.exec.vector.expressions.CastTimestampToDouble; @@ -42,7 +42,7 @@ * */ @VectorizedExpressions({CastTimestampToDouble.class, CastLongToFloatViaLongToDouble.class, - CastDecimalToDouble.class, CastStringToFloat.class}) + CastDecimalToFloat.class, CastStringToFloat.class}) public class UDFToFloat extends UDF { private final FloatWritable floatWritable = new FloatWritable(); diff --git ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorTypeCasts.java ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorTypeCasts.java index 6aa6da9..7f90f97 100644 --- ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorTypeCasts.java +++ ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorTypeCasts.java @@ -379,6 +379,54 @@ private VectorizedRowBatch getBatchDecimalDouble() { } @Test + public void testCastDecimalToFloat() { + + final double eps = 0.00000000000001d; // tolerance to check float equality + + double f1 = HiveDecimal.create("1.1").floatValue(); + double f2 = HiveDecimal.create("-2.2").floatValue(); + double f3 = HiveDecimal.create("9999999999999999.00").floatValue(); + + // test basic case + VectorizedRowBatch b = getBatchDecimalDouble(); + VectorExpression expr = new CastDecimalToFloat(0, 1); + expr.evaluate(b); + DoubleColumnVector r = (DoubleColumnVector) b.cols[1]; + assertEquals(f1, r.vector[0], eps); + assertEquals(f2, r.vector[1], eps); + assertEquals(f3, r.vector[2], eps); + + // test with nulls in input + b = getBatchDecimalDouble(); + b.cols[0].noNulls = false; + b.cols[0].isNull[1] = true; + expr.evaluate(b); + r = (DoubleColumnVector) b.cols[1]; + assertFalse(r.noNulls); + assertTrue(r.isNull[1]); + assertFalse(r.isNull[0]); + assertEquals(f1, r.vector[0], eps); + + // test repeating case + b = getBatchDecimalDouble(); + b.cols[0].isRepeating = true; + expr.evaluate(b); + r = (DoubleColumnVector) b.cols[1]; + assertTrue(r.isRepeating); + assertEquals(f1, r.vector[0], eps); + + // test repeating nulls case + b = getBatchDecimalDouble(); + b.cols[0].isRepeating = true; + b.cols[0].noNulls = false; + b.cols[0].isNull[0] = true; + expr.evaluate(b); + r = (DoubleColumnVector) b.cols[1]; + assertTrue(r.isRepeating); + assertTrue(r.isNull[0]); + } + + @Test public void testCastDecimalToString() throws HiveException { VectorizedRowBatch b = getBatchDecimalString(); VectorExpression expr = new CastDecimalToString(0, 1); diff --git ql/src/test/queries/clientpositive/vectorization_parquet_ppd_decimal.q ql/src/test/queries/clientpositive/vectorization_parquet_ppd_decimal.q new file mode 100644 index 0000000..006caac --- /dev/null +++ ql/src/test/queries/clientpositive/vectorization_parquet_ppd_decimal.q @@ -0,0 +1,165 @@ +SET hive.vectorized.execution.enabled=true; +SET hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat; +SET mapred.min.split.size=1000; +SET mapred.max.split.size=5000; +set hive.llap.cache.allow.synthetic.fileid=true; + +create table newtypestbl(c char(10), v varchar(10), d decimal(5,3), da date) stored as parquet; + +insert overwrite table newtypestbl select * from (select cast("apple" as char(10)), cast("bee" as varchar(10)), 0.22, cast("1970-02-20" as date) from src src1 union all select cast("hello" as char(10)), cast("world" as varchar(10)), 11.22, cast("1970-02-27" as date) from src src2 limit 10) uniontbl; + +-- decimal data types (EQUAL, NOT_EQUAL, LESS_THAN, LESS_THAN_EQUALS, IN, BETWEEN tests) +select * from newtypestbl where d=0.22; + +set hive.optimize.index.filter=true; +select * from newtypestbl where d=0.22; + +set hive.optimize.index.filter=false; +select * from newtypestbl where d='0.22'; + +set hive.optimize.index.filter=true; +select * from newtypestbl where d='0.22'; + +set hive.optimize.index.filter=false; +select * from newtypestbl where d=cast('0.22' as float); + +set hive.optimize.index.filter=true; +select * from newtypestbl where d=cast('0.22' as float); + +set hive.optimize.index.filter=false; +select * from newtypestbl where d!=0.22; + +set hive.optimize.index.filter=true; +select * from newtypestbl where d!=0.22; + +set hive.optimize.index.filter=false; +select * from newtypestbl where d!='0.22'; + +set hive.optimize.index.filter=true; +select * from newtypestbl where d!='0.22'; + +set hive.optimize.index.filter=false; +select * from newtypestbl where d!=cast('0.22' as float); + +set hive.optimize.index.filter=true; +select * from newtypestbl where d!=cast('0.22' as float); + +set hive.optimize.index.filter=false; +select * from newtypestbl where d<11.22; + +set hive.optimize.index.filter=true; +select * from newtypestbl where d<11.22; + +set hive.optimize.index.filter=false; +select * from newtypestbl where d<'11.22'; + +set hive.optimize.index.filter=true; +select * from newtypestbl where d<'11.22'; + +set hive.optimize.index.filter=false; +select * from newtypestbl where d 4:float + selectExpressions: CastDecimalToFloat(col 0:decimal(4,2)) -> 4:float Statistics: Num rows: 2 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE Reduce Output Operator key expressions: _col0 (type: float) diff --git ql/src/test/results/clientpositive/llap/vector_decimal_2.q.out ql/src/test/results/clientpositive/llap/vector_decimal_2.q.out index ca13c06..bd9ee98 100644 --- ql/src/test/results/clientpositive/llap/vector_decimal_2.q.out +++ ql/src/test/results/clientpositive/llap/vector_decimal_2.q.out @@ -638,7 +638,7 @@ STAGE PLANS: className: VectorSelectOperator native: true projectedOutputColumnNums: [2] - selectExpressions: CastDecimalToDouble(col 0:decimal(18,9)) -> 2:float + selectExpressions: CastDecimalToFloat(col 0:decimal(18,9)) -> 2:float Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE Reduce Output Operator key expressions: _col0 (type: float) @@ -1577,7 +1577,7 @@ STAGE PLANS: className: VectorSelectOperator native: true projectedOutputColumnNums: [2] - selectExpressions: CastDecimalToDouble(col 0:decimal(18,9)) -> 2:float + selectExpressions: CastDecimalToFloat(col 0:decimal(18,9)) -> 2:float Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE Reduce Output Operator key expressions: _col0 (type: float) diff --git ql/src/test/results/clientpositive/llap/vector_decimal_expressions.q.out ql/src/test/results/clientpositive/llap/vector_decimal_expressions.q.out index 7dbe584..47f4414 100644 --- ql/src/test/results/clientpositive/llap/vector_decimal_expressions.q.out +++ ql/src/test/results/clientpositive/llap/vector_decimal_expressions.q.out @@ -76,7 +76,7 @@ STAGE PLANS: className: VectorSelectOperator native: true projectedOutputColumnNums: [4, 6, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] - selectExpressions: DecimalColAddDecimalColumn(col 1:decimal(20,10), col 2:decimal(23,14)) -> 4:decimal(25,14), DecimalColSubtractDecimalColumn(col 1:decimal(20,10), col 5:decimal(25,14))(children: DecimalScalarMultiplyDecimalColumn(val 2, col 2:decimal(23,14)) -> 5:decimal(25,14)) -> 6:decimal(26,14), DecimalColDivideDecimalColumn(col 7:decimal(21,10), col 2:decimal(23,14))(children: DecimalColAddDecimalScalar(col 1:decimal(20,10), val 2.34) -> 7:decimal(21,10)) -> 8:decimal(38,13), DecimalColMultiplyDecimalColumn(col 1:decimal(20,10), col 9:decimal(27,17))(children: DecimalColDivideDecimalScalar(col 2:decimal(23,14), val 3.4) -> 9:decimal(27,17)) -> 10:decimal(38,17), DecimalColModuloDecimalScalar(col 1:decimal(20,10), val 10) -> 11:decimal(12,10), CastDecimalToLong(col 1:decimal(20,10)) -> 12:int, CastDecimalToLong(col 2:decimal(23,14)) -> 13:smallint, CastDecimalToLong(col 2:decimal(23,14)) -> 14:tinyint, CastDecimalToLong(col 1:decimal(20,10)) -> 15:bigint, CastDecimalToBoolean(col 1:decimal(20,10)) -> 16:boolean, CastDecimalToDouble(col 2:decimal(23,14)) -> 17:double, CastDecimalToDouble(col 1:decimal(20,10)) -> 18:float, CastDecimalToString(col 2:decimal(23,14)) -> 19:string, CastDecimalToTimestamp(col 1:decimal(20,10)) -> 20:timestamp + selectExpressions: DecimalColAddDecimalColumn(col 1:decimal(20,10), col 2:decimal(23,14)) -> 4:decimal(25,14), DecimalColSubtractDecimalColumn(col 1:decimal(20,10), col 5:decimal(25,14))(children: DecimalScalarMultiplyDecimalColumn(val 2, col 2:decimal(23,14)) -> 5:decimal(25,14)) -> 6:decimal(26,14), DecimalColDivideDecimalColumn(col 7:decimal(21,10), col 2:decimal(23,14))(children: DecimalColAddDecimalScalar(col 1:decimal(20,10), val 2.34) -> 7:decimal(21,10)) -> 8:decimal(38,13), DecimalColMultiplyDecimalColumn(col 1:decimal(20,10), col 9:decimal(27,17))(children: DecimalColDivideDecimalScalar(col 2:decimal(23,14), val 3.4) -> 9:decimal(27,17)) -> 10:decimal(38,17), DecimalColModuloDecimalScalar(col 1:decimal(20,10), val 10) -> 11:decimal(12,10), CastDecimalToLong(col 1:decimal(20,10)) -> 12:int, CastDecimalToLong(col 2:decimal(23,14)) -> 13:smallint, CastDecimalToLong(col 2:decimal(23,14)) -> 14:tinyint, CastDecimalToLong(col 1:decimal(20,10)) -> 15:bigint, CastDecimalToBoolean(col 1:decimal(20,10)) -> 16:boolean, CastDecimalToDouble(col 2:decimal(23,14)) -> 17:double, CastDecimalToFloat(col 1:decimal(20,10)) -> 18:float, CastDecimalToString(col 2:decimal(23,14)) -> 19:string, CastDecimalToTimestamp(col 1:decimal(20,10)) -> 20:timestamp Statistics: Num rows: 455 Data size: 100294 Basic stats: COMPLETE Column stats: NONE Reduce Output Operator key expressions: _col0 (type: decimal(25,14)), _col1 (type: decimal(26,14)), _col2 (type: decimal(38,13)), _col3 (type: decimal(38,17)), _col4 (type: decimal(12,10)), _col5 (type: int), _col6 (type: smallint), _col7 (type: tinyint), _col8 (type: bigint), _col9 (type: boolean), _col10 (type: double), _col11 (type: float), _col12 (type: string), _col13 (type: timestamp) @@ -249,7 +249,7 @@ STAGE PLANS: className: VectorSelectOperator native: true projectedOutputColumnNums: [4, 6, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] - selectExpressions: DecimalColAddDecimalColumn(col 1:decimal(10,3), col 2:decimal(7,2)) -> 4:decimal(11,3), DecimalColSubtractDecimalColumn(col 1:decimal(10,3), col 5:decimal(9,2))(children: DecimalScalarMultiplyDecimalColumn(val 2, col 2:decimal(7,2)) -> 5:decimal(9,2)) -> 6:decimal(11,3), DecimalColDivideDecimalColumn(col 7:decimal(11,3), col 2:decimal(7,2))(children: DecimalColAddDecimalScalar(col 1:decimal(10,3), val 2.34) -> 7:decimal(11,3)) -> 8:decimal(21,11), DecimalColMultiplyDecimalColumn(col 1:decimal(10,3), col 9:decimal(12,6))(children: DecimalColDivideDecimalScalar(col 2:decimal(7,2), val 3.4) -> 9:decimal(12,6)) -> 10:decimal(23,9), DecimalColModuloDecimalScalar(col 1:decimal(10,3), val 10) -> 11:decimal(5,3), CastDecimalToLong(col 1:decimal(10,3)) -> 12:int, CastDecimalToLong(col 2:decimal(7,2)) -> 13:smallint, CastDecimalToLong(col 2:decimal(7,2)) -> 14:tinyint, CastDecimalToLong(col 1:decimal(10,3)) -> 15:bigint, CastDecimalToBoolean(col 1:decimal(10,3)) -> 16:boolean, CastDecimalToDouble(col 2:decimal(7,2)) -> 17:double, CastDecimalToDouble(col 1:decimal(10,3)) -> 18:float, CastDecimalToString(col 2:decimal(7,2)) -> 19:string, CastDecimalToTimestamp(col 1:decimal(10,3)) -> 20:timestamp + selectExpressions: DecimalColAddDecimalColumn(col 1:decimal(10,3), col 2:decimal(7,2)) -> 4:decimal(11,3), DecimalColSubtractDecimalColumn(col 1:decimal(10,3), col 5:decimal(9,2))(children: DecimalScalarMultiplyDecimalColumn(val 2, col 2:decimal(7,2)) -> 5:decimal(9,2)) -> 6:decimal(11,3), DecimalColDivideDecimalColumn(col 7:decimal(11,3), col 2:decimal(7,2))(children: DecimalColAddDecimalScalar(col 1:decimal(10,3), val 2.34) -> 7:decimal(11,3)) -> 8:decimal(21,11), DecimalColMultiplyDecimalColumn(col 1:decimal(10,3), col 9:decimal(12,6))(children: DecimalColDivideDecimalScalar(col 2:decimal(7,2), val 3.4) -> 9:decimal(12,6)) -> 10:decimal(23,9), DecimalColModuloDecimalScalar(col 1:decimal(10,3), val 10) -> 11:decimal(5,3), CastDecimalToLong(col 1:decimal(10,3)) -> 12:int, CastDecimalToLong(col 2:decimal(7,2)) -> 13:smallint, CastDecimalToLong(col 2:decimal(7,2)) -> 14:tinyint, CastDecimalToLong(col 1:decimal(10,3)) -> 15:bigint, CastDecimalToBoolean(col 1:decimal(10,3)) -> 16:boolean, CastDecimalToDouble(col 2:decimal(7,2)) -> 17:double, CastDecimalToFloat(col 1:decimal(10,3)) -> 18:float, CastDecimalToString(col 2:decimal(7,2)) -> 19:string, CastDecimalToTimestamp(col 1:decimal(10,3)) -> 20:timestamp Statistics: Num rows: 455 Data size: 100294 Basic stats: COMPLETE Column stats: NONE Reduce Output Operator key expressions: _col0 (type: decimal(11,3)), _col1 (type: decimal(11,3)), _col2 (type: decimal(21,11)), _col3 (type: decimal(23,9)), _col4 (type: decimal(5,3)), _col5 (type: int), _col6 (type: smallint), _col7 (type: tinyint), _col8 (type: bigint), _col9 (type: boolean), _col10 (type: double), _col11 (type: float), _col12 (type: string), _col13 (type: timestamp) diff --git ql/src/test/results/clientpositive/vector_decimal_1.q.out ql/src/test/results/clientpositive/vector_decimal_1.q.out index ffd32f6..25da3a2 100644 --- ql/src/test/results/clientpositive/vector_decimal_1.q.out +++ ql/src/test/results/clientpositive/vector_decimal_1.q.out @@ -529,7 +529,7 @@ STAGE PLANS: className: VectorSelectOperator native: true projectedOutputColumnNums: [4] - selectExpressions: CastDecimalToDouble(col 0:decimal(4,2)) -> 4:float + selectExpressions: CastDecimalToFloat(col 0:decimal(4,2)) -> 4:float Statistics: Num rows: 2 Data size: 336 Basic stats: COMPLETE Column stats: NONE Reduce Output Operator key expressions: _col0 (type: float) diff --git ql/src/test/results/clientpositive/vector_decimal_expressions.q.out ql/src/test/results/clientpositive/vector_decimal_expressions.q.out index 6bbe813..8692ccb 100644 --- ql/src/test/results/clientpositive/vector_decimal_expressions.q.out +++ ql/src/test/results/clientpositive/vector_decimal_expressions.q.out @@ -70,7 +70,7 @@ STAGE PLANS: className: VectorSelectOperator native: true projectedOutputColumnNums: [4, 6, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] - selectExpressions: DecimalColAddDecimalColumn(col 1:decimal(20,10), col 2:decimal(23,14)) -> 4:decimal(25,14), DecimalColSubtractDecimalColumn(col 1:decimal(20,10), col 5:decimal(25,14))(children: DecimalScalarMultiplyDecimalColumn(val 2, col 2:decimal(23,14)) -> 5:decimal(25,14)) -> 6:decimal(26,14), DecimalColDivideDecimalColumn(col 7:decimal(21,10), col 2:decimal(23,14))(children: DecimalColAddDecimalScalar(col 1:decimal(20,10), val 2.34) -> 7:decimal(21,10)) -> 8:decimal(38,13), DecimalColMultiplyDecimalColumn(col 1:decimal(20,10), col 9:decimal(27,17))(children: DecimalColDivideDecimalScalar(col 2:decimal(23,14), val 3.4) -> 9:decimal(27,17)) -> 10:decimal(38,17), DecimalColModuloDecimalScalar(col 1:decimal(20,10), val 10) -> 11:decimal(12,10), CastDecimalToLong(col 1:decimal(20,10)) -> 12:int, CastDecimalToLong(col 2:decimal(23,14)) -> 13:smallint, CastDecimalToLong(col 2:decimal(23,14)) -> 14:tinyint, CastDecimalToLong(col 1:decimal(20,10)) -> 15:bigint, CastDecimalToBoolean(col 1:decimal(20,10)) -> 16:boolean, CastDecimalToDouble(col 2:decimal(23,14)) -> 17:double, CastDecimalToDouble(col 1:decimal(20,10)) -> 18:float, CastDecimalToString(col 2:decimal(23,14)) -> 19:string, CastDecimalToTimestamp(col 1:decimal(20,10)) -> 20:timestamp + selectExpressions: DecimalColAddDecimalColumn(col 1:decimal(20,10), col 2:decimal(23,14)) -> 4:decimal(25,14), DecimalColSubtractDecimalColumn(col 1:decimal(20,10), col 5:decimal(25,14))(children: DecimalScalarMultiplyDecimalColumn(val 2, col 2:decimal(23,14)) -> 5:decimal(25,14)) -> 6:decimal(26,14), DecimalColDivideDecimalColumn(col 7:decimal(21,10), col 2:decimal(23,14))(children: DecimalColAddDecimalScalar(col 1:decimal(20,10), val 2.34) -> 7:decimal(21,10)) -> 8:decimal(38,13), DecimalColMultiplyDecimalColumn(col 1:decimal(20,10), col 9:decimal(27,17))(children: DecimalColDivideDecimalScalar(col 2:decimal(23,14), val 3.4) -> 9:decimal(27,17)) -> 10:decimal(38,17), DecimalColModuloDecimalScalar(col 1:decimal(20,10), val 10) -> 11:decimal(12,10), CastDecimalToLong(col 1:decimal(20,10)) -> 12:int, CastDecimalToLong(col 2:decimal(23,14)) -> 13:smallint, CastDecimalToLong(col 2:decimal(23,14)) -> 14:tinyint, CastDecimalToLong(col 1:decimal(20,10)) -> 15:bigint, CastDecimalToBoolean(col 1:decimal(20,10)) -> 16:boolean, CastDecimalToDouble(col 2:decimal(23,14)) -> 17:double, CastDecimalToFloat(col 1:decimal(20,10)) -> 18:float, CastDecimalToString(col 2:decimal(23,14)) -> 19:string, CastDecimalToTimestamp(col 1:decimal(20,10)) -> 20:timestamp Statistics: Num rows: 455 Data size: 78802 Basic stats: COMPLETE Column stats: NONE Reduce Output Operator key expressions: _col0 (type: decimal(25,14)), _col1 (type: decimal(26,14)), _col2 (type: decimal(38,13)), _col3 (type: decimal(38,17)), _col4 (type: decimal(12,10)), _col5 (type: int), _col6 (type: smallint), _col7 (type: tinyint), _col8 (type: bigint), _col9 (type: boolean), _col10 (type: double), _col11 (type: float), _col12 (type: string), _col13 (type: timestamp) @@ -214,7 +214,7 @@ STAGE PLANS: className: VectorSelectOperator native: true projectedOutputColumnNums: [4, 6, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] - selectExpressions: DecimalColAddDecimalColumn(col 1:decimal(10,3), col 2:decimal(7,2)) -> 4:decimal(11,3), DecimalColSubtractDecimalColumn(col 1:decimal(10,3), col 5:decimal(9,2))(children: DecimalScalarMultiplyDecimalColumn(val 2, col 2:decimal(7,2)) -> 5:decimal(9,2)) -> 6:decimal(11,3), DecimalColDivideDecimalColumn(col 7:decimal(11,3), col 2:decimal(7,2))(children: DecimalColAddDecimalScalar(col 1:decimal(10,3), val 2.34) -> 7:decimal(11,3)) -> 8:decimal(21,11), DecimalColMultiplyDecimalColumn(col 1:decimal(10,3), col 9:decimal(12,6))(children: DecimalColDivideDecimalScalar(col 2:decimal(7,2), val 3.4) -> 9:decimal(12,6)) -> 10:decimal(23,9), DecimalColModuloDecimalScalar(col 1:decimal(10,3), val 10) -> 11:decimal(5,3), CastDecimalToLong(col 1:decimal(10,3)) -> 12:int, CastDecimalToLong(col 2:decimal(7,2)) -> 13:smallint, CastDecimalToLong(col 2:decimal(7,2)) -> 14:tinyint, CastDecimalToLong(col 1:decimal(10,3)) -> 15:bigint, CastDecimalToBoolean(col 1:decimal(10,3)) -> 16:boolean, CastDecimalToDouble(col 2:decimal(7,2)) -> 17:double, CastDecimalToDouble(col 1:decimal(10,3)) -> 18:float, CastDecimalToString(col 2:decimal(7,2)) -> 19:string, CastDecimalToTimestamp(col 1:decimal(10,3)) -> 20:timestamp + selectExpressions: DecimalColAddDecimalColumn(col 1:decimal(10,3), col 2:decimal(7,2)) -> 4:decimal(11,3), DecimalColSubtractDecimalColumn(col 1:decimal(10,3), col 5:decimal(9,2))(children: DecimalScalarMultiplyDecimalColumn(val 2, col 2:decimal(7,2)) -> 5:decimal(9,2)) -> 6:decimal(11,3), DecimalColDivideDecimalColumn(col 7:decimal(11,3), col 2:decimal(7,2))(children: DecimalColAddDecimalScalar(col 1:decimal(10,3), val 2.34) -> 7:decimal(11,3)) -> 8:decimal(21,11), DecimalColMultiplyDecimalColumn(col 1:decimal(10,3), col 9:decimal(12,6))(children: DecimalColDivideDecimalScalar(col 2:decimal(7,2), val 3.4) -> 9:decimal(12,6)) -> 10:decimal(23,9), DecimalColModuloDecimalScalar(col 1:decimal(10,3), val 10) -> 11:decimal(5,3), CastDecimalToLong(col 1:decimal(10,3)) -> 12:int, CastDecimalToLong(col 2:decimal(7,2)) -> 13:smallint, CastDecimalToLong(col 2:decimal(7,2)) -> 14:tinyint, CastDecimalToLong(col 1:decimal(10,3)) -> 15:bigint, CastDecimalToBoolean(col 1:decimal(10,3)) -> 16:boolean, CastDecimalToDouble(col 2:decimal(7,2)) -> 17:double, CastDecimalToFloat(col 1:decimal(10,3)) -> 18:float, CastDecimalToString(col 2:decimal(7,2)) -> 19:string, CastDecimalToTimestamp(col 1:decimal(10,3)) -> 20:timestamp Statistics: Num rows: 455 Data size: 78788 Basic stats: COMPLETE Column stats: NONE Reduce Output Operator key expressions: _col0 (type: decimal(11,3)), _col1 (type: decimal(11,3)), _col2 (type: decimal(21,11)), _col3 (type: decimal(23,9)), _col4 (type: decimal(5,3)), _col5 (type: int), _col6 (type: smallint), _col7 (type: tinyint), _col8 (type: bigint), _col9 (type: boolean), _col10 (type: double), _col11 (type: float), _col12 (type: string), _col13 (type: timestamp) diff --git ql/src/test/results/clientpositive/vectorization_parquet_ppd_decimal.q.out ql/src/test/results/clientpositive/vectorization_parquet_ppd_decimal.q.out new file mode 100644 index 0000000..c2611fc --- /dev/null +++ ql/src/test/results/clientpositive/vectorization_parquet_ppd_decimal.q.out @@ -0,0 +1,766 @@ +PREHOOK: query: create table newtypestbl(c char(10), v varchar(10), d decimal(5,3), da date) stored as parquet +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +PREHOOK: Output: default@newtypestbl +POSTHOOK: query: create table newtypestbl(c char(10), v varchar(10), d decimal(5,3), da date) stored as parquet +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@newtypestbl +PREHOOK: query: insert overwrite table newtypestbl select * from (select cast("apple" as char(10)), cast("bee" as varchar(10)), 0.22, cast("1970-02-20" as date) from src src1 union all select cast("hello" as char(10)), cast("world" as varchar(10)), 11.22, cast("1970-02-27" as date) from src src2 limit 10) uniontbl +PREHOOK: type: QUERY +PREHOOK: Input: default@src +PREHOOK: Output: default@newtypestbl +POSTHOOK: query: insert overwrite table newtypestbl select * from (select cast("apple" as char(10)), cast("bee" as varchar(10)), 0.22, cast("1970-02-20" as date) from src src1 union all select cast("hello" as char(10)), cast("world" as varchar(10)), 11.22, cast("1970-02-27" as date) from src src2 limit 10) uniontbl +POSTHOOK: type: QUERY +POSTHOOK: Input: default@src +POSTHOOK: Output: default@newtypestbl +POSTHOOK: Lineage: newtypestbl.c EXPRESSION [] +POSTHOOK: Lineage: newtypestbl.d EXPRESSION [] +POSTHOOK: Lineage: newtypestbl.da EXPRESSION [] +POSTHOOK: Lineage: newtypestbl.v EXPRESSION [] +PREHOOK: query: select * from newtypestbl where d=0.22 +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d=0.22 +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +PREHOOK: query: select * from newtypestbl where d=0.22 +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d=0.22 +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +PREHOOK: query: select * from newtypestbl where d='0.22' +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d='0.22' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +PREHOOK: query: select * from newtypestbl where d='0.22' +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d='0.22' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +PREHOOK: query: select * from newtypestbl where d=cast('0.22' as float) +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d=cast('0.22' as float) +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +PREHOOK: query: select * from newtypestbl where d=cast('0.22' as float) +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d=cast('0.22' as float) +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +PREHOOK: query: select * from newtypestbl where d!=0.22 +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d!=0.22 +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +PREHOOK: query: select * from newtypestbl where d!=0.22 +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d!=0.22 +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +PREHOOK: query: select * from newtypestbl where d!='0.22' +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d!='0.22' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +PREHOOK: query: select * from newtypestbl where d!='0.22' +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d!='0.22' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +PREHOOK: query: select * from newtypestbl where d!=cast('0.22' as float) +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d!=cast('0.22' as float) +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +PREHOOK: query: select * from newtypestbl where d!=cast('0.22' as float) +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d!=cast('0.22' as float) +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +hello world 11.220 1970-02-27 +PREHOOK: query: select * from newtypestbl where d<11.22 +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d<11.22 +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +PREHOOK: query: select * from newtypestbl where d<11.22 +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d<11.22 +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +PREHOOK: query: select * from newtypestbl where d<'11.22' +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d<'11.22' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +PREHOOK: query: select * from newtypestbl where d<'11.22' +PREHOOK: type: QUERY +PREHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +POSTHOOK: query: select * from newtypestbl where d<'11.22' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@newtypestbl +#### A masked pattern was here #### +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +apple bee 0.220 1970-02-20 +PREHOOK: query: select * from newtypestbl where d