[
https://issues.apache.org/jira/browse/HIVE-26446?focusedWorklogId=800926&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-800926
]
ASF GitHub Bot logged work on HIVE-26446:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 16/Aug/22 12:02
Start Date: 16/Aug/22 12:02
Worklog Time Spent: 10m
Work Description: simhadri-g commented on code in PR #3499:
URL: https://github.com/apache/hive/pull/3499#discussion_r946689250
##########
ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveProtoLoggingHook.java:
##########
@@ -322,4 +338,63 @@ private void assertOtherInfo(HiveHookEventProto event,
OtherInfoType key, String
Assert.assertEquals(value, val);
}
}
+
+ private void testTablesWritten(WriteEntity we, boolean isPartitioned) throws
Exception {
+ String query = isPartitioned ?
+ "insert into test_partition partition(dt = '20220102', lable =
'test1') values('20220103', 'banana');" :
+ "insert into default.testTable1 values('ab')";
+ HashSet<WriteEntity> tableWritten = new HashSet<>();
+ tableWritten.add(we);
+ QueryState state = new QueryState.Builder().withHiveConf(conf).build();
+ @SuppressWarnings("serial")
+ QueryPlan queryPlan = new QueryPlan(HiveOperation.QUERY) {
+ };
+ queryPlan.setQueryId("test_queryId");
+ queryPlan.setQueryStartTime(1234L);
+ queryPlan.setQueryString(query);
+ queryPlan.setRootTasks(new ArrayList<>());
+ queryPlan.setInputs(new HashSet<>());
+ queryPlan.setOutputs(tableWritten);
+ PerfLogger perf = PerfLogger.getPerfLogger(conf, true);
+ HookContext ctx = new HookContext(queryPlan, state, null, "test_user",
"192.168.10.11",
+ "hive_addr", "test_op_id", "test_session_id", "test_thread_id",
true, perf, null);
+
+ ctx.setHookType(HookType.PRE_EXEC_HOOK);
+ EventLogger evtLogger = new EventLogger(conf, SystemClock.getInstance());
+ evtLogger.handle(ctx);
+ evtLogger.shutdown();
+
+ HiveHookEventProto event = loadEvent(conf, tmpFolder);
+
+ Assert.assertEquals(EventType.QUERY_SUBMITTED.name(),
event.getEventType());
+ Assert.assertEquals(we.getTable().getFullyQualifiedName(),
event.getTablesWritten(0));
+ }
+
+ private Table newTable(boolean isPartitioned) {
Review Comment:
WriteEntity constructor only accepts
org.apache.hadoop.hive.ql.metadata.Table .
If we have to use the the TableBuilder, we will need to import
org.apache.hadoop.hive.metastore.api.Table, this will introduce a new package
dependency.
I also found that, the helper methods are available here, we just have move
them to commonTestUtils so that other tests can use them. Can we do this in
separate jira?
https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestAppendPartitions.java#L540
Issue Time Tracking
-------------------
Worklog Id: (was: 800926)
Time Spent: 50m (was: 40m)
> HiveProtoLoggingHook fails to populate TablesWritten field for partitioned
> tables.
> ----------------------------------------------------------------------------------
>
> Key: HIVE-26446
> URL: https://issues.apache.org/jira/browse/HIVE-26446
> Project: Hive
> Issue Type: Bug
> Reporter: Simhadri Govindappa
> Assignee: Simhadri Govindappa
> Priority: Major
> Labels: pull-request-available
> Time Spent: 50m
> Remaining Estimate: 0h
>
> From
> [here|https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java#L490]
> :
> {code:java}
> if (entity.getType() == Entity.Type.TABLE) {code}
> entity.getType() returns the value as "PARTITION" for partitioned tables
> instead of "TABLE" as a result the above check returns false and the
> tablesWritten field in the hiveProtologger is left unpopulated for
> partitioned tables.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)