This is an automated email from the ASF dual-hosted git repository.

rameshkumar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d59479c4cf HIVE-28334 Support queries with function expression in the 
prepare execute workflow (Ramesh Kumar, reviewed by Soumyakanti Das)
4d59479c4cf is described below

commit 4d59479c4cf79197f15dc283ba5b3a2b8b750c05
Author: Ramesh Kumar <[email protected]>
AuthorDate: Tue Jul 9 16:00:04 2024 -0700

    HIVE-28334 Support queries with function expression in the prepare execute 
workflow (Ramesh Kumar, reviewed by Soumyakanti Das)
---
 .../hive/ql/plan/ExprNodeGenericFuncDesc.java      |   3 +
 .../clientpositive/prepare_plan_func_expr.q        |   9 ++
 .../llap/prepare_plan_func_expr.q.out              | 100 +++++++++++++++++++++
 3 files changed, 112 insertions(+)

diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java 
b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java
index 99710bf2c7c..d7f8c0b126d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeGenericFuncDesc.java
@@ -111,6 +111,9 @@ public class ExprNodeGenericFuncDesc extends ExprNodeDesc 
implements
 
   @Override
   public ObjectInspector getWritableObjectInspector() {
+    if (writableObjectInspector == null) {
+      writableObjectInspector = 
TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(typeInfo);
+    }
     return writableObjectInspector;
   }
 
diff --git a/ql/src/test/queries/clientpositive/prepare_plan_func_expr.q 
b/ql/src/test/queries/clientpositive/prepare_plan_func_expr.q
new file mode 100644
index 00000000000..e6983ed4468
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/prepare_plan_func_expr.q
@@ -0,0 +1,9 @@
+--! qt:dataset:src
+--! qt:dataset:alltypesorc
+
+explain prepare pint from select sum(ctinyint)/count(ctinyint) as ag from 
alltypesorc where cint = ? group by cint;
+explain cbo prepare pint from select sum(ctinyint)/count(ctinyint) as ag from 
alltypesorc where cint = ? group by cint;
+prepare pint from select sum(ctinyint)/count(ctinyint) as ag from alltypesorc 
where cint = ? group by cint;
+
+execute pint using 1000828;
+
diff --git 
a/ql/src/test/results/clientpositive/llap/prepare_plan_func_expr.q.out 
b/ql/src/test/results/clientpositive/llap/prepare_plan_func_expr.q.out
new file mode 100644
index 00000000000..a57038f67b0
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/prepare_plan_func_expr.q.out
@@ -0,0 +1,100 @@
+PREHOOK: query: explain prepare pint from select sum(ctinyint)/count(ctinyint) 
as ag from alltypesorc where cint = ? group by cint
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: explain prepare pint from select 
sum(ctinyint)/count(ctinyint) as ag from alltypesorc where cint = ? group by 
cint
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Tez
+#### A masked pattern was here ####
+      Edges:
+        Reducer 2 <- Map 1 (SIMPLE_EDGE)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: alltypesorc
+                  filterExpr: (cint = UDFToInteger($1)) (type: boolean)
+                  Statistics: Num rows: 12288 Data size: 73392 Basic stats: 
COMPLETE Column stats: COMPLETE
+                  Filter Operator
+                    predicate: (cint = UDFToInteger($1)) (type: boolean)
+                    Statistics: Num rows: 6144 Data size: 36696 Basic stats: 
COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      expressions: ctinyint (type: tinyint)
+                      outputColumnNames: _col1
+                      Statistics: Num rows: 6144 Data size: 36696 Basic stats: 
COMPLETE Column stats: COMPLETE
+                      Group By Operator
+                        aggregations: sum(_col1), count(_col1)
+                        keys: null (type: int)
+                        minReductionHashAggr: 0.99
+                        mode: hash
+                        outputColumnNames: _col0, _col1, _col2
+                        Statistics: Num rows: 1 Data size: 20 Basic stats: 
COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: int)
+                          null sort order: z
+                          sort order: +
+                          Map-reduce partition columns: _col0 (type: int)
+                          Statistics: Num rows: 1 Data size: 20 Basic stats: 
COMPLETE Column stats: COMPLETE
+                          value expressions: _col1 (type: bigint), _col2 
(type: bigint)
+            Execution mode: llap
+            LLAP IO: all inputs
+        Reducer 2 
+            Execution mode: vectorized, llap
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: sum(VALUE._col0), count(VALUE._col1)
+                keys: KEY._col0 (type: int)
+                mode: mergepartial
+                outputColumnNames: _col0, _col1, _col2
+                Statistics: Num rows: 1 Data size: 20 Basic stats: COMPLETE 
Column stats: COMPLETE
+                Select Operator
+                  expressions: (UDFToDouble(_col1) / UDFToDouble(_col2)) 
(type: double)
+                  outputColumnNames: _col0
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE 
Column stats: COMPLETE
+                  File Output Operator
+                    compressed: false
+                    Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE 
Column stats: COMPLETE
+                    table:
+                        input format: 
org.apache.hadoop.mapred.SequenceFileInputFormat
+                        output format: 
org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                        serde: 
org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: explain cbo prepare pint from select 
sum(ctinyint)/count(ctinyint) as ag from alltypesorc where cint = ? group by 
cint
+PREHOOK: type: QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: explain cbo prepare pint from select 
sum(ctinyint)/count(ctinyint) as ag from alltypesorc where cint = ? group by 
cint
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+CBO PLAN:
+HiveProject(ag=[/(CAST($1):DOUBLE, CAST($2):DOUBLE)])
+  HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[count($1)])
+    HiveProject($f0=[CAST(?1):INTEGER], $f1=[$0])
+      HiveFilter(condition=[=($2, CAST(?1):INTEGER)])
+        HiveTableScan(table=[[default, alltypesorc]], 
table:alias=[alltypesorc])
+
+PREHOOK: query: execute pint using 1000828
+PREHOOK: type: EXECUTE QUERY
+PREHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+POSTHOOK: query: execute pint using 1000828
+POSTHOOK: type: EXECUTE QUERY
+POSTHOOK: Input: default@alltypesorc
+#### A masked pattern was here ####
+11.0

Reply via email to