diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/metainfo/annotation/OpTraitsRulesProcFactory.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/metainfo/annotation/OpTraitsRulesProcFactory.java index 7149f5c..5725d10 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/metainfo/annotation/OpTraitsRulesProcFactory.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/metainfo/annotation/OpTraitsRulesProcFactory.java @@ -130,30 +130,32 @@ public boolean checkBucketedTable(Table tbl, ParseContext pGraphContext, // construct a mapping of (Partition->bucket file names) and (Partition -> bucket number) if (!partitions.isEmpty()) { for (Partition p : partitions) { + int bucketCount = p.getBucketCount(); + if (bucketCount > 0) { List fileNames = AbstractBucketJoinProc.getBucketFilePathsOfPartition(p.getDataLocation(), pGraphContext); // The number of files for the table should be same as number of // buckets. - int bucketCount = p.getBucketCount(); - if (fileNames.size() != 0 && fileNames.size() != bucketCount) { return false; } } } + } } else { - + int numBuckets = tbl.getNumBuckets(); + if (numBuckets > 0) { List fileNames = AbstractBucketJoinProc.getBucketFilePathsOfPartition(tbl.getDataLocation(), pGraphContext); - Integer num = new Integer(tbl.getNumBuckets()); // The number of files for the table should be same as number of buckets. - if (fileNames.size() != 0 && fileNames.size() != num) { + if (fileNames.size() != 0 && fileNames.size() != numBuckets) { return false; } } + } return true; }