kasakrisz commented on code in PR #6496:
URL: https://github.com/apache/hive/pull/6496#discussion_r3332926628
##########
ql/src/test/org/apache/hadoop/hive/ql/stats/TestStatsUtils.java:
##########
@@ -565,4 +569,44 @@ void testGetColStatisticsTimestampType() {
assertEquals(1700000000L, range.maxValue.longValue(), "maxValue mismatch
for TIMESTAMP");
}
+ @Test
+ void testEstimateStatsForMissingColsHandlesEmptyList() {
+ HiveConf conf = new HiveConf();
+
+ ColumnInfo columnInfoA = new ColumnInfo("a", TypeInfoFactory.intTypeInfo,
"t", false);
+
+ List<ColStatistics> allColumnStats =
StatsUtils.estimateStatsForMissingCols(
+ List.of("a"), Collections.emptyList(), conf, 0, List.of(columnInfoA));
+
+ assertEquals(1, allColumnStats.size());
+ }
+
+ @Test
+ void testEstimateStatsForMissingColsCombinesExistingStatsAndEstimations() {
+ HiveConf conf = new HiveConf();
+
+ ColumnInfo colNeededButNotExists = new ColumnInfo("neededButNotExists",
TypeInfoFactory.intTypeInfo, "t", false);
+ ColumnInfo colNeededAndExists = new ColumnInfo("neededAndExists",
TypeInfoFactory.intTypeInfo, "t", false);
+ ColumnInfo colNotNeededButExists = new ColumnInfo("notNeededButExists",
TypeInfoFactory.intTypeInfo, "t", false);
+ ColumnInfo colNotNeededNotExists = new ColumnInfo("notNeededNotExists",
TypeInfoFactory.intTypeInfo, "t", false);
+
+ ColStatistics colStatNeededAndExists = new ColStatistics();
+ colStatNeededAndExists.setColumnName(colNeededAndExists.getInternalName());
+ ColStatistics colStatNotNeededButExists = new ColStatistics();
+
colStatNotNeededButExists.setColumnName(colNotNeededButExists.getInternalName());
+
+ List<ColStatistics> allColumnStats =
StatsUtils.estimateStatsForMissingCols(
+ List.of(colNeededAndExists.getInternalName(),
colNeededButNotExists.getInternalName()),
+ List.of(colStatNeededAndExists, colStatNotNeededButExists),
+ conf,
+ 0,
+ List.of(colNeededButNotExists, colNeededAndExists,
colNotNeededButExists, colNotNeededNotExists));
+
+ assertEquals(3, allColumnStats.size());
+ assertEquals(allColumnStats.get(0), colStatNeededAndExists);
+ assertEquals(allColumnStats.get(1), colStatNotNeededButExists);
+ assertTrue(allColumnStats.get(2).isEstimated());
+ assertEquals(allColumnStats.get(2).getColumnName(),
colNeededButNotExists.getInternalName());
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]