diff --git ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPEqualNS.java ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPEqualNS.java index cd339c004a..585a22539b 100644 --- ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPEqualNS.java +++ ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPEqualNS.java @@ -21,11 +21,16 @@ import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.metadata.HiveException; -@Description(name = "<=>", value = "a _FUNC_ b - Returns same result with EQUAL(=) operator " + - "for non-null operands, but returns TRUE if both are NULL, FALSE if one of the them is NULL") +@Description(name = "IS NOT DISTINCT FROM", value = "a _FUNC_ b - Returns same result with EQUALNS (IS NOT DISTINCT " + + "FROM) operator for non-null operands, but returns TRUE if both are NULL, FALSE if one of the them is NULL") @NDV(maxNdv = 2) public class GenericUDFOPEqualNS extends GenericUDFOPEqual { + public GenericUDFOPEqualNS(){ + this.opName = "EQUALNS"; + this.opDisplayName = "IS NOT DISTINCT FROM"; + } + @Override public Object evaluate(DeferredObject[] arguments) throws HiveException { Object o0 = arguments[0].get(); @@ -43,6 +48,6 @@ public Object evaluate(DeferredObject[] arguments) throws HiveException { @Override public GenericUDF negative() { - return new GenericUDFOPNotEqualNS(); + return new GenericUDFOPNotEqualNS(); } } diff --git ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPNotEqualNS.java ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPNotEqualNS.java index d48bbbbce3..f4b5e8f547 100644 --- ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPNotEqualNS.java +++ ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPNotEqualNS.java @@ -18,11 +18,19 @@ package org.apache.hadoop.hive.ql.udf.generic; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.metadata.HiveException; // this function is for internal use only public class GenericUDFOPNotEqualNS extends GenericUDFOPNotEqual { + @Description(name = "IS DISTINCT FROM", value = "a _FUNC_ b - Returns same result with NOTEQUALNS (IS DISTINCT " + + "FROM) operator for non-null operands, but returns FALSE if both are NULL, TRUE if one of the them is NULL") + public GenericUDFOPNotEqualNS(){ + this.opName = "NOTEQUALNS"; + this.opDisplayName = "IS DISTINCT FROM"; + } + @Override public Object evaluate(DeferredObject[] arguments) throws HiveException { Object o0 = arguments[0].get(); @@ -40,6 +48,6 @@ public Object evaluate(DeferredObject[] arguments) throws HiveException { @Override public GenericUDF negative() { - return new GenericUDFOPEqualNS(); + return new GenericUDFOPEqualNS(); } } diff --git ql/src/test/results/clientpositive/filter_cond_pushdown_HIVE_15647.q.out ql/src/test/results/clientpositive/filter_cond_pushdown_HIVE_15647.q.out index bc023a6eb0..424fc712ec 100644 --- ql/src/test/results/clientpositive/filter_cond_pushdown_HIVE_15647.q.out +++ ql/src/test/results/clientpositive/filter_cond_pushdown_HIVE_15647.q.out @@ -41,10 +41,10 @@ STAGE PLANS: Map Operator Tree: TableScan alias: sales - filterExpr: ((store_number = customer_id) and store_id is not null) (type: boolean) + filterExpr: ((store_number IS NOT DISTINCT FROM customer_id) and store_id is not null) (type: boolean) Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE Filter Operator - predicate: ((store_number = customer_id) and store_id is not null) (type: boolean) + predicate: ((store_number IS NOT DISTINCT FROM customer_id) and store_id is not null) (type: boolean) Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE Reduce Output Operator key expressions: store_id (type: int) @@ -237,10 +237,10 @@ STAGE PLANS: Map Operator Tree: TableScan alias: sales - filterExpr: ((store_number = customer_id) and store_id is not null) (type: boolean) + filterExpr: ((store_number IS NOT DISTINCT FROM customer_id) and store_id is not null) (type: boolean) Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE Filter Operator - predicate: ((store_number = customer_id) and store_id is not null) (type: boolean) + predicate: ((store_number IS NOT DISTINCT FROM customer_id) and store_id is not null) (type: boolean) Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: NONE Reduce Output Operator key expressions: store_id (type: int) diff --git ql/src/test/results/clientpositive/llap/is_distinct_from.q.out ql/src/test/results/clientpositive/llap/is_distinct_from.q.out index 010c4a15f8..fa581f768e 100644 --- ql/src/test/results/clientpositive/llap/is_distinct_from.q.out +++ ql/src/test/results/clientpositive/llap/is_distinct_from.q.out @@ -206,9 +206,9 @@ STAGE PLANS: Processor Tree: TableScan alias: test_n5 - filterExpr: (y <> null) (type: boolean) + filterExpr: (y IS DISTINCT FROM null) (type: boolean) Filter Operator - predicate: (y <> null) (type: boolean) + predicate: (y IS DISTINCT FROM null) (type: boolean) Select Operator expressions: x (type: string), y (type: string) outputColumnNames: _col0, _col1 @@ -243,9 +243,9 @@ STAGE PLANS: Processor Tree: TableScan alias: test_n5 - filterExpr: (y = null) (type: boolean) + filterExpr: (y IS NOT DISTINCT FROM null) (type: boolean) Filter Operator - predicate: (y = null) (type: boolean) + predicate: (y IS NOT DISTINCT FROM null) (type: boolean) Select Operator expressions: x (type: string), null (type: string) outputColumnNames: _col0, _col1 @@ -287,9 +287,9 @@ STAGE PLANS: Processor Tree: TableScan alias: part - filterExpr: (p_size <> 2) (type: boolean) + filterExpr: (p_size IS DISTINCT FROM 2) (type: boolean) Filter Operator - predicate: (p_size <> 2) (type: boolean) + predicate: (p_size IS DISTINCT FROM 2) (type: boolean) Select Operator expressions: p_partkey (type: int), p_name (type: string), p_mfgr (type: string), p_brand (type: string), p_type (type: string), p_size (type: int), p_container (type: string), p_retailprice (type: double), p_comment (type: string) outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8 @@ -343,9 +343,9 @@ STAGE PLANS: Processor Tree: TableScan alias: part - filterExpr: (p_size = 2) (type: boolean) + filterExpr: (p_size IS NOT DISTINCT FROM 2) (type: boolean) Filter Operator - predicate: (p_size = 2) (type: boolean) + predicate: (p_size IS NOT DISTINCT FROM 2) (type: boolean) Select Operator expressions: p_partkey (type: int), p_name (type: string), p_mfgr (type: string), p_brand (type: string), p_type (type: string), 2 (type: int), p_container (type: string), p_retailprice (type: double), p_comment (type: string) outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8 diff --git ql/src/test/results/clientpositive/llap/orc_predicate_pushdown.q.out ql/src/test/results/clientpositive/llap/orc_predicate_pushdown.q.out index 797eaa8324..06b7703dd3 100644 --- ql/src/test/results/clientpositive/llap/orc_predicate_pushdown.q.out +++ ql/src/test/results/clientpositive/llap/orc_predicate_pushdown.q.out @@ -503,7 +503,7 @@ STAGE PLANS: TableScan alias: orc_pred Filter Operator - predicate: ((s like 'bob%') and (t = -1) and s is not null) (type: boolean) + predicate: ((s like 'bob%') and (t IS NOT DISTINCT FROM -1) and s is not null) (type: boolean) Select Operator expressions: -1Y (type: tinyint), s (type: string) outputColumnNames: _col0, _col1 @@ -533,9 +533,9 @@ STAGE PLANS: Processor Tree: TableScan alias: orc_pred - filterExpr: ((t = -1) and s is not null and (s like 'bob%')) (type: boolean) + filterExpr: ((t IS NOT DISTINCT FROM -1) and s is not null and (s like 'bob%')) (type: boolean) Filter Operator - predicate: ((s like 'bob%') and (t = -1) and s is not null) (type: boolean) + predicate: ((s like 'bob%') and (t IS NOT DISTINCT FROM -1) and s is not null) (type: boolean) Select Operator expressions: -1Y (type: tinyint), s (type: string) outputColumnNames: _col0, _col1 diff --git ql/src/test/results/clientpositive/llap/parquet_predicate_pushdown.q.out ql/src/test/results/clientpositive/llap/parquet_predicate_pushdown.q.out index 81af3d4ef2..2cb69dc249 100644 --- ql/src/test/results/clientpositive/llap/parquet_predicate_pushdown.q.out +++ ql/src/test/results/clientpositive/llap/parquet_predicate_pushdown.q.out @@ -441,7 +441,7 @@ STAGE PLANS: TableScan alias: tbl_pred Filter Operator - predicate: ((s like 'bob%') and (t = -1) and s is not null) (type: boolean) + predicate: ((s like 'bob%') and (t IS NOT DISTINCT FROM -1) and s is not null) (type: boolean) Select Operator expressions: -1Y (type: tinyint), s (type: string) outputColumnNames: _col0, _col1 @@ -471,9 +471,9 @@ STAGE PLANS: Processor Tree: TableScan alias: tbl_pred - filterExpr: ((t = -1) and s is not null and (s like 'bob%')) (type: boolean) + filterExpr: ((t IS NOT DISTINCT FROM -1) and s is not null and (s like 'bob%')) (type: boolean) Filter Operator - predicate: ((s like 'bob%') and (t = -1) and s is not null) (type: boolean) + predicate: ((s like 'bob%') and (t IS NOT DISTINCT FROM -1) and s is not null) (type: boolean) Select Operator expressions: -1Y (type: tinyint), s (type: string) outputColumnNames: _col0, _col1 diff --git ql/src/test/results/clientpositive/udf_equal.q.out ql/src/test/results/clientpositive/udf_equal.q.out index 52bd8438c7..5ccfac0513 100644 --- ql/src/test/results/clientpositive/udf_equal.q.out +++ ql/src/test/results/clientpositive/udf_equal.q.out @@ -37,12 +37,12 @@ PREHOOK: query: DESCRIBE FUNCTION <=> PREHOOK: type: DESCFUNCTION POSTHOOK: query: DESCRIBE FUNCTION <=> POSTHOOK: type: DESCFUNCTION -a <=> b - Returns same result with EQUAL(=) operator for non-null operands, but returns TRUE if both are NULL, FALSE if one of the them is NULL +a <=> b - Returns same result with EQUALNS (IS NOT DISTINCT FROM) operator for non-null operands, but returns TRUE if both are NULL, FALSE if one of the them is NULL PREHOOK: query: DESCRIBE FUNCTION EXTENDED <=> PREHOOK: type: DESCFUNCTION POSTHOOK: query: DESCRIBE FUNCTION EXTENDED <=> POSTHOOK: type: DESCFUNCTION -a <=> b - Returns same result with EQUAL(=) operator for non-null operands, but returns TRUE if both are NULL, FALSE if one of the them is NULL +a <=> b - Returns same result with EQUALNS (IS NOT DISTINCT FROM) operator for non-null operands, but returns TRUE if both are NULL, FALSE if one of the them is NULL Function class:org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPEqualNS Function type:BUILTIN PREHOOK: query: SELECT true<=>false, false<=>true, false<=>false, true<=>true, NULL<=>NULL, true<=>NULL, NULL<=>true, false<=>NULL, NULL<=>false FROM src tablesample (1 rows)