This is an automated email from the ASF dual-hosted git repository. dkuzmenko 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 d7b3a5ba4a6 HIVE-29067: insert-select-union-all query fails while publishing InsertEvent if source query does not return output (#5926) d7b3a5ba4a6 is described below commit d7b3a5ba4a6d3c4ea894fd36d0fc7e1f87a53e64 Author: Naresh P R <prnaresh.nar...@gmail.com> AuthorDate: Wed Jul 9 03:25:04 2025 -0400 HIVE-29067: insert-select-union-all query fails while publishing InsertEvent if source query does not return output (#5926) --- ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java | 5 ++--- ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java index 60db2749862..566b9607164 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java @@ -3961,7 +3961,7 @@ public void fireInsertEvent(String dbName, String tblName, } } - private void fireInsertEvent(Table tbl, Map<String, String> partitionSpec, boolean replace, List<FileStatus> newFiles) + void fireInsertEvent(Table tbl, Map<String, String> partitionSpec, boolean replace, List<FileStatus> newFiles) throws HiveException { if (conf.getBoolVar(ConfVars.FIRE_EVENTS_FOR_DML)) { LOG.debug("Firing dml insert event"); @@ -3974,11 +3974,10 @@ private void fireInsertEvent(Table tbl, Map<String, String> partitionSpec, boole FireEventRequestData data = new FireEventRequestData(); InsertEventRequestData insertData = new InsertEventRequestData(); insertData.setReplace(replace); + insertData.setFilesAdded(new ArrayList()); data.setInsertData(insertData); if (newFiles != null && !newFiles.isEmpty()) { addInsertFileInformation(newFiles, fileSystem, insertData); - } else { - insertData.setFilesAdded(new ArrayList<String>()); } FireEventRequest rqst = new FireEventRequest(true, data); rqst.setDbName(tbl.getDbName()); diff --git a/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java b/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java index 2d42ea880ba..a55551357d2 100755 --- a/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java +++ b/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java @@ -1055,6 +1055,17 @@ public void testFireInsertEvent() throws Throwable { Path insertedPath = new Path(insertEvent.getFiles().get(i)); Assert.assertEquals(expectedCheckSums.get(insertedPath.getName()), checkSums.get(i)); } + + // Fire the InsertEvent with empty folder + hiveDb.fireInsertEvent(table, null, false, + Lists.newArrayList(new FileStatus(5, true, 1, 64, 100, tablePath))); + // Get the last Metastore event + InsertEvent insertEvent1 = DummyFireInsertListener.getLastEvent(); + // Check the event + Assert.assertNotNull(insertEvent1); + // getFiles should be empty and not null + Assert.assertNotNull(insertEvent1.getFiles()); + Assert.assertTrue(insertEvent1.getFiles().isEmpty()); } private String getFileCheckSum(FileSystem fileSystem, Path p) throws Exception {