From e8518df733b54d33cc4454b4bff2db6bf9f0b6d2 Mon Sep 17 00:00:00 2001 From: Anton Kutuzov Date: Mon, 4 Aug 2025 16:58:40 +0200 Subject: [PATCH] Add supporting of timestamp type in statistics for hive 3 and 4 versions --- .../metastore/thrift/ThriftMetastoreUtil.java | 47 +++++- .../AbstractHiveStatisticsProvider.java | 12 ++ .../io/trino/plugin/hive/util/Statistics.java | 25 ++- .../plugin/hive/BaseHiveConnectorTest.java | 146 ++++++++++++++---- .../plugin/hive/BaseTestHiveOnDataLake.java | 40 +++++ .../io/trino/plugin/hive/HiveQueryRunner.java | 3 +- .../product/hive/TestHiveTableStatistics.java | 22 +-- .../io/trino/tests/tpch/TpchQueryRunner.java | 10 ++ 8 files changed, 258 insertions(+), 47 deletions(-) diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreUtil.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreUtil.java index f0fa736b3a00..17b673ecefc6 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreUtil.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreUtil.java @@ -43,6 +43,8 @@ import io.trino.hive.thrift.metastore.SerDeInfo; import io.trino.hive.thrift.metastore.StorageDescriptor; import io.trino.hive.thrift.metastore.StringColumnStatsData; +import io.trino.hive.thrift.metastore.Timestamp; +import io.trino.hive.thrift.metastore.TimestampColumnStatsData; import io.trino.metastore.AcidOperation; import io.trino.metastore.Column; import io.trino.metastore.Database; @@ -83,6 +85,8 @@ import java.math.BigInteger; import java.nio.ByteBuffer; import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Collection; @@ -148,8 +152,13 @@ import static io.trino.spi.type.IntegerType.INTEGER; import static io.trino.spi.type.RealType.REAL; import static io.trino.spi.type.SmallintType.SMALLINT; +import static io.trino.spi.type.StandardTypes.TIMESTAMP; +import static io.trino.spi.type.Timestamps.MICROSECONDS_PER_MILLISECOND; +import static io.trino.spi.type.Timestamps.MICROSECONDS_PER_SECOND; import static io.trino.spi.type.TinyintType.TINYINT; import static io.trino.spi.type.VarbinaryType.VARBINARY; +import static java.lang.Math.ceilDiv; +import static java.lang.Math.floorDiv; import static java.lang.Math.toIntExact; import static java.lang.String.format; import static java.util.Locale.ENGLISH; @@ -521,6 +530,10 @@ public static HiveColumnStatistics fromMetastoreApiColumnStatistics(ColumnStatis LongColumnStatsData longStatsData = columnStatistics.getStatsData().getLongStats(); OptionalLong min = longStatsData.isSetLowValue() ? OptionalLong.of(longStatsData.getLowValue()) : OptionalLong.empty(); OptionalLong max = longStatsData.isSetHighValue() ? OptionalLong.of(longStatsData.getHighValue()) : OptionalLong.empty(); + if (min.isPresent() && max.isPresent() && columnStatistics.getColType().equals(TIMESTAMP)) { + min = OptionalLong.of(min.getAsLong() * MICROSECONDS_PER_SECOND); + max = OptionalLong.of(max.getAsLong() * MICROSECONDS_PER_SECOND); + } OptionalLong nullsCount = longStatsData.isSetNumNulls() ? fromMetastoreNullsCount(longStatsData.getNumNulls()) : OptionalLong.empty(); OptionalLong distinctValuesWithNullCount = longStatsData.isSetNumDVs() ? OptionalLong.of(longStatsData.getNumDVs()) : OptionalLong.empty(); return createIntegerColumnStatistics(min, max, nullsCount, distinctValuesWithNullCount); @@ -585,6 +598,14 @@ public static HiveColumnStatistics fromMetastoreApiColumnStatistics(ColumnStatis averageColumnLength, nullsCount); } + if (columnStatistics.getStatsData().isSetTimestampStats()) { + TimestampColumnStatsData timestampStatsData = columnStatistics.getStatsData().getTimestampStats(); + OptionalLong min = timestampStatsData.isSetLowValue() ? fromMetastoreTimestamp(timestampStatsData.getLowValue()) : OptionalLong.empty(); + OptionalLong max = timestampStatsData.isSetHighValue() ? fromMetastoreTimestamp(timestampStatsData.getHighValue()) : OptionalLong.empty(); + OptionalLong nullsCount = timestampStatsData.isSetNumNulls() ? fromMetastoreNullsCount(timestampStatsData.getNumNulls()) : OptionalLong.empty(); + OptionalLong distinctValuesWithNullCount = timestampStatsData.isSetNumDVs() ? OptionalLong.of(timestampStatsData.getNumDVs()) : OptionalLong.empty(); + return createIntegerColumnStatistics(min, max, nullsCount, distinctValuesWithNullCount); + } throw new TrinoException(HIVE_INVALID_METADATA, "Invalid column statistics data: " + columnStatistics); } @@ -609,6 +630,14 @@ public static OptionalLong fromMetastoreNullsCount(long nullsCount) return OptionalLong.of(nullsCount); } + private static OptionalLong fromMetastoreTimestamp(Timestamp timestamp) + { + if (timestamp == null) { + return OptionalLong.empty(); + } + return OptionalLong.of(LocalDateTime.ofEpochSecond(timestamp.getSecondsSinceEpoch(), 0, ZoneOffset.UTC).toInstant(ZoneOffset.UTC).toEpochMilli() * MICROSECONDS_PER_MILLISECOND); + } + private static Optional fromMetastoreDecimal(@Nullable Decimal decimal) { if (decimal == null) { @@ -768,8 +797,9 @@ public static ColumnStatisticsObj createMetastoreColumnStatistics(String columnN case SHORT: case INT: case LONG: - case TIMESTAMP: return createLongStatistics(columnName, columnType, statistics); + case TIMESTAMP: + return createTimestampStatistics(columnName, columnType, statistics); case FLOAT: case DOUBLE: return createDoubleStatistics(columnName, columnType, statistics); @@ -819,6 +849,18 @@ private static ColumnStatisticsObj createLongStatistics(String columnName, HiveT return new ColumnStatisticsObj(columnName, columnType.toString(), longStats(data)); } + private static ColumnStatisticsObj createTimestampStatistics(String columnName, HiveType columnType, HiveColumnStatistics statistics) + { + LongColumnStatsData data = new LongColumnStatsData(); + statistics.getIntegerStatistics().ifPresent(timestampStatistics -> { + timestampStatistics.getMin().ifPresent(value -> data.setLowValue(floorDiv(value, MICROSECONDS_PER_SECOND))); + timestampStatistics.getMax().ifPresent(value -> data.setHighValue(ceilDiv(value, MICROSECONDS_PER_SECOND))); + }); + statistics.getNullsCount().ifPresent(data::setNumNulls); + statistics.getDistinctValuesWithNullCount().ifPresent(data::setNumDVs); + return new ColumnStatisticsObj(columnName, columnType.toString(), longStats(data)); + } + private static ColumnStatisticsObj createDoubleStatistics(String columnName, HiveType columnType, HiveColumnStatistics statistics) { DoubleColumnStatsData data = new DoubleColumnStatsData(); @@ -893,8 +935,7 @@ public static Set getSupportedColumnStatistics(Type typ return ImmutableSet.of(MIN_VALUE, MAX_VALUE, NUMBER_OF_DISTINCT_VALUES, NUMBER_OF_NON_NULL_VALUES); } if (type instanceof TimestampType || type instanceof TimestampWithTimeZoneType) { - // TODO (https://github.com/trinodb/trino/issues/5859) Add support for timestamp MIN_VALUE, MAX_VALUE - return ImmutableSet.of(NUMBER_OF_DISTINCT_VALUES, NUMBER_OF_NON_NULL_VALUES); + return ImmutableSet.of(MIN_VALUE, MAX_VALUE, NUMBER_OF_DISTINCT_VALUES, NUMBER_OF_NON_NULL_VALUES); } if (type instanceof VarcharType || type instanceof CharType) { // TODO Collect MIN,MAX once it is used by the optimizer diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/statistics/AbstractHiveStatisticsProvider.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/statistics/AbstractHiveStatisticsProvider.java index fe5f1b0c48ba..e1df2a4b7cc5 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/statistics/AbstractHiveStatisticsProvider.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/statistics/AbstractHiveStatisticsProvider.java @@ -44,6 +44,7 @@ import io.trino.spi.statistics.TableStatistics; import io.trino.spi.type.CharType; import io.trino.spi.type.DecimalType; +import io.trino.spi.type.TimestampType; import io.trino.spi.type.Type; import io.trino.spi.type.VarcharType; @@ -843,6 +844,9 @@ private static Optional createRange(Type type, HiveColumnStatistics if (type.equals(DATE)) { return statistics.getDateStatistics().flatMap(AbstractHiveStatisticsProvider::createDateRange); } + if (type instanceof TimestampType) { + return statistics.getIntegerStatistics().flatMap(AbstractHiveStatisticsProvider::createTimestampRange); + } if (type instanceof DecimalType) { return statistics.getDecimalStatistics().flatMap(AbstractHiveStatisticsProvider::createDecimalRange); } @@ -895,6 +899,14 @@ private static Optional createDateRange(DateStatistics statistics) return Optional.empty(); } + private static Optional createTimestampRange(IntegerStatistics statistics) + { + if (statistics.getMin().isPresent() && statistics.getMax().isPresent()) { + return Optional.of(new DoubleRange(statistics.getMin().getAsLong(), statistics.getMax().getAsLong())); + } + return Optional.empty(); + } + private static Optional createDecimalRange(DecimalStatistics statistics) { if (statistics.getMin().isPresent() && statistics.getMax().isPresent()) { diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/util/Statistics.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/util/Statistics.java index 7de48dabb1d9..bd2cc9c42207 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/util/Statistics.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/util/Statistics.java @@ -26,10 +26,13 @@ import io.trino.spi.Page; import io.trino.spi.TrinoException; import io.trino.spi.block.Block; +import io.trino.spi.block.Fixed12Block; import io.trino.spi.statistics.ColumnStatisticMetadata; import io.trino.spi.statistics.ComputedStatistics; import io.trino.spi.type.DecimalType; import io.trino.spi.type.Decimals; +import io.trino.spi.type.LongTimestamp; +import io.trino.spi.type.TimestampType; import io.trino.spi.type.Type; import java.math.BigDecimal; @@ -65,6 +68,7 @@ import static io.trino.spi.type.IntegerType.INTEGER; import static io.trino.spi.type.RealType.REAL; import static io.trino.spi.type.SmallintType.SMALLINT; +import static io.trino.spi.type.TimestampType.MAX_PRECISION; import static io.trino.spi.type.TinyintType.TINYINT; import static java.lang.Float.intBitsToFloat; import static java.lang.Math.toIntExact; @@ -128,10 +132,12 @@ else if (type.equals(DOUBLE) || type.equals(REAL)) { else if (type.equals(DATE)) { result.setDateStatistics(new DateStatistics(Optional.empty(), Optional.empty())); } + else if (type instanceof TimestampType) { + result.setIntegerStatistics(new IntegerStatistics(OptionalLong.empty(), OptionalLong.empty())); + } else if (type instanceof DecimalType) { result.setDecimalStatistics(new DecimalStatistics(Optional.empty(), Optional.empty())); } - // TODO (https://github.com/trinodb/trino/issues/5859) Add support for timestamp else { throw new IllegalArgumentException("Unexpected type: " + type); } @@ -240,10 +246,12 @@ else if (type.equals(DOUBLE) || type.equals(REAL)) { else if (type.equals(DATE)) { result.setDateStatistics(new DateStatistics(getDateValue(type, min), getDateValue(type, max))); } + else if (type instanceof TimestampType) { + result.setIntegerStatistics(new IntegerStatistics(getTimestampValue(type, min), getTimestampValue(type, max))); + } else if (type instanceof DecimalType) { result.setDecimalStatistics(new DecimalStatistics(getDecimalValue(type, min), getDecimalValue(type, max))); } - // TODO (https://github.com/trinodb/trino/issues/5859) Add support for timestamp else { throw new IllegalArgumentException("Unexpected type: " + type); } @@ -288,6 +296,19 @@ private static Optional getDateValue(Type type, Block block) return Optional.of(LocalDate.ofEpochDay(days)); } + private static OptionalLong getTimestampValue(Type type, Block block) + { + verify(type instanceof TimestampType, "Unsupported type: %s", type); + if (block.isNull(0)) { + return OptionalLong.empty(); + } + if (block instanceof Fixed12Block) { + LongTimestamp ts = (LongTimestamp) TimestampType.createTimestampType(MAX_PRECISION).getObject(block, 0); + return OptionalLong.of(ts.getEpochMicros()); + } + return OptionalLong.of(type.getLong(block, 0)); + } + private static Optional getDecimalValue(Type type, Block block) { verify(type instanceof DecimalType, "Unsupported type: %s", type); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java index 7bc854803792..4d2de7524682 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java @@ -6595,7 +6595,7 @@ public void testCollectColumnStatisticsOnCreateTable() "('c_boolean', null, 2.0E0, 0.5E0, null, null, null), " + "('c_bigint', null, 2.0E0, 0.5E0, null, '0', '1'), " + "('c_double', null, 2.0E0, 0.5E0, null, '1.2', '2.2'), " + - "('c_timestamp', null, 2.0E0, 0.5E0, null, null, null), " + + "('c_timestamp', null, 2.0E0, 0.5E0, null, '2012-08-08 00:00:00.000', '2012-08-08 01:00:00.000'), " + "('c_varchar', 8.0E0, 2.0E0, 0.5E0, null, null, null), " + "('c_varbinary', 8.0E0, null, 0.5E0, null, null, null), " + "('p_varchar', 8.0E0, 1.0E0, 0.0E0, null, null, null), " + @@ -6605,7 +6605,7 @@ public void testCollectColumnStatisticsOnCreateTable() "('c_boolean', null, 2.0E0, 0.5E0, null, null, null), " + "('c_bigint', null, 2.0E0, 0.5E0, null, '1', '2'), " + "('c_double', null, 2.0E0, 0.5E0, null, '2.3', '3.3'), " + - "('c_timestamp', null, 2.0E0, 0.5E0, null, null, null), " + + "('c_timestamp', null, 2.0E0, 0.5E0, null, '2012-09-09 00:00:00.000', '2012-09-09 01:00:00.000'), " + "('c_varchar', 8.0E0, 2.0E0, 0.5E0, null, null, null), " + "('c_varbinary', 8.0E0, null, 0.5E0, null, null, null), " + "('p_varchar', 8.0E0, 1.0E0, 0.0E0, null, null, null), " + @@ -6652,7 +6652,7 @@ public void testCollectStatisticsOnCreateTableTimestampWithPrecision() assertQuery("SHOW STATS FOR " + tableName, "SELECT * FROM VALUES " + - "('c_timestamp', null, 9.0, 0.0, null, null, null), " + + "('c_timestamp', null, 9.0, 0.0, null, '1988-04-08 02:03:04.111', '1988-04-08 02:03:04.119'), " + "(null, null, null, null, 12.0, null, null)"); } finally { @@ -6698,7 +6698,7 @@ public void testCollectColumnStatisticsOnInsert() "('c_boolean', null, 2.0E0, 0.5E0, null, null, null), " + "('c_bigint', null, 2.0E0, 0.5E0, null, '0', '1'), " + "('c_double', null, 2.0E0, 0.5E0, null, '1.2', '2.2'), " + - "('c_timestamp', null, 2.0E0, 0.5E0, null, null, null), " + + "('c_timestamp', null, 2.0E0, 0.5E0, null, '2012-08-08 00:00:00.000', '2012-08-08 01:00:00.000'), " + "('c_varchar', 8.0E0, 2.0E0, 0.5E0, null, null, null), " + "('c_varbinary', 8.0E0, null, 0.5E0, null, null, null), " + "('p_varchar', 8.0E0, 1.0E0, 0.0E0, null, null, null), " + @@ -6708,7 +6708,7 @@ public void testCollectColumnStatisticsOnInsert() "('c_boolean', null, 2.0E0, 0.5E0, null, null, null), " + "('c_bigint', null, 2.0E0, 0.5E0, null, '1', '2'), " + "('c_double', null, 2.0E0, 0.5E0, null, '2.3', '3.3'), " + - "('c_timestamp', null, 2.0E0, 0.5E0, null, null, null), " + + "('c_timestamp', null, 2.0E0, 0.5E0, null, '2012-09-09 00:00:00.000', '2012-09-09 01:00:00.000'), " + "('c_varchar', 8.0E0, 2.0E0, 0.5E0, null, null, null), " + "('c_varbinary', 8.0E0, null, 0.5E0, null, null, null), " + "('p_varchar', 8.0E0, 1.0E0, 0.0E0, null, null, null), " + @@ -6892,7 +6892,7 @@ public void testAnalyzePartitionedTable() ('c_boolean', null, 2.0, 0.5, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '0', '1'), ('c_double', null, 2.0, 0.5, null, '1.2', '2.2'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-08-08 00:00:00.000', '2012-08-08 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', 4.0, null, 0.5, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -6905,7 +6905,7 @@ public void testAnalyzePartitionedTable() ('c_boolean', null, 2.0, 0.5, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '1', '2'), ('c_double', null, 2.0, 0.5, null, '2.3', '3.3'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-09-09 00:00:00.000', '2012-09-09 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', 4.0, null, 0.5, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -6919,7 +6919,7 @@ public void testAnalyzePartitionedTable() ('c_boolean', null, 1.0, 0.0, null, null, null), ('c_bigint', null, 4.0, 0.0, null, '4', '7'), ('c_double', null, 4.0, 0.0, null, '4.7', '7.7'), - ('c_timestamp', null, 4.0, 0.0, null, null, null), + ('c_timestamp', null, 4.0, 0.0, null, '1977-07-07 07:04:00.000', '1977-07-07 07:07:00.000'), ('c_varchar', 16.0, 4.0, 0.0, null, null, null), ('c_varbinary', 8.0, null, 0.0, null, null, null), ('p_varchar', 0.0, 0.0, 1.0, null, null, null), @@ -6978,7 +6978,7 @@ public void testAnalyzePartitionedTable() ('c_boolean', null, 2.0, 0.5, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '0', '1'), ('c_double', null, 2.0, 0.5, null, '1.2', '2.2'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-08-08 00:00:00.000', '2012-08-08 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', 4.0, null, 0.5, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -6991,7 +6991,7 @@ public void testAnalyzePartitionedTable() ('c_boolean', null, 2.0, 0.5, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '1', '2'), ('c_double', null, 2.0, 0.5, null, '2.3', '3.3'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-09-09 00:00:00.000', '2012-09-09 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', 4.0, null, 0.5, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -7004,7 +7004,7 @@ public void testAnalyzePartitionedTable() ('c_boolean', null, 1.0, 0.0, null, null, null), ('c_bigint', null, 4.0, 0.0, null, '4', '7'), ('c_double', null, 4.0, 0.0, null, '4.7', '7.7'), - ('c_timestamp', null, 4.0, 0.0, null, null, null), + ('c_timestamp', null, 4.0, 0.0, null, '1977-07-07 07:04:00.000', '1977-07-07 07:07:00.000'), ('c_varchar', 16.0, 4.0, 0.0, null, null, null), ('c_varbinary', 8.0, null, 0.0, null, null, null), ('p_varchar', 0.0, 0.0, 1.0, null, null, null), @@ -7017,7 +7017,7 @@ public void testAnalyzePartitionedTable() ('c_boolean', null, 2.0, 0.5, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '2', '3'), ('c_double', null, 2.0, 0.5, null, '3.4', '4.4'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-10-10 00:00:00.000', '2012-10-10 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', 4.0, null, 0.5, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -7090,7 +7090,7 @@ public void testAnalyzePartitionedTableWithColumnSubset() ('c_boolean', null, null, null, null, null, null), ('c_bigint', null, null, null, null, null, null), ('c_double', null, null, null, null, null, null), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-08-08 00:00:00.000', '2012-08-08 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', null, null, null, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -7104,7 +7104,7 @@ public void testAnalyzePartitionedTableWithColumnSubset() ('c_boolean', null, null, null, null, null, null), ('c_bigint', null, null, null, null, null, null), ('c_double', null, null, null, null, null, null), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-09-09 00:00:00.000', '2012-09-09 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', null, null, null, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -7118,7 +7118,7 @@ public void testAnalyzePartitionedTableWithColumnSubset() ('c_boolean', null, null, null, null, null, null), ('c_bigint', null, null, null, null, null, null), ('c_double', null, null, null, null, null, null), - ('c_timestamp', null, 4.0, 0.0, null, null, null), + ('c_timestamp', null, 4.0, 0.0, null, '1977-07-07 07:04:00.000', '1977-07-07 07:07:00.000'), ('c_varchar', 16.0, 4.0, 0.0, null, null, null), ('c_varbinary', null, null, null, null, null, null), ('p_varchar', 0.0, 0.0, 1.0, null, null, null), @@ -7182,7 +7182,7 @@ public void testAnalyzePartitionedTableWithColumnSubset() ('c_boolean', null, null, null, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '0', '1'), ('c_double', null, 2.0, 0.5, null, '1.2', '2.2'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-08-08 00:00:00.000', '2012-08-08 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', null, null, null, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -7196,7 +7196,7 @@ public void testAnalyzePartitionedTableWithColumnSubset() ('c_boolean', null, null, null, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '1', '2'), ('c_double', null, 2.0, 0.5, null, '2.3', '3.3'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-09-09 00:00:00.000', '2012-09-09 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', null, null, null, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -7210,7 +7210,7 @@ public void testAnalyzePartitionedTableWithColumnSubset() ('c_boolean', null, null, null, null, null, null), ('c_bigint', null, 4.0, 0.0, null, '4', '7'), ('c_double', null, 4.0, 0.0, null, '4.7', '7.7'), - ('c_timestamp', null, 4.0, 0.0, null, null, null), + ('c_timestamp', null, 4.0, 0.0, null, '1977-07-07 07:04:00.000', '1977-07-07 07:07:00.000'), ('c_varchar', 16.0, 4.0, 0.0, null, null, null), ('c_varbinary', null, null, null, null, null, null), ('p_varchar', 0.0, 0.0, 1.0, null, null, null), @@ -7260,6 +7260,94 @@ public void testAnalyzePartitionedTableWithColumnSubset() (null, null, null, null, null, null, null) """); + assertUpdate( + format("ANALYZE %s WITH (columns = ARRAY['c_timestamp'])", tableName), 16); + + assertQuery( + format("SHOW STATS FOR (SELECT * FROM %s WHERE p_varchar = 'p1' AND p_bigint = 7)", tableName), + """ + SELECT * FROM VALUES + ('c_boolean', null, null, null, null, null, null), + ('c_bigint', null, 2.0, 0.5, null, '0', '1'), + ('c_double', null, 2.0, 0.5, null, '1.2', '2.2'), + ('c_timestamp', null, 2.0, 0.5, null, '2012-08-08 00:00:00.000', '2012-08-08 01:00:00.000'), + ('c_varchar', 8.0, 2.0, 0.5, null, null, null), + ('c_varbinary', null, null, null, null, null, null), + ('p_varchar', 8.0, 1.0, 0.0, null, null, null), + ('p_bigint', null, 1.0, 0.0, null, '7', '7'), + (null, null, null, null, 4.0, null, null) + """); + assertQuery( + format("SHOW STATS FOR (SELECT * FROM %s WHERE p_varchar = 'p2' AND p_bigint = 7)", tableName), + """ + SELECT * FROM VALUES + ('c_boolean', null, null, null, null, null, null), + ('c_bigint', null, 2.0, 0.5, null, '1', '2'), + ('c_double', null, 2.0, 0.5, null, '2.3', '3.3'), + ('c_timestamp', null, 2.0, 0.5, null, '2012-09-09 00:00:00.000', '2012-09-09 01:00:00.000'), + ('c_varchar', 8.0, 2.0, 0.5, null, null, null), + ('c_varbinary', null, null, null, null, null, null), + ('p_varchar', 8.0, 1.0, 0.0, null, null, null), + ('p_bigint', null, 1.0, 0.0, null, '7', '7'), + (null, null, null, null, 4.0, null, null) + """); + assertQuery( + format("SHOW STATS FOR (SELECT * FROM %s WHERE p_varchar IS NULL AND p_bigint IS NULL)", tableName), + """ + SELECT * FROM VALUES + ('c_boolean', null, null, null, null, null, null), + ('c_bigint', null, 4.0, 0.0, null, '4', '7'), + ('c_double', null, 4.0, 0.0, null, '4.7', '7.7'), + ('c_timestamp', null, 4.0, 0.0, null, '1977-07-07 07:04:00.000', '1977-07-07 07:07:00.000'), + ('c_varchar', 16.0, 4.0, 0.0, null, null, null), + ('c_varbinary', null, null, null, null, null, null), + ('p_varchar', 0.0, 0.0, 1.0, null, null, null), + ('p_bigint', 0.0, 0.0, 1.0, null, null, null), + (null, null, null, null, 4.0, null, null) + """); + assertQuery( + format("SHOW STATS FOR (SELECT * FROM %s WHERE p_varchar = 'p3' AND p_bigint = 8)", tableName), + """ + SELECT * FROM VALUES + ('c_boolean', null, null, null, null, null, null), + ('c_bigint', null, 2.0, 0.5, null, '2', '3'), + ('c_double', null, 2.0, 0.5, null, '3.4', '4.4'), + ('c_timestamp', null, 2.0, 0.5, null, '2012-10-10 00:00:00.000', '2012-10-10 01:00:00.000'), + ('c_varchar', null, null, null, null, null, null), + ('c_varbinary', null, null, null, null, null, null), + ('p_varchar', 8.0, 1.0, 0.0, null, null, null), + ('p_bigint', null, 1.0, 0.0, null, '8', '8'), + (null, null, null, null, 4.0, null, null) + """); + assertQuery( + format("SHOW STATS FOR (SELECT * FROM %s WHERE p_varchar = 'e1' AND p_bigint = 9)", tableName), + """ + SELECT * FROM VALUES + ('c_boolean', null, null, null, null, null, null), + ('c_bigint', null, null, null, null, null, null), + ('c_double', null, null, null, null, null, null), + ('c_timestamp', null, null, null, null, null, null), + ('c_varchar', null, null, null, null, null, null), + ('c_varbinary', null, null, null, null, null, null), + ('p_varchar', null, 1.0, 0.0, null, null, null), + ('p_bigint', null, 1.0, 0.0, null, 9, 9), + (null, null, null, null, null, null, null) + """); + assertQuery( + format("SHOW STATS FOR (SELECT * FROM %s WHERE p_varchar = 'e2' AND p_bigint = 9)", tableName), + """ + SELECT * FROM VALUES + ('c_boolean', null, null, null, null, null, null), + ('c_bigint', null, null, null, null, null, null), + ('c_double', null, null, null, null, null, null), + ('c_timestamp', null, null, null, null, null, null), + ('c_varchar', null, null, null, null, null, null), + ('c_varbinary', null, null, null, null, null, null), + ('p_varchar', null, 1.0, 0.0, null, null, null), + ('p_bigint', null, 1.0, 0.0, null, 9, 9), + (null, null, null, null, null, null, null) + """); + assertUpdate("DROP TABLE " + tableName); } @@ -7293,7 +7381,7 @@ public void testAnalyzeUnpartitionedTable() ('c_boolean', null, 2.0, 0.375, null, null, null), ('c_bigint', null, 8.0, 0.375, null, '0', '7'), ('c_double', null, 10.0, 0.375, null, '1.2', '7.7'), - ('c_timestamp', null, 10.0, 0.375, null, null, null), + ('c_timestamp', null, 10.0, 0.375, null, '1977-07-07 07:04:00.000', '2012-10-10 01:00:00.000'), ('c_varchar', 40.0, 10.0, 0.375, null, null, null), ('c_varbinary', 20.0, null, 0.375, null, null, null), ('p_varchar', 24.0, 3.0, 0.25, null, null, null), @@ -7345,21 +7433,21 @@ public void testAnalyzeTableTimestampWithPrecision() assertUpdate(nanosecondsTimestamp, "ANALYZE " + tableName, 12); assertQuery("SHOW STATS FOR " + tableName, "SELECT * FROM VALUES " + - "('c_timestamp', null, 9.0, 0.0, null, null, null), " + + "('c_timestamp', null, 9.0, 0.0, null, '1988-04-08 02:03:04.111', '1988-04-08 02:03:04.119'), " + "(null, null, null, null, 12.0, null, null)"); assertUpdate(format("CALL system.drop_stats('%s', '%s')", TPCH_SCHEMA, tableName)); assertUpdate(microsecondsTimestamp, "ANALYZE " + tableName, 12); assertQuery("SHOW STATS FOR " + tableName, "SELECT * FROM VALUES " + - "('c_timestamp', null, 7.0, 0.0, null, null, null), " + + "('c_timestamp', null, 7.0, 0.0, null, '1988-04-08 02:03:04.111', '1988-04-08 02:03:04.119'), " + "(null, null, null, null, 12.0, null, null)"); assertUpdate(format("CALL system.drop_stats('%s', '%s')", TPCH_SCHEMA, tableName)); assertUpdate(millisecondsTimestamp, "ANALYZE " + tableName, 12); assertQuery("SHOW STATS FOR " + tableName, "SELECT * FROM VALUES " + - "('c_timestamp', null, 4.0, 0.0, null, null, null), " + + "('c_timestamp', null, 4.0, 0.0, null, '1988-04-08 02:03:04.111', '1988-04-08 02:03:04.119'), " + "(null, null, null, null, 12.0, null, null)"); } finally { @@ -7488,7 +7576,7 @@ public void testDropStatsPartitionedTable() ('c_boolean', null, 2.0, 0.5, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '0', '1'), ('c_double', null, 2.0, 0.5, null, '1.2', '2.2'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-08-08 00:00:00.000', '2012-08-08 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', 4.0, null, 0.5, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -7501,7 +7589,7 @@ public void testDropStatsPartitionedTable() ('c_boolean', null, 2.0, 0.5, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '1', '2'), ('c_double', null, 2.0, 0.5, null, '2.3', '3.3'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-09-09 00:00:00.000', '2012-09-09 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', 4.0, null, 0.5, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -7514,7 +7602,7 @@ public void testDropStatsPartitionedTable() ('c_boolean', null, 1.0, 0.0, null, null, null), ('c_bigint', null, 4.0, 0.0, null, '4', '7'), ('c_double', null, 4.0, 0.0, null, '4.7', '7.7'), - ('c_timestamp', null, 4.0, 0.0, null, null, null), + ('c_timestamp', null, 4.0, 0.0, null, '1977-07-07 07:04:00.000', '1977-07-07 07:07:00.000'), ('c_varchar', 16.0, 4.0, 0.0, null, null, null), ('c_varbinary', 8.0, null, 0.0, null, null, null), ('p_varchar', 0.0, 0.0, 1.0, null, null, null), @@ -7527,7 +7615,7 @@ public void testDropStatsPartitionedTable() ('c_boolean', null, 2.0, 0.5, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '2', '3'), ('c_double', null, 2.0, 0.5, null, '3.4', '4.4'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-10-10 00:00:00.000', '2012-10-10 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', 4.0, null, 0.5, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -7576,7 +7664,7 @@ public void testDropStatsPartitionedTable() ('c_boolean', null, 2.0, 0.5, null, null, null), ('c_bigint', null, 2.0, 0.5, null, '0', '1'), ('c_double', null, 2.0, 0.5, null, '1.2', '2.2'), - ('c_timestamp', null, 2.0, 0.5, null, null, null), + ('c_timestamp', null, 2.0, 0.5, null, '2012-08-08 00:00:00.000', '2012-08-08 01:00:00.000'), ('c_varchar', 8.0, 2.0, 0.5, null, null, null), ('c_varbinary', 4.0, null, 0.5, null, null, null), ('p_varchar', 8.0, 1.0, 0.0, null, null, null), @@ -7604,7 +7692,7 @@ public void testDropStatsPartitionedTable() ('c_boolean', null, 1.0, 0.0, null, null, null), ('c_bigint', null, 4.0, 0.0, null, '4', '7'), ('c_double', null, 4.0, 0.0, null, '4.7', '7.7'), - ('c_timestamp', null, 4.0, 0.0, null, null, null), + ('c_timestamp', null, 4.0, 0.0, null, '1977-07-07 07:04:00.000', '1977-07-07 07:07:00.000'), ('c_varchar', 16.0, 4.0, 0.0, null, null, null), ('c_varbinary', 8.0, null, 0.0, null, null, null), ('p_varchar', 0.0, 0.0, 1.0, null, null, null), @@ -7774,7 +7862,7 @@ public void testDropStatsUnpartitionedTable() "('c_boolean', null, 2.0, 0.375, null, null, null), " + "('c_bigint', null, 8.0, 0.375, null, '0', '7'), " + "('c_double', null, 10.0, 0.375, null, '1.2', '7.7'), " + - "('c_timestamp', null, 10.0, 0.375, null, null, null), " + + "('c_timestamp', null, 10.0, 0.375, null, '1977-07-07 07:04:00.000', '2012-10-10 01:00:00.000'), " + "('c_varchar', 40.0, 10.0, 0.375, null, null, null), " + "('c_varbinary', 20.0, null, 0.375, null, null, null), " + "('p_varchar', 24.0, 3.0, 0.25, null, null, null), " + diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseTestHiveOnDataLake.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseTestHiveOnDataLake.java index c86c8fcfe34e..eb7f663cda3a 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseTestHiveOnDataLake.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseTestHiveOnDataLake.java @@ -2251,6 +2251,46 @@ public void testUnsupportedDropSchemaCascadeWithNonHiveTable() } } + @Test + public void testSupportTimestampStatisticsForHive3andHive4() + { + Session session = Session.builder(getQueryRunner().getDefaultSession()) + .setCatalogSessionProperty("hive", "insert_existing_partitions_behavior", "APPEND") + .setCatalogSessionProperty("hive", "collect_column_statistics_on_write", "true") + .build(); + String testTable = HIVE_TEST_SCHEMA + ".test_tabble_" + randomNameSuffix(); + assertUpdate(session, "CREATE TABLE " + testTable + "(\n" + + " VendorID BIGINT,\n" + + " tpep_pickup_datetime TIMESTAMP,\n" + + " tpep_dropoff_datetime TIMESTAMP,\n" + + " passenger_count DOUBLE,\n" + + " trip_distance DOUBLE,\n" + + " payment_type BIGINT,\n" + + " Fare_amount DOUBLE,\n" + + " Tip_amount DOUBLE,\n" + + " Total_amount DOUBLE\n" + + ")"); + assertUpdate(session, "INSERT INTO " + testTable + " VALUES(1, TIMESTAMP '2025-09-19 10:00:00', TIMESTAMP '2025-09-19 10:10:00', 2, 3.5, 1, 10.0, 2.0, 12.0)", 1); + assertUpdate(session, "ANALYZE " + testTable, 1); + assertUpdate(session, "ANALYZE " + testTable, 1); + + assertQuery( + "SHOW STATS FOR " + testTable, + """ + VALUES + ('vendorid', null, '1.0', '0.0', null, '1', '1'), + ('tpep_pickup_datetime', null, '1.0', '0.0', null, '2025-09-19 10:00:00.000', '2025-09-19 10:00:00.000'), + ('tpep_dropoff_datetime', null, '1.0', '0.0', null, '2025-09-19 10:10:00.000', '2025-09-19 10:10:00.000'), + ('passenger_count', null, '1.0', '0.0', null, '2.0', '2.0'), + ('trip_distance', null, '1.0', '0.0', null, '3.5', '3.5'), + ('payment_type', null, '1.0', '0.0', null, '1', '1'), + ('fare_amount', null, '1.0', '0.0', null, '10.0', '10.0'), + ('tip_amount', null, '1.0', '0.0', null, '2.0', '2.0'), + ('total_amount', null, '1.0', '0.0', null, '12.0', '12.0'), + (null, null, null, null, '1.0', null, null) + """); + } + @Test public void testUnsupportedCommentOnHiveView() { diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveQueryRunner.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveQueryRunner.java index 2eb36d67a8e5..798d033f9181 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveQueryRunner.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/HiveQueryRunner.java @@ -417,8 +417,7 @@ public static void main(String[] args) .setSchema("tpch") .build()) .addCoordinatorProperty("http-server.http.port", "8080") - .addHiveProperty("hive.metastore", "glue") - .addHiveProperty("hive.metastore.glue.default-warehouse-dir", "local:///glue") + .addHiveProperty("hive.metastore.uri", "thrift://hive-metastore:9083") .addHiveProperty("hive.security", "allow-all") .setCreateTpchSchemas(false) .build(); diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTableStatistics.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTableStatistics.java index aff4c7072059..1e4599b442ea 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTableStatistics.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveTableStatistics.java @@ -129,7 +129,7 @@ private static List getAllTypesTableStatistics() row("c_double", null, 2.0, 0.0, null, "234.561", "235.567"), row("c_decimal", null, 2.0, 0.0, null, "345.0", "346.0"), row("c_decimal_w_params", null, 2.0, 0.0, null, "345.671", "345.678"), - row("c_timestamp", null, 2.0, 0.0, null, null, null), + row("c_timestamp", null, 2.0, 0.0, null, "2015-05-10 12:15:31.000", "2015-05-10 12:15:36.000"), row("c_date", null, 2.0, 0.0, null, "2015-05-09", "2015-06-10"), row("c_string", 22.0, 2.0, 0.0, null, null, null), row("c_varchar", 20.0, 2.0, 0.0, null, null, null), @@ -529,7 +529,7 @@ public void testStatisticsForAllDataTypes() row("c_double", null, 2.0, 0.0, null, "234.561", "235.567"), row("c_decimal", null, 2.0, 0.0, null, "345.0", "346.0"), row("c_decimal_w_params", null, 2.0, 0.0, null, "345.671", "345.678"), - row("c_timestamp", null, 2.0, 0.0, null, null, null), + row("c_timestamp", null, 2.0, 0.0, null, "2015-05-10 12:15:31.000", "2015-05-10 12:15:35.000"), row("c_date", null, 2.0, 0.0, null, "2015-05-09", "2015-06-10"), row("c_string", 22.0, 2.0, 0.0, null, null, null), row("c_varchar", 20.0, 2.0, 0.0, null, null, null), @@ -908,7 +908,7 @@ public void testAnalyzeForAllDataTypes() row("c_double", null, 2.0, 0.0, null, "234.561", "235.567"), row("c_decimal", null, 2.0, 0.0, null, "345.0", "346.0"), row("c_decimal_w_params", null, 2.0, 0.0, null, "345.671", "345.678"), - row("c_timestamp", null, 2.0, 0.0, null, null, null), + row("c_timestamp", null, 2.0, 0.0, null, "2015-05-10 12:15:31.000", "2015-05-10 12:15:36.000"), row("c_date", null, 2.0, 0.0, null, "2015-05-09", "2015-06-10"), row("c_string", 22.0, 2.0, 0.0, null, null, null), row("c_varchar", 20.0, 2.0, 0.0, null, null, null), @@ -1053,7 +1053,7 @@ public void testComputeTableStatisticsOnInsert() row("c_double", null, 2.0, 0.5, null, "234.561", "235.567"), row("c_decimal", null, 2.0, 0.5, null, "345.0", "346.0"), row("c_decimal_w_params", null, 2.0, 0.5, null, "345.671", "345.678"), - row("c_timestamp", null, 2.0, 0.5, null, null, null), + row("c_timestamp", null, 2.0, 0.5, null, "2015-05-10 12:15:31.000", "2015-05-10 12:15:36.000"), row("c_date", null, 2.0, 0.5, null, "2015-05-09", "2015-06-10"), row("c_string", 22.0, 2.0, 0.5, null, null, null), row("c_varchar", 20.0, 2.0, 0.5, null, null, null), @@ -1088,7 +1088,7 @@ public void testComputeTableStatisticsOnInsert() row("c_double", null, 2.0, 0.4, null, "234.56", "235.567"), row("c_decimal", null, 2.0, 0.4, null, "343.0", "346.0"), row("c_decimal_w_params", null, 2.0, 0.4, null, "345.67", "345.678"), - row("c_timestamp", null, 2.0, 0.4, null, null, null), + row("c_timestamp", null, 2.0, 0.4, null, "2015-05-10 12:15:30.000", "2015-05-10 12:15:36.000"), row("c_date", null, 2.0, 0.4, null, "2015-05-08", "2015-06-10"), row("c_string", 32.0001, 2.0, 0.4, null, null, null), row("c_varchar", 29.0001, 2.0, 0.4, null, null, null), @@ -1164,7 +1164,7 @@ public void testComputePartitionStatisticsOnCreateTable() row("c_double", null, 1.0, 0.5, null, "234.56", "234.56"), row("c_decimal", null, 1.0, 0.5, null, "343.0", "343.0"), row("c_decimal_w_params", null, 1.0, 0.5, null, "345.67", "345.67"), - row("c_timestamp", null, 1.0, 0.5, null, null, null), + row("c_timestamp", null, 1.0, 0.5, null, "2015-05-10 12:15:30.000", "2015-05-10 12:15:30.000"), row("c_date", null, 1.0, 0.5, null, "2015-05-08", "2015-05-08"), row("c_string", 10.0, 1.0, 0.5, null, null, null), row("c_varchar", 10.0, 1.0, 0.5, null, null, null), @@ -1184,7 +1184,7 @@ public void testComputePartitionStatisticsOnCreateTable() row("c_double", null, 1.0, 0.5, null, "777.56", "777.56"), row("c_decimal", null, 1.0, 0.5, null, "888.0", "888.0"), row("c_decimal_w_params", null, 1.0, 0.5, null, "999.67", "999.67"), - row("c_timestamp", null, 1.0, 0.5, null, null, null), + row("c_timestamp", null, 1.0, 0.5, null, "2015-05-10 12:45:30.000", "2015-05-10 12:45:30.000"), row("c_date", null, 1.0, 0.5, null, "2015-05-09", "2015-05-09"), row("c_string", 10.0, 1.0, 0.5, null, null, null), row("c_varchar", 10.0, 1.0, 0.5, null, null, null), @@ -1250,7 +1250,7 @@ public void testComputePartitionStatisticsOnInsert() row("c_double", null, 1.0, 0.5, null, "234.56", "234.56"), row("c_decimal", null, 1.0, 0.5, null, "343.0", "343.0"), row("c_decimal_w_params", null, 1.0, 0.5, null, "345.67", "345.67"), - row("c_timestamp", null, 1.0, 0.5, null, null, null), + row("c_timestamp", null, 1.0, 0.5, null, "2015-05-10 12:15:30.000", "2015-05-10 12:15:30.000"), row("c_date", null, 1.0, 0.5, null, "2015-05-08", "2015-05-08"), row("c_string", 10.0, 1.0, 0.5, null, null, null), row("c_varchar", 10.0, 1.0, 0.5, null, null, null), @@ -1270,7 +1270,7 @@ public void testComputePartitionStatisticsOnInsert() row("c_double", null, 1.0, 0.5, null, "777.56", "777.56"), row("c_decimal", null, 1.0, 0.5, null, "888.0", "888.0"), row("c_decimal_w_params", null, 1.0, 0.5, null, "999.67", "999.67"), - row("c_timestamp", null, 1.0, 0.5, null, null, null), + row("c_timestamp", null, 1.0, 0.5, null, "2015-05-10 12:45:30.000", "2015-05-10 12:45:30.000"), row("c_date", null, 1.0, 0.5, null, "2015-05-09", "2015-05-09"), row("c_string", 10.0, 1.0, 0.5, null, null, null), row("c_varchar", 10.0, 1.0, 0.5, null, null, null), @@ -1293,7 +1293,7 @@ public void testComputePartitionStatisticsOnInsert() row("c_double", null, 1.0, 0.5, null, "233.56", "234.56"), row("c_decimal", null, 1.0, 0.5, null, "342.0", "343.0"), row("c_decimal_w_params", null, 1.0, 0.5, null, "344.67", "345.67"), - row("c_timestamp", null, 1.0, 0.5, null, null, null), + row("c_timestamp", null, 1.0, 0.5, null, "2015-05-10 12:15:29.000", "2015-05-10 12:15:30.000"), row("c_date", null, 1.0, 0.5, null, "2015-05-07", "2015-05-08"), row("c_string", 20.0, 1.0, 0.5, null, null, null), row("c_varchar", 20.0, 1.0, 0.5, null, null, null), @@ -1316,7 +1316,7 @@ public void testComputePartitionStatisticsOnInsert() row("c_double", null, 1.0, 0.5, null, "777.56", "778.56"), row("c_decimal", null, 1.0, 0.5, null, "888.0", "889.0"), row("c_decimal_w_params", null, 1.0, 0.5, null, "999.67", "1000.67"), - row("c_timestamp", null, 1.0, 0.5, null, null, null), + row("c_timestamp", null, 1.0, 0.5, null, "2015-05-10 12:45:30.000", "2015-05-10 12:45:31.000"), row("c_date", null, 1.0, 0.5, null, "2015-05-09", "2015-05-10"), row("c_string", 20.0, 1.0, 0.5, null, null, null), row("c_varchar", 20.0, 1.0, 0.5, null, null, null), diff --git a/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunner.java b/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunner.java index 28fc5955e8cb..8813b502b69d 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunner.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/tpch/TpchQueryRunner.java @@ -17,6 +17,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.airlift.log.Logger; import io.airlift.log.Logging; +import io.trino.plugin.hive.HivePlugin; +import io.trino.plugin.memory.MemoryPlugin; import io.trino.plugin.tpch.TpchPlugin; import io.trino.testing.DistributedQueryRunner; import io.trino.testing.QueryRunner; @@ -83,6 +85,14 @@ public static void main(String[] args) .buildOrThrow()) .withProtocolSpooling("json+zstd") .build(); + + // 👉 Подключаем memory + queryRunner.installPlugin(new MemoryPlugin()); + queryRunner.createCatalog("memory", "memory"); + + queryRunner.installPlugin(new HivePlugin()); + queryRunner.createCatalog("hive", "hive"); + Logger log = Logger.get(TpchQueryRunner.class); log.info("======== SERVER STARTED ========"); log.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl());