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 @@ -17,6 +17,7 @@
import com.google.common.primitives.Shorts;
import com.google.common.primitives.SignedBytes;
import io.airlift.slice.Slice;
import io.trino.spi.TrinoException;
import io.trino.spi.type.CharType;
import io.trino.spi.type.DecimalType;
import io.trino.spi.type.Decimals;
Expand Down Expand Up @@ -50,6 +51,7 @@
import static io.airlift.slice.SliceUtf8.countCodePoints;
import static io.airlift.slice.Slices.utf8Slice;
import static io.airlift.slice.Slices.wrappedBuffer;
import static io.trino.plugin.jdbc.JdbcErrorCode.JDBC_ERROR;
import static io.trino.plugin.jdbc.PredicatePushdownController.CASE_INSENSITIVE_CHARACTER_PUSHDOWN;
import static io.trino.plugin.jdbc.PredicatePushdownController.DISABLE_PUSHDOWN;
import static io.trino.plugin.jdbc.PredicatePushdownController.FULL_PUSHDOWN;
Expand Down Expand Up @@ -407,7 +409,13 @@ public boolean isNull(ResultSet resultSet, int columnIndex)
public long readLong(ResultSet resultSet, int columnIndex)
throws SQLException
{
return resultSet.getObject(columnIndex, LocalDate.class).toEpochDay();
LocalDate value = resultSet.getObject(columnIndex, LocalDate.class);
// Some drivers (e.g. MemSQL's) return null LocalDate even though the value isn't null
if (value == null) {
throw new TrinoException(JDBC_ERROR, "Driver returned null LocalDate for a non-null value");
}

return value.toEpochDay();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,7 @@ public void testCreateTableAsSelectNegativeDate()
{
// TODO (https://github.com/trinodb/trino/issues/10320) SingleStore stores '0000-00-00' when inserted negative dates and it throws an exception during reading the row
assertThatThrownBy(super::testCreateTableAsSelectNegativeDate)
.hasCauseInstanceOf(RuntimeException.class)
.hasStackTraceContaining("JDBC_ERROR")
.hasStackTraceContaining("JdbcRecordCursor.getLong");
.hasStackTraceContaining("TrinoException: Driver returned null LocalDate for a non-null value");
}

@Test
Expand All @@ -324,9 +322,7 @@ public void testInsertNegativeDate()
{
// TODO (https://github.com/trinodb/trino/issues/10320) SingleStore stores '0000-00-00' when inserted negative dates and it throws an exception during reading the row
assertThatThrownBy(super::testInsertNegativeDate)
.hasCauseInstanceOf(RuntimeException.class)
.hasStackTraceContaining("JDBC_ERROR")
.hasStackTraceContaining("JdbcRecordCursor.getLong");
.hasStackTraceContaining("TrinoException: Driver returned null LocalDate for a non-null value");
}

/**
Expand Down