Skip to content

[INLONG-12213][SDK][Transform] Support parsing SQL NULL literal via NullValueParser - #12214

Merged
luchunliang merged 1 commit into
apache:masterfrom
luchunliang:INLONG-12213
Sep 16, 2026
Merged

luchunliang merged 1 commit into
apache:masterfrom
luchunliang:INLONG-12213

Conversation

@luchunliang

Copy link
Copy Markdown
Contributor

Fixes #12213

Motivation

Modifications

Proposed Change

Introduce a NullValueParser following the existing StringParser pattern:

@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:

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

@luchunliang
luchunliang merged commit 13c4379 into apache:master Sep 16, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature][SDK][Transform] Support parsing SQL NULL literal via NullValueParser

3 participants