Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timestamp literal handling in the multi-stage query engine #14502

Merged
merged 1 commit into from
Nov 20, 2024
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 @@ -255,7 +255,15 @@ private static RexExpression.Literal fromRexLiteralValue(ColumnDataType dataType
value = Boolean.TRUE.equals(value) ? BooleanUtils.INTERNAL_TRUE : BooleanUtils.INTERNAL_FALSE;
break;
case TIMESTAMP:
value = ((Calendar) value).getTimeInMillis();
if (value instanceof Calendar) {
value = ((Calendar) value).getTimeInMillis();
} else if (value instanceof TimestampString) {
value = ((TimestampString) value).getMillisSinceEpoch();
} else if (value instanceof Long) {
// Already in millis
} else {
throw new IllegalStateException("Unsupported value type for TIMESTAMP: " + value.getClass().getName());
}
break;
case STRING:
value = ((NlsString) value).getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ protected Object[][] provideQueries() {
new Object[]{"SELECT JSON_EXTRACT_SCALAR(col1, '$.foo', 'FLOAT_ARRAY') FROM a"},
new Object[]{"SELECT JSON_EXTRACT_SCALAR(col1, '$.foo', 'DOUBLE_ARRAY') FROM a"},
new Object[]{"SELECT JSON_EXTRACT_SCALAR(col1, '$.foo', 'STRING_ARRAY') FROM a"},
new Object[]{"SELECT ts_timestamp FROM a WHERE ts_timestamp BETWEEN TIMESTAMP '2016-01-01 00:00:00' AND "
+ "TIMESTAMP '2016-01-01 10:00:00'"},
new Object[]{"SELECT ts_timestamp FROM a WHERE ts_timestamp >= CAST(1454284798000 AS TIMESTAMP)"}
};
}

Expand Down
Loading