ShashidharM0118 opened a new pull request, #18733:
URL: https://github.com/apache/datafusion/pull/18733

   ## Which issue does this PR close?
   
   Closes #18669
   
   ## Rationale for this change
   
   The `make_udf_function!` macro had significant code duplication between its 
two arms. Both arms contained nearly identical 16-line implementations that 
only differed in the constructor call. Additionally, the `$UDF` parameter was 
unused in the second arm, which was inefficient.
   
   This refactoring eliminates the duplication by applying a delegation 
pattern, where the simpler 2-parameter arm now delegates to the more complete 
3-parameter arm with a default constructor.
   
   ## What changes are included in this PR?
   
   - **Reordered macro arms**: The 3-parameter arm (with `$CTOR`) is now first 
and contains the full implementation
   - **Delegation pattern**: The 2-parameter arm now delegates to the 
3-parameter arm by calling `make_udf_function!($UDF, $NAME, <$UDF>::new)`
   - **Parameter type change**: Changed `$CTOR` from `:path` to `:expr` and 
wrap the call as `($CTOR)()` for flexibility
   - **Fixed unused parameter**: The `$UDF` type parameter is now utilized in 
the 2-parameter arm to construct the default constructor path
   - **Code reduction**: Reduced the macro from 33 lines to 25 lines by 
eliminating duplication
   
   ## Are these changes tested?
   
   Yes 
   
   ## Are there any user-facing changes?
   
   No 


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to