Search in sources :

Example 21 with ColumnStatistics

use of io.trino.spi.statistics.ColumnStatistics in project trino by trinodb.

the class TestDeltaLakeMetastoreStatistics method testStatisticsNegativeInfinityAndNaN.

@Test
public void testStatisticsNegativeInfinityAndNaN() {
    // Stats with NaN values cannot be used
    DeltaLakeTableHandle tableHandle = registerTable("negative_infinity_nan");
    TableStatistics stats = deltaLakeMetastore.getTableStatistics(SESSION, tableHandle, Constraint.alwaysTrue());
    ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE);
    assertEquals(columnStatistics.getRange().get().getMin(), NEGATIVE_INFINITY);
    assertEquals(columnStatistics.getRange().get().getMax(), POSITIVE_INFINITY);
}
Also used : ColumnStatistics(io.trino.spi.statistics.ColumnStatistics) TableStatistics(io.trino.spi.statistics.TableStatistics) DeltaLakeTableHandle(io.trino.plugin.deltalake.DeltaLakeTableHandle) Test(org.testng.annotations.Test)

Example 22 with ColumnStatistics

use of io.trino.spi.statistics.ColumnStatistics in project trino by trinodb.

the class TestDeltaLakeMetastoreStatistics method assertEmptyStats.

private void assertEmptyStats(TableStatistics tableStatistics) {
    assertEquals(tableStatistics.getRowCount(), Estimate.of(0));
    ColumnStatistics columnStatistics = tableStatistics.getColumnStatistics().get(COLUMN_HANDLE);
    assertEquals(columnStatistics.getNullsFraction(), Estimate.of(0));
    assertEquals(columnStatistics.getDistinctValuesCount(), Estimate.of(0));
}
Also used : ColumnStatistics(io.trino.spi.statistics.ColumnStatistics)

Example 23 with ColumnStatistics

use of io.trino.spi.statistics.ColumnStatistics in project trino by trinodb.

the class TestDeltaLakeMetastoreStatistics method testStatisticsNegInf.

@Test
public void testStatisticsNegInf() {
    DeltaLakeTableHandle tableHandle = registerTable("negative_infinity");
    TableStatistics stats = deltaLakeMetastore.getTableStatistics(SESSION, tableHandle, Constraint.alwaysTrue());
    ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE);
    assertEquals(columnStatistics.getRange().get().getMin(), NEGATIVE_INFINITY);
    assertEquals(columnStatistics.getRange().get().getMax(), NEGATIVE_INFINITY);
}
Also used : ColumnStatistics(io.trino.spi.statistics.ColumnStatistics) TableStatistics(io.trino.spi.statistics.TableStatistics) DeltaLakeTableHandle(io.trino.plugin.deltalake.DeltaLakeTableHandle) Test(org.testng.annotations.Test)

Example 24 with ColumnStatistics

use of io.trino.spi.statistics.ColumnStatistics in project trino by trinodb.

the class TestDeltaLakeMetastoreStatistics method testStatisticsNegZero.

@Test
public void testStatisticsNegZero() {
    DeltaLakeTableHandle tableHandle = registerTable("negative_zero");
    TableStatistics stats = deltaLakeMetastore.getTableStatistics(SESSION, tableHandle, Constraint.alwaysTrue());
    ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE);
    assertEquals(columnStatistics.getRange().get().getMin(), -0.0d);
    assertEquals(columnStatistics.getRange().get().getMax(), -0.0d);
}
Also used : ColumnStatistics(io.trino.spi.statistics.ColumnStatistics) TableStatistics(io.trino.spi.statistics.TableStatistics) DeltaLakeTableHandle(io.trino.plugin.deltalake.DeltaLakeTableHandle) Test(org.testng.annotations.Test)

Aggregations

ColumnStatistics (io.trino.spi.statistics.ColumnStatistics)24 TableStatistics (io.trino.spi.statistics.TableStatistics)23 Test (org.testng.annotations.Test)15 DeltaLakeTableHandle (io.trino.plugin.deltalake.DeltaLakeTableHandle)14 ColumnHandle (io.trino.spi.connector.ColumnHandle)10 Type (io.trino.spi.type.Type)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 HiveColumnStatistics (io.trino.plugin.hive.metastore.HiveColumnStatistics)5 CharType (io.trino.spi.type.CharType)5 VarcharType (io.trino.spi.type.VarcharType)5 Map (java.util.Map)5 SchemaTableName (io.trino.spi.connector.SchemaTableName)4 DecimalType (io.trino.spi.type.DecimalType)4 Objects.requireNonNull (java.util.Objects.requireNonNull)4 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)3 Preconditions.checkState (com.google.common.base.Preconditions.checkState)3 Verify.verify (com.google.common.base.Verify.verify)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)3