Details
-
Improvement
-
Status: Reopened
-
Major
-
Resolution: Unresolved
-
1.19.0
-
None
Description
RexSimplify.simplifyCast() is slow when converting a string to SQL Timestamp value. The slowness is caused by this line:
executor.reduce(rexBuilder, ImmutableList.of(e), reducedValues);
Debugging this code line with my team showed that for timestamp conversion it loads a pre-compiled conversion code, which makes it slow. My team proposes to replace this line with the following code that greately improves performance:
if (typeName == SqlTypeName.CHAR && e.getType().getSqlTypeName() == SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE) { if (literal.getValue() instanceof NlsString) { String timestampStr = ((NlsString) literal.getValue()).getValue(); Long timestampLong = SqlFunctions.toTimestampWithLocalTimeZone(timestampStr); reducedValues.add(rexBuilder.makeLiteral(timestampLong, e.getType(), true)); } } if (reducedValues.isEmpty()) { executor.reduce(rexBuilder, ImmutableList.of(e), reducedValues); }
Let us know if we can submit a pull request with this code change or if we've missed anything. Do you know the reason behind using a pre-compiled code for timestamp conversion?
Attachments
Attachments
Issue Links
- is related to
-
CALCITE-1695 Not all RexUtil.simplifyXxx code paths carry the provided executor
- Closed