Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bed032d
HIVE-29625: Disambiguate ColStatistics.countDistinct "unknown" from "…
konstantinb May 21, 2026
124abe6
HIVE-29625: impacted .out files + reverting an unintended edit
konstantinb May 22, 2026
f5b19e9
HIVE-29625: itest code, small tweaks + better code reuse
konstantinb May 25, 2026
349be2f
HIVE-29625: SQ feedback + better test code
konstantinb May 27, 2026
03960fd
HIVE-29625: more SQ feedback
konstantinb May 28, 2026
5b2bc13
Merge branch 'master' into HIVE-29625
konstantinb May 28, 2026
a94dbe9
Merge branch 'master' into HIVE-29625
konstantinb May 29, 2026
98cff4e
HIVE-29625: trigger a rebuild
konstantinb May 30, 2026
28112af
Merge branch 'master' into HIVE-29625
konstantinb Jul 19, 2026
5b0700f
HIVE-29625: few more required changes + test files
konstantinb Jul 20, 2026
73fa017
HIVE-29625: SonarQube feedback + misc refactoring
konstantinb Jul 23, 2026
6dbe997
Merge branch 'master' into HIVE-29625
konstantinb Oct 5, 2026
68a9747
HIVE-29625: Align license headers of new test files with checkstyle/a…
konstantinb Oct 6, 2026
b988af0
HIVE-29625: self-identified code nits
konstantinb Oct 7, 2026
6c5989b
HIVE-29625: trigger CI re-run
konstantinb Oct 8, 2026
d69875a
HIVE-29625: fixed checkMapSideAggregation()'s deviation from the orig…
konstantinb Nov 5, 2026
dcaac90
HIVE-29625: fix "col <=> NULL" estimate when the NDV is a verified zero
konstantinb Nov 5, 2026
17bccf8
HIVE-29625: clarify verified-zero IN estimate under hive.stats.filter…
konstantinb Nov 5, 2026
e2adeaf
Merge branch 'master' into HIVE-29625
konstantinb Nov 5, 2026
8ba92be
HIVE-29625: SQ feedback
konstantinb Nov 5, 2026
eda2c8d
HIVE-29625: clarifying null-safe equality operator
konstantinb Nov 12, 2026
c84946b
Merge branch 'master' into HIVE-29625
konstantinb Nov 23, 2026
45c29a0
HIVE-29625: Report unknown NDV to Calcite as null
konstantinb Nov 25, 2026
ecb61df
HIVE-29625: Apply review suggestions
konstantinb Nov 25, 2026
a90be13
HIVE-29625: Size the map-side hash table with the GROUP BY grouping c…
konstantinb Nov 25, 2026
9cc9cfb
HIVE-29625: SQ feedback
konstantinb Nov 26, 2026
85b3980
HIVE-29625: Update plans for nested-pruning .out files for NOT null p…
konstantinb Nov 26, 2026
3241f0c
HIVE-29625: Replace unknownSeen state with an immutable propagate-unk…
konstantinb Nov 28, 2026
a484cb5
HIVE-29625: Restore the zero NDV fallback at the Calcite boundary
konstantinb Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ public static Object processReduceSinkToHashJoin(ReduceSinkOperator parentRS, Ma
ExprNodeDesc realCol = parentRS.getColumnExprMap().get(prefix + "." + keyCol);
ColStatistics cs =
StatsUtils.getColStatisticsFromExpression(context.conf, stats, realCol);
if (cs == null || cs.getCountDistint() <= 0) {
if (cs == null || cs.getCountDistint() < 0) {
// missing stats or unknown NDV: the key columns cannot bound
// the key count, so it stays at the row count
maxKeyCount = Long.MAX_VALUE;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public Object process(Node nd, Stack<Node> stack,
Statistics parentStats = groupByOperator.getParentOperators().get(0).getStatistics();
long ndvProduct = StatsUtils.computeNDVGroupingColumns(
colStats, parentStats, true);
// if ndvProduct is 0 then column stats state must be partial and we are missing
if (ndvProduct == 0) {
if (ndvProduct < 0) {
// unknown NDV product: keep the configured minimum reduction
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
Expand Down Expand Up @@ -926,7 +927,8 @@ private long computeMaxWriters() {
* Computes the partition cardinality based on column NDV statistics.
* @return positive value = estimated cardinality, 0 = no partition columns, -1 = stats unavailable
*/
private long computePartCardinality(List<Integer> partitionPos,
@VisibleForTesting
long computePartCardinality(List<Integer> partitionPos,
List<Function<List<ExprNodeDesc>, ExprNodeDesc>> customPartitionExprs,
Statistics tStats, Operator<? extends OperatorDesc> fsParent,
ArrayList<ExprNodeDesc> allRSCols) {
Expand All @@ -937,7 +939,8 @@ private long computePartCardinality(List<Integer> partitionPos,
for (Integer idx : partitionPos) {
ColumnInfo ci = fsParent.getSchema().getSignature().get(idx);
ColStatistics partStats = tStats.getColumnStatisticsFromColName(ci.getInternalName());
if (partStats == null) {
// countDistinct < 0 means "unknown" - same path as missing stats
if (partStats == null || partStats.getCountDistint() < 0) {
return -1;
}
partCardinality *= partStats.getCountDistint();
Expand All @@ -952,7 +955,8 @@ private long computePartCardinality(List<Integer> partitionPos,
// implementations on UDFs (e.g. iceberg_bucket reports min(inputNDV, numBuckets))
ColStatistics exprStats = StatsUtils.getColStatisticsFromExpression(
this.parseCtx.getConf(), tStats, resolved);
if (exprStats == null) {
// countDistinct < 0 means "unknown" - same path as missing stats
if (exprStats == null || exprStats.getCountDistint() < 0) {
return -1;
}
partCardinality *= exprStats.getCountDistint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan;
import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.JdbcHiveTableScan;
import org.apache.hadoop.hive.ql.plan.ColStatistics;
import com.google.common.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -51,7 +52,8 @@ public class HiveRelMdDistinctRowCount extends RelMdDistinctRowCount {
ReflectiveRelMetadataProvider.reflectiveSource(
BuiltInMethod.DISTINCT_ROW_COUNT.method, new HiveRelMdDistinctRowCount());

private HiveRelMdDistinctRowCount() {
@VisibleForTesting
HiveRelMdDistinctRowCount() {
}

public Double getDistinctRowCount(HiveTableScan htRel, RelMetadataQuery mq, ImmutableBitSet groupKey,
Expand All @@ -61,6 +63,12 @@ public Double getDistinctRowCount(HiveTableScan htRel, RelMetadataQuery mq, Immu
List<ColStatistics> colStats = htRel.getColStat(projIndxLst);
Double noDistinctRows = 1.0;
for (ColStatistics cStat : colStats) {
// unknown (< 0) or zero NDV yields 0; null (Calcite's
// "unknown") would need matching guards in
// HiveRelMdRowCount's PK-FK analysis
if (cStat.getCountDistint() <= 0) {
return 0.0;
}
noDistinctRows *= cStat.getCountDistint();
}

Expand Down
Loading
Loading