Search in sources :

Example 6 with HiveTimestampPrecision

use of io.trino.plugin.hive.HiveTimestampPrecision in project trino by trinodb.

the class TestHiveStorageFormats method assertSimpleTimestamps.

/**
 * Assertions for tables created by {@link #createSimpleTimestampTable(String, StorageFormat)}
 */
private static void assertSimpleTimestamps(String tableName, List<TimestampAndPrecision> data) {
    SoftAssertions softly = new SoftAssertions();
    for (TimestampAndPrecision entry : data) {
        for (HiveTimestampPrecision precision : HiveTimestampPrecision.values()) {
            setTimestampPrecision(precision);
            // Assert also with `CAST AS varchar` on the server side to avoid any JDBC-related issues
            softly.check(() -> assertThat(onTrino().executeQuery(format("SELECT id, typeof(ts), CAST(ts AS varchar), ts FROM %s WHERE id = %s", tableName, entry.getId()))).as("timestamp(%d)", precision.getPrecision()).containsOnly(row(entry.getId(), entry.getReadType(precision), entry.getReadValue(precision), Timestamp.valueOf(entry.getReadValue(precision)))));
        }
    }
    softly.assertAll();
}
Also used : SoftAssertions(org.assertj.core.api.SoftAssertions) HiveTimestampPrecision(io.trino.plugin.hive.HiveTimestampPrecision)

Aggregations

HiveTimestampPrecision (io.trino.plugin.hive.HiveTimestampPrecision)6 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 TrinoException (io.trino.spi.TrinoException)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 HiveColumnHandle (io.trino.plugin.hive.HiveColumnHandle)2 Type (io.trino.spi.type.Type)2 SoftAssertions (org.assertj.core.api.SoftAssertions)2 Test (org.testng.annotations.Test)2 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)1 Splitter (com.google.common.base.Splitter)1 Verify.verify (com.google.common.base.Verify.verify)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)1 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)1 Lists (com.google.common.collect.Lists)1 Maps.immutableEntry (com.google.common.collect.Maps.immutableEntry)1 Streams (com.google.common.collect.Streams)1 Inject (com.google.inject.Inject)1 DataSize (io.airlift.units.DataSize)1