Skip to content

Commit

Permalink
Fix timestamp literal handling in the multi-stage query engine (#14502)
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmayya authored Nov 20, 2024
1 parent 89622c0 commit a914940
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit a914940

Please sign in to comment.