Skip to content

[FLINK-40901][table]Fixed the codegen bug w jsonType/Length - #29384

Open
VasShabu wants to merge 2 commits into
apache:masterfrom
VasShabu:JsonCodeGenUtilBugFix
Open

VasShabu wants to merge 2 commits into
apache:masterfrom
VasShabu:JsonCodeGenUtilBugFix

Conversation

@VasShabu

@VasShabu VasShabu commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

JSON_TYPE and JSON_LENGTH could return the previous row's result when an earlier JSON call on the same input was skipped (e.g. in CASE WHEN). They now use the shared JsonParseReuse, which parses on first use per record.

Brief change log

  • JSON_TYPE and JSON_LENGTH codegen now parses its input via the shared JsonParseReuse, like the other JSON functions
  • Removed the separate parse cache (getOrCreateParsedJson) in JsonCodeGenUtils, which could leave stale parsed state for rows where the first JSON call was skipped

Verifying this change

Added four tests to JsonParseReuseTest covering JSON_TYPE / JSON_LENGTH / JSON_VALUE on a shared input when the first call is skipped for some rows (CASE WHEN, short-circuited OR in a filter)

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (yes)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not applicable)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [Claude Opus 5.5]

@flinkbot

flinkbot commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Comment on lines +102 to +108
return new Tuple2<>("", CodeGenUtils.qualifyMethod(wholeDocument) + "(" + parsed + ")");
}

final String pathSpec = operands.apply(1).literalValue().get().toString();
final boolean isPathDefinite = SqlJsonUtils.isPathDefinite(pathSpec);
return new Tuple2<>(
parsed.parseCode,
"",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that generateCallOnParsedInput() always returns "" as first param, you can remove the Tuple and change the return type to a plain string.

@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants