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 @@ -4573,6 +4573,7 @@ private Optional<TableVersion> extractTableVersion(Table table, QualifiedObjectN
private void validateVersionPointer(QualifiedObjectName tableName, QueryPeriod queryPeriod, TableVersion extractedVersion)
{
Type type = extractedVersion.getObjectType();
Object pointer = extractedVersion.getPointer();
if (extractedVersion.getPointerType() == PointerType.TEMPORAL) {
// Before checking if the connector supports the version type, verify that version is a valid time-based type
if (!(type instanceof TimestampWithTimeZoneType ||
Expand All @@ -4582,6 +4583,14 @@ private void validateVersionPointer(QualifiedObjectName tableName, QueryPeriod q
"Type %s invalid. Temporal pointers must be of type Timestamp, Timestamp with Time Zone, or Date.",
type.getDisplayName()));
}
if (pointer == null) {
throw semanticException(INVALID_ARGUMENTS, queryPeriod, "Pointer value cannot be NULL");
}
}
else {
if (pointer == null) {
throw semanticException(INVALID_ARGUMENTS, queryPeriod, "Pointer value cannot be NULL");
}
}

if (!metadata.isValidTableVersion(session, tableName, extractedVersion)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,14 @@ public void testTemporalTableVersion()

// null value with right type
assertFails("SELECT * FROM t1 FOR TIMESTAMP AS OF CAST(NULL AS date)")
.hasErrorCode(NOT_SUPPORTED)
.hasMessage("This connector does not support versioned tables");
.hasErrorCode(INVALID_ARGUMENTS)
.hasMessage("line 1:18: Pointer value cannot be NULL");
assertFails("SELECT * FROM t1 FOR TIMESTAMP AS OF CAST(NULL AS timestamp(3))")
.hasErrorCode(NOT_SUPPORTED)
.hasMessage("This connector does not support versioned tables");
.hasErrorCode(INVALID_ARGUMENTS)
.hasMessage("line 1:18: Pointer value cannot be NULL");
assertFails("SELECT * FROM t1 FOR TIMESTAMP AS OF CAST(NULL AS timestamp(3) with time zone)")
.hasErrorCode(NOT_SUPPORTED)
.hasMessage("This connector does not support versioned tables");
.hasErrorCode(INVALID_ARGUMENTS)
.hasMessage("line 1:18: Pointer value cannot be NULL");

// null value with wrong type
assertFails("SELECT * FROM t1 FOR TIMESTAMP AS OF NULL")
Expand Down Expand Up @@ -448,11 +448,11 @@ public void testRangeIdTableVersion()
.hasErrorCode(INVALID_ARGUMENTS)
.hasMessage("line 1:18: Pointer value cannot be NULL");
assertFails("SELECT * FROM t1 FOR VERSION AS OF CAST(NULL AS bigint)")
.hasErrorCode(NOT_SUPPORTED)
.hasMessage("This connector does not support versioned tables");
.hasErrorCode(INVALID_ARGUMENTS)
.hasMessage("line 1:18: Pointer value cannot be NULL");
assertFails("SELECT * FROM t1 FOR VERSION AS OF CAST(NULL AS varchar)")
.hasErrorCode(NOT_SUPPORTED)
.hasMessage("This connector does not support versioned tables");
.hasErrorCode(INVALID_ARGUMENTS)
.hasMessage("line 1:18: Pointer value cannot be NULL");
}

@Test
Expand Down