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
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
import io.trino.tpcds.Results;
import io.trino.tpcds.column.Column;
import io.trino.tpcds.column.ColumnType;
import org.joda.time.Days;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;

import java.time.LocalDate;
import java.util.Iterator;
import java.util.List;

Expand Down Expand Up @@ -131,7 +130,7 @@ public long getLong(int field)
checkState(row != null, "No current row");
Column column = columns.get(field);
if (column.getType().getBase() == ColumnType.Base.DATE) {
return Days.daysBetween(new LocalDate(0), LocalDate.parse(row.get(column.getPosition()))).getDays();
return LocalDate.parse(row.get(column.getPosition())).toEpochDay();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @findepi

}
if (column.getType().getBase() == ColumnType.Base.TIME) {
return LocalTime.parse(row.get(column.getPosition())).getMillisOfDay();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ public void testShowTables()
assertQueryFails("SHOW TABLES FROM sf0", "line 1:1: Schema 'sf0' does not exist");
}

@Test
public void testDateColumnValuesCorrectness()
{
// make sure date values are correct regardless of the system timezone selected (test are executed with the system timezone set to America/Bahia_Banderas)
assertQuery("SELECT d_date FROM date_dim WHERE d_date_id = 'AAAAAAAAOKJNECAA'", "SELECT DATE '1900-01-02'");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this test failing without the fix? Worth a comment (and maybe rename) to explain what exactly are we testing here.

Copy link
Copy Markdown
Contributor Author

@arhimondr arhimondr May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I does fail without the fix. The tests are run in America/Bahia_Banderas time zone (-6). Before the change the value returned used to be 1900-01-01 while the correct value is 1900-01-02 (verified by manually checking the value TPC-DS generator returns as a string)

Will add a comment.

}

private Session createSession(String schemaName)
{
return testSessionBuilder()
Expand Down