Repository navigation
HIVE-30131: StatsOptimizer: Answer MIN, MAX and COUNT on a DECIMAL column from column statistics - #6844
HIVE-30131: StatsOptimizer: Answer MIN, MAX and COUNT on a DECIMAL column from column statistics#6844deniskuzZ wants to merge 1 commit into
Conversation
c24a193 to
ba8a463
Compare
…lumn from column statistics - getType mapped a decimal column to StatType.Unsupported, so min, max and count(col) over one scanned the table even with accurate satistics - add StatType.Decimal and the cases its exhaustive switches then require - read the bound through DecimalUtils.getHiveDecimal, as the metastore does - partitioned tables need no fold here: statsFor already aggregates them
|
There was a problem hiding this comment.
🟢 Approval recommended
The implementation handles DECIMAL bounds and null counts consistently and includes broad regression coverage.
0 open findings
What changed in this PR
Adds statistics-based optimization for MIN, MAX, and COUNT on DECIMAL columns.
Changes:
- Maps DECIMAL types to decimal column statistics and converts stored bounds to
HiveDecimal. - Tests native, partitioned, all-NULL, and Iceberg decimal columns.
- Disables stats optimization in the vectorized UDF execution test.
| File | Description |
|---|---|
ql/src/java/.../StatsOptimizer.java |
Implements DECIMAL statistics support. |
ql/src/test/queries/clientpositive/metadata_only_queries.q |
Adds native-table DECIMAL tests. |
ql/src/test/results/clientpositive/llap/metadata_only_queries.q.out |
Records native-table results and plans. |
ql/src/test/queries/clientpositive/vector_decimal_udf.q |
Preserves vectorized execution coverage. |
iceberg/.../iceberg_part_colstats.q |
Adds Iceberg DECIMAL statistics tests. |
iceberg/.../iceberg_part_colstats.q.out |
Records Iceberg results and plans. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| set hive.explain.user=false; | ||
| SET hive.vectorized.execution.enabled=true; | ||
| set hive.fetch.task.conversion=minimal; | ||
| set hive.compute.query.using.stats=false; |
There was a problem hiding this comment.
Based on CI run 7 I'm assuming, this was explicitly turned off to preserve the vectorized Tez execution coverage and new q file (metadata_only_queries.q and iceberg_part_colstats.q.) will test this PR?
There was a problem hiding this comment.
yes, exactly. Otherwise, vector_decimal_udf.q was answered from stats, skipping execution



What changes were proposed in this pull request?
Why are the changes needed?
Missing stats optimization for DECIMAL column
Does this PR introduce any user-facing change?
No
How was this patch tested?
metadata_only_queries.q