luchunliang opened a new pull request, #12214:
URL: https://github.com/apache/inlong/pull/12214

   Fixes #12213 
   
   ### Motivation
   
   <!--Explain here the context, and why you're making that change. What is the 
problem you're trying to solve.-->
   
   ### Modifications
   
   ### Proposed Change
   
   Introduce a `NullValueParser` following the existing `StringParser` pattern:
   
   ```java
   @TransformParser(values = NullValue.class)
   public class NullValueParser implements ValueParser {
   
       public NullValueParser(NullValue expr) {
           // The NULL literal carries no value; nothing to store.
       }
   
       @Override
       public Object parse(SourceData sourceData, int rowIndex, Context 
context) {
           return null;
       }
   }
   ```
   
   `@TransformParser(values = NullValue.class)` registers `NullValue.class` in 
`parserMap`, so `getTransformParser` resolves it through the reflective 
constructor branch, and `NULL` literals evaluate to constant `null`.
   
   ### Resulting Behavior
   
   - `ifnull(null, numeric2)` evaluates its first argument to `null`, so 
`IfNullFunction` falls back to the second argument as expected.
   - Other functions that receive a `NULL` literal as an argument (e.g. 
`coalesce`, `num_nulls`, `concat_ws`) no longer fail during parser construction.
   
   ### Tests
   
   Added a true-`NULL`-literal case to `TestIfNullFunction`:
   
   ```java
   // case6: ifnull(null, numeric2) -- true NULL literal
   transformSql = "select ifnull(null,numeric2) from source";
   data = "5|3|3|5";
   Assert.assertEquals("result=3", output.get(0));
   ```
   
   Verified: `Tests run: 1, Failures: 0, Errors: 0, Skipped: 0`.
   
   ### Backward Compatibility
   
   - Fully backward compatible.
   - No public API or method-signature change; only a new parser class is added.
   - Existing column / function / literal parsers are unaffected.
   
   ### Files Changed
   
   - 
`inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/parser/NullValueParser.java`
 *(new)*
   - 
`inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/function/condition/TestIfNullFunction.java`
   
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [ ] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   
     *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads 
(10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs 
/ not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a follow-up 
issue for adding the documentation
   


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

Reply via email to