[ https://issues.apache.org/jira/browse/HIVE-17257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16117565#comment-16117565 ]
Chao Sun commented on HIVE-17257: --------------------------------- [~kellyzly]: the empty files maybe generated if the result set is empty and if you have multiple mapper/reducers with file sink. Example: {code} set hive.execution.engine=spark; set hive.auto.convert.join=false; set mapreduce.job.reduces=1000; create table dummy (a string); insert overwrite directory '/tmp/test' select src.key from src join dummy on src.key = dummy.a; {code} The above will generate 1000 empty files in /tmp/test. [~xuefuz]: I need to revise the patch. There's an issue where HoS won't launch task for the final merge job since the input data is empty. > Hive should merge empty files > ----------------------------- > > Key: HIVE-17257 > URL: https://issues.apache.org/jira/browse/HIVE-17257 > Project: Hive > Issue Type: Bug > Reporter: Chao Sun > Assignee: Chao Sun > Attachments: HIVE-17257.0.patch > > > Currently if merging file option is turned on and the dest dir contains large > number of empty files, Hive will not trigger merge task: > {code} > private long getMergeSize(FileSystem inpFs, Path dirPath, long avgSize) { > AverageSize averageSize = getAverageSize(inpFs, dirPath); > if (averageSize.getTotalSize() <= 0) { > return -1; > } > if (averageSize.getNumFiles() <= 1) { > return -1; > } > if (averageSize.getTotalSize()/averageSize.getNumFiles() < avgSize) { > return averageSize.getTotalSize(); > } > return -1; > } > {code} > This logic doesn't seem right as the it seems better to combine these empty > files into one. -- This message was sent by Atlassian JIRA (v6.4.14#64029)