Skip to content

Commit

Permalink
[FLINK-29831][hive] fix test failure for hive3
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyuxia authored Nov 4, 2022
1 parent 276bb77 commit 8e66be8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@

package org.apache.flink.connectors.hive;

import org.apache.flink.table.HiveVersionTestUtil;
import org.apache.flink.table.api.SqlDialect;
import org.apache.flink.table.catalog.hive.HiveCatalog;
import org.apache.flink.table.catalog.hive.HiveTestUtils;
import org.apache.flink.table.catalog.hive.client.HiveShimLoader;
import org.apache.flink.table.plan.stats.ColumnStats;
import org.apache.flink.table.plan.stats.TableStats;
import org.apache.flink.table.planner.plan.stats.FlinkStatistic;
Expand All @@ -43,7 +41,6 @@
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

/** Test for statistics functionality in {@link HiveTableSource}. */
public class HiveTableSourceStatisticsReportTest extends StatisticsReportTestBase {
Expand Down Expand Up @@ -298,43 +295,20 @@ private static void assertHiveTableOrcFormatTableStatsEquals(
expectedColumnStatsMap.put(
"f_string",
new ColumnStats.Builder().setMax("def").setMin("abcd").setNullCount(0L).build());
if (HiveVersionTestUtil.HIVE_310_OR_LATER) {
// TODO For hive 3.x version, Orc format encounter decimal type columns (like
// decimal(5, 2), decimal(14, 2)) will write a wrong column stat 'min' or 'max' in
// orc metadata footer. This branch will remove after this error is fixed, following
// issue HIVE-26492
expectedColumnStatsMap.put(
"f_decimal5",
new ColumnStats.Builder()
.setMax(new BigDecimal("223.45"))
.setMin(new BigDecimal("0"))
.setNullCount(0L)
.build());
expectedColumnStatsMap.put(
"f_decimal14",
new ColumnStats.Builder()
.setMax(new BigDecimal("123333333355.33"))
.setMin(new BigDecimal("0"))
.setNullCount(0L)
.build());
} else if (HiveVersionTestUtil.HIVE_230_OR_LATER) {
expectedColumnStatsMap.put(
"f_decimal5",
new ColumnStats.Builder()
.setMax(new BigDecimal("223.45"))
.setMin(new BigDecimal("123.45"))
.setNullCount(0L)
.build());
expectedColumnStatsMap.put(
"f_decimal14",
new ColumnStats.Builder()
.setMax(new BigDecimal("123333333355.33"))
.setMin(new BigDecimal("123333333333.33"))
.setNullCount(0L)
.build());
} else {
fail("Unknown test version " + HiveShimLoader.getHiveVersion());
}
expectedColumnStatsMap.put(
"f_decimal5",
new ColumnStats.Builder()
.setMax(new BigDecimal("223.45"))
.setMin(new BigDecimal("123.45"))
.setNullCount(0L)
.build());
expectedColumnStatsMap.put(
"f_decimal14",
new ColumnStats.Builder()
.setMax(new BigDecimal("123333333355.33"))
.setMin(new BigDecimal("123333333333.33"))
.setNullCount(0L)
.build());
expectedColumnStatsMap.put(
"f_decimal38",
new ColumnStats.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void testNumberOfBuiltinFunctions() {

private void verifyNumBuiltInFunctions(String hiveVersion, HiveModule hiveModule) {
if (HiveVersionTestUtil.HIVE_310_OR_LATER) {
assertThat(hiveModule.listFunctions()).hasSize(296);
assertThat(hiveModule.listFunctions()).hasSize(297);
} else if (HiveVersionTestUtil.HIVE_230_OR_LATER) {
assertThat(hiveModule.listFunctions()).hasSize(277);
} else {
Expand Down

0 comments on commit 8e66be8

Please sign in to comment.