dengzhhu653 commented on code in PR #4569:
URL: https://github.com/apache/hive/pull/4569#discussion_r1322655736
##########
itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java:
##########
@@ -1684,6 +1684,58 @@ public void cleanupNotifs() throws Exception {
assertEquals(0, rsp2.getEventsSize());
}
+ @Test
+ public void fetchNotificationEventBasedOnTables() throws Exception {
+ String dbName = "test_hive27499";
+ String table1 = "test_tbl1";
+ String table2 = "test_tbl2";
+ String table3 = "test_tbl3";
+ // Generate some table events
+ generateSometableEvents(dbName, table1);
+ generateSometableEvents(dbName, table2);
+ generateSometableEvents(dbName, table3);
+
+ // Verify events by table names
+ NotificationEventRequest request = new NotificationEventRequest();
+ request.setLastEvent(firstEventId);
+ request.setMaxEvents(-1);
+ request.setDbName(dbName);
+ request.setTableNames(Arrays.asList(table1));
+ NotificationEventResponse rsp1 = msClient.getNextNotification(request,
true, null);
+ assertEquals(12, rsp1.getEventsSize());
+ request.setTableNames(Arrays.asList(table1, table2));
+ NotificationEventResponse rsp2 = msClient.getNextNotification(request,
true, null);
+ assertEquals(24, rsp2.getEventsSize());
+ request.unsetTableNames();
+ NotificationEventResponse rsp3 = msClient.getNextNotification(request,
true, null);
+ assertEquals(37, rsp3.getEventsSize());
+
+ NotificationEventsCountRequest eventsReq = new
NotificationEventsCountRequest(firstEventId, dbName);
+ eventsReq.setTableNames(Arrays.asList(table1));
+ assertEquals(12,
msClient.getNotificationEventsCount(eventsReq).getEventsCount());
+ eventsReq.setTableNames(Arrays.asList(table1, table2));
+ assertEquals(24,
msClient.getNotificationEventsCount(eventsReq).getEventsCount());
+ eventsReq.unsetTableNames();
+ assertEquals(37,
msClient.getNotificationEventsCount(eventsReq).getEventsCount());
+ }
+
+ private void generateSometableEvents(String dbName, String tableName) throws
Exception {
+ // Event 1
+ driver.run("create database if not exists "+dbName);
+ // Event 2
+ driver.run("use "+dbName);
Review Comment:
we do not generate an event for `use db`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]