msathis commented on a change in pull request #387:
URL: https://github.com/apache/arrow-datafusion/pull/387#discussion_r638138544
##########
File path: datafusion/src/optimizer/constant_folding.rs
##########
@@ -217,6 +218,35 @@ impl<'a> ExprRewriter for ConstantRewriter<'a> {
.query_execution_start_time
.timestamp_nanos(),
))),
+ Expr::ScalarFunction {
+ fun: BuiltinScalarFunction::ToTimestamp,
+ args,
+ } => {
+ if !args.is_empty() {
+ match &args[0] {
+ Expr::Literal(ScalarValue::Utf8(Some(val))) => {
+ match string_to_timestamp_nanos(val) {
+ Ok(timestamp) => Expr::Literal(
+
ScalarValue::TimestampNanosecond(Some(timestamp)),
+ ),
+ _ => Expr::ScalarFunction {
+ fun: BuiltinScalarFunction::ToTimestamp,
+ args,
+ },
+ }
+ }
+ _ => Expr::ScalarFunction {
+ fun: BuiltinScalarFunction::ToTimestamp,
+ args,
+ },
+ }
+ } else {
+ Expr::ScalarFunction {
+ fun: BuiltinScalarFunction::ToTimestamp,
+ args,
+ }
+ }
+ }
Review comment:
In case of all error cases including empty, we don't optimise. So the
default non-optimised flow continues.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]