Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugin/trino-tpcds/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import static io.trino.plugin.tpcds.TpcdsMetadata.getTrinoType;
import static io.trino.spi.type.Chars.trimTrailingSpaces;
import static io.trino.spi.type.Decimals.rescale;
import static io.trino.spi.type.Timestamps.PICOSECONDS_PER_MILLISECOND;
import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
Expand Down Expand Up @@ -133,7 +134,7 @@ public long getLong(int field)
return LocalDate.parse(row.get(column.getPosition())).toEpochDay();
}
if (column.getType().getBase() == ColumnType.Base.TIME) {
return LocalTime.parse(row.get(column.getPosition())).getMillisOfDay();
return (long) LocalTime.parse(row.get(column.getPosition())).getMillisOfDay() * PICOSECONDS_PER_MILLISECOND;
}
if (column.getType().getBase() == ColumnType.Base.INTEGER) {
return parseInt(row.get(column.getPosition()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
import org.testng.annotations.Test;

import java.math.BigDecimal;
import java.time.LocalTime;

import static io.trino.spi.type.Timestamps.NANOSECONDS_PER_DAY;
import static io.trino.spi.type.Timestamps.NANOSECONDS_PER_SECOND;
import static io.trino.testing.MaterializedResult.resultBuilder;
import static io.trino.testing.TestingSession.testSessionBuilder;
import static io.trino.testing.assertions.Assert.assertEquals;
import static java.util.stream.Collectors.joining;
import static java.util.stream.IntStream.range;
import static org.assertj.core.api.Assertions.assertThat;

public class TestTpcds
extends AbstractTestQueryFramework
Expand Down Expand Up @@ -61,6 +65,17 @@ public void testSelect()
assertEquals(expected, actual);
}

@Test
public void testTimeRepresentation()
{
LocalTime timeNow = LocalTime.now();
LocalTime readTime = (LocalTime) computeScalar("SELECT dv_create_time FROM dbgen_version");
long differenceNanos = (NANOSECONDS_PER_DAY + readTime.toNanoOfDay() - timeNow.toNanoOfDay()) % NANOSECONDS_PER_DAY;
differenceNanos = Math.min(differenceNanos, NANOSECONDS_PER_DAY - differenceNanos);
assertThat(differenceNanos)
.isBetween(0L, 10 * NANOSECONDS_PER_SECOND);
}

@Test
public void testLargeInWithShortDecimal()
{
Expand Down