The ConstEvaluator in SimplifyExpressions might evaluate some UDFs early in the
planning stage, by executing them directly. For example, the database() function.
So the ConfigOptions here (which is set from the session context) should be present
in the UDF’s ScalarFunctionArgs. However, the default implementation in DataFusion
seems to lost track on it: the ConfigOptions is recreated with its default values again.
So we create a custom OptimizerConfig with the desired ConfigOptions
to walk around the issue.
TODO(LFC): Maybe use DataFusion’s OptimizerContext again
once https://github.com/apache/datafusion/pull/17742 is merged.
A patch for substrait simply throw timezone away, so when decoding, if columns have different timezone then expected schema, use expected schema’s timezone