Refactor to_timestamp* UDF constructors with shared macros
#7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
The
to_timestamp*scalar UDF implementations (to_timestamp,to_timestamp_seconds,to_timestamp_millis,to_timestamp_micros,to_timestamp_nanos) each contained near-identical boilerplate for:Defaultimplementationsnew()constructors (kept for backward compatibility)new_with_config()constructors that extract timezone fromConfigOptionswith_updated_config()implementations that rebuild the UDF with the new configThis duplication increases maintenance cost and the risk of the functions drifting apart over time.
What changes are included in this PR?
Introduces a
impl_to_timestamp_constructors!macro to generate:Defaultimplnew()constructornew_with_config()constructor that pullsexecution.time_zonefromConfigOptionsApplies the macro to all five
ToTimestamp*UDF structs.Introduces an
impl_with_updated_config!macro to generate the identicalwith_updated_config()method body.Replaces per-type
with_updated_config()method implementations with the macro invocation.Are these changes tested?
with_updated_config()bodies are identical to the previous hand-written implementations.Are there any user-facing changes?
new()constructors are still present); this change only reduces internal boilerplate.