-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29368: more conservative NDV combining by PessimisticStatCombiner #6244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
konstantinb
wants to merge
7
commits into
apache:master
Choose a base branch
from
konstantinb:HIVE-29368
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
633951c
HIVE-29368: more conservative NDV combining by PessimisticStatCombiner
konstantinb 199c441
HIVE-29368: regenerated impacted test results + added an explanation …
konstantinb f0022f7
HIVE-29368: one more test file, modified using explain output only fo…
konstantinb bd86e3c
HIVE-29368: only increment ndv by one inextractNDVGroupingColumns() i…
konstantinb 75dbdf8
HIVE-29368: further tuning NDV handling, including reading stats for …
konstantinb 0ddef8c
Merge origin/master into HIVE-29368
konstantinb 8b361de
HIVE-29368: impacted test .out files
konstantinb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -832,6 +832,7 @@ public static ColStatistics getColStatistics(ColumnStatisticsObj cso, String col | |
| cs.setNumNulls(csd.getBinaryStats().getNumNulls()); | ||
| } else if (colTypeLowerCase.equals(serdeConstants.TIMESTAMP_TYPE_NAME)) { | ||
| cs.setAvgColLen(JavaDataModel.get().lengthOfTimestamp()); | ||
| cs.setCountDistint(csd.getTimestampStats().getNumDVs()); | ||
| cs.setNumNulls(csd.getTimestampStats().getNumNulls()); | ||
| Long lowVal = (csd.getTimestampStats().getLowValue() != null) ? csd.getTimestampStats().getLowValue() | ||
| .getSecondsSinceEpoch() : null; | ||
|
|
@@ -862,6 +863,7 @@ public static ColStatistics getColStatistics(ColumnStatisticsObj cso, String col | |
| cs.setHistogram(csd.getDecimalStats().getHistogram()); | ||
| } else if (colTypeLowerCase.equals(serdeConstants.DATE_TYPE_NAME)) { | ||
| cs.setAvgColLen(JavaDataModel.get().lengthOfDate()); | ||
| cs.setCountDistint(csd.getDateStats().getNumDVs()); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am unsure if this was deliberately not added or an unintended omission. It does seem to improve stats' calculations of multiple .q test files, especially after more conservative NDV handling by PessimisticStatCombiner |
||
| cs.setNumNulls(csd.getDateStats().getNumNulls()); | ||
| Long lowVal = (csd.getDateStats().getLowValue() != null) ? csd.getDateStats().getLowValue() | ||
| .getDaysSinceEpoch() : null; | ||
|
|
@@ -2087,8 +2089,16 @@ private static List<Long> extractNDVGroupingColumns(List<ColStatistics> colStats | |
| for (ColStatistics cs : colStats) { | ||
| if (cs != null) { | ||
| long ndv = cs.getCountDistint(); | ||
| if (cs.getNumNulls() > 0) { | ||
| ndv = StatsUtils.safeAdd(ndv, 1); | ||
|
|
||
| if (ndv == 0L) { | ||
| // Typically, ndv == 0 means "NDV unknown", and no safe GROUPBY adjustments are possible | ||
| // However, there is a special exception for "constant NULL" columns. They are intentionally generated | ||
| // with NDV values of 0 and numNulls == numRows, while their actual NDV is 1 | ||
| if (cs.getNumNulls() >= parentStats.getNumRows()) { | ||
| ndv = 1L; | ||
| } | ||
| } else if (cs.getNumNulls() > 0L) { | ||
| ndv = StatsUtils.safeAdd(ndv, 1L); | ||
| } | ||
| ndvValues.add(ndv); | ||
| } else { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unsure if this was deliberately not added or an unintended omission. It does seem to improve stats' calculations of multiple .q test files, especially after more conservative NDV handling by PessimisticStatCombiner