Skip to content

[Feature] Add flat_json.column_paths to control which JSON paths are … - #1

Open
moweonlee wants to merge 9 commits into
mainfrom
feature/manual-column-control-to-flatjson
Open

[Feature] Add flat_json.column_paths to control which JSON paths are …#1
moweonlee wants to merge 9 commits into
mainfrom
feature/manual-column-control-to-flatjson

Conversation

@moweonlee

@moweonlee moweonlee commented Apr 17, 2026

Copy link
Copy Markdown
Owner

…always columnized

Why I'm doing:

What I'm doing:

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
    • This pr needs auto generate documentation
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.1
    • 4.0
    • 3.5
    • 3.4

…always columnized

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Apr 21, 2026
@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown

🌎 Translation Required?

Thanks for your doc contribution! The following languages are missing or outdated for your changes.

🤖 Automated Translations

If you are fluent in any of the missing languages you can add them. If not, a maintainer can generate the translations below.

Maintainer: Check the ones you wish to generate:

docs/en/using_starrocks/Flat_json_column_paths.md

  • ja for docs/en/using_starrocks/Flat_json_column_paths.md (New)

Maintainers: Check boxes and reply with /translate to start.

🕒 Last updated: Thu, 23 Apr 2026 12:49:42 GMT

- Rename toThrift() back to toTFlatJsonConfig() in FlatJsonConfig.java;
  CreateReplicaTask.java still calls the original name and the rename
  would cause a compilation error.
- Restore the 4-parameter update(bool, double, double, int) helper in
  flat_json_config.h that was removed in the refactor commit; other
  parts of the codebase may rely on it and the original author had
  intent behind exposing it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Moweon Lee and others added 4 commits April 22, 2026 21:16
…lay merge

modifyTableProperties() uses putAll (merge, not replace). When a user removes
all forced paths for a JSON column, the corresponding flat_json.column_paths.<col>
key is absent from FlatJsonConfig.toProperties(). On follower FEs the stale key
survives the putAll and causes buildFromProperties() to reconstruct a FlatJsonConfig
with ghost paths, silently forcing paths that should no longer be columnized.

Fix: purge all flat_json.column_paths.* keys from the existing properties map
before the putAll when replaying OP_MODIFY_FLAT_JSON_CONFIG, mirroring the
SchemaChangeHandler.removeIf() that already does this on the leader.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… CREATE TABLE

CREATE TABLE did not verify that column names referenced in
flat_json.column_paths.* properties are actual JSON-typed columns in
the table schema. Unlike ALTER TABLE (which already validates via
AlterTableClauseAnalyzer), CREATE TABLE silently accepted invalid
column names and stored them, causing BE to silently ignore the
configured paths.

Added the same JSON-column existence check used in
AlterTableClauseAnalyzer to processFlatJsonConfig() in
OlapTableFactory so that CREATE TABLE fails fast with a clear error
when a non-existent or non-JSON column is referenced.
…hs ALTER

Three issues fixed:

1. AlterTableClauseAnalyzer: when flat_json.enable and flat_json.column_paths.*
   were present in the same ALTER TABLE, the else-if chain caused column_paths
   validation (JSON column existence check, path format) to be silently skipped.
   Extracted the validation into validateFlatJsonColumnPathsProperties() and call
   it from both the enable branch and the dedicated column_paths branch.

2. AlterTableClauseAnalyzer: the properties.size() != 1 guard did not include
   FLAT_JSON_PROPERTY_PREFIX, so users could not bundle flat_json.enable and
   flat_json.column_paths.* in a single ALTER TABLE statement. Added the prefix
   to the existing multi-property allowlist alongside dynamic_partition and binlog.

3. SchemaChangeHandler: stale flat_json.column_paths.* key removal ran without
   holding the write lock, creating a narrow window where SHOW CREATE TABLE could
   observe the old keys already erased but the new values not yet written by the
   WAL lambda. Moved the removal inside the WRITE lock block immediately before
   modifyFlatJsonMeta so the removal and WAL update are atomic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dled ALTER

When flat_json.enable=false and flat_json.column_paths.* are combined in
a single ALTER TABLE, the Analyzer previously called validateFlatJsonColumnPathsProperties
without first verifying that enable=true, allowing an invalid combination
to pass FE validation. The execution layer (updateFlatJsonConfigMeta) would
then throw a RuntimeException instead of a proper SemanticException.

Add an explicit guard in the enable branch: if flat_json.enable is not
"true" and column_paths properties are present, report a SemanticException
immediately so the error is clear and caught at the right layer.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
moweonlee added a commit that referenced this pull request May 26, 2026
…le orphans

Address two follow-up review comments on flat_json ALTER propagation:

- Round-trip flat_json.version through FlatJsonConfig.toProperties()
  and TableProperty.buildFlatJsonConfig() so FE failover preserves
  the version monotonicity the BE version-gate depends on. Without
  this, OP_MODIFY_FLAT_JSON_CONFIG replay reset version to 0 while
  BEs already held higher versions, causing subsequent ALTERs to be
  silently dropped by BE (new_version <= old_version).

- Treat an unset flat_json_config_version on a tablet report as 0 in
  ReportHandler so tablets that never received an initial ALTER push
  (orphans from missed pushes) are picked up by heartbeat
  reconciliation instead of being skipped indefinitely.

Verified both bugs end-to-end on a local FE+BE cluster by swapping
between pre-fix and post-fix FE jars against the same BE:

- EditLog persistence: with pre-fix FE, ALTER #1, ALTER #2, FE
  restart, ALTER #3 left BE holding a higher version than FE, with
  FE logging "BE flat_json_config version is N greater than version
  of FE". With post-fix FE the same sequence applied versions 1 and
  2 cleanly and produced no such warning.

- Orphan reconciliation: with pre-fix FE, an ALTER fired while BE
  was down (so the initial push timed out) left the tablet without
  flat_json_config and the FE skipped it on every subsequent tablet
  report. With post-fix FE the same setup, after restarting FE to
  drain any in-memory agent task queue, BE applied the config 21 ms
  after its first post-restart tablet report -- proving heartbeat
  reconciliation alone reaches orphans.

Co-Authored-By: 김영진 <jini.kim@navercorp.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: 이모원[Log data] <moweon.lee@navercorp.com>
moweonlee added a commit that referenced this pull request May 26, 2026
…le orphans

Address two follow-up review comments on flat_json ALTER propagation:

- Round-trip flat_json.version through FlatJsonConfig.toProperties()
  and TableProperty.buildFlatJsonConfig() so FE failover preserves
  the version monotonicity the BE version-gate depends on. Without
  this, OP_MODIFY_FLAT_JSON_CONFIG replay reset version to 0 while
  BEs already held higher versions, causing subsequent ALTERs to be
  silently dropped by BE (new_version <= old_version).

- Treat an unset flat_json_config_version on a tablet report as 0 in
  ReportHandler so tablets that never received an initial ALTER push
  (orphans from missed pushes) are picked up by heartbeat
  reconciliation instead of being skipped indefinitely.

Verified both bugs end-to-end on a local FE+BE cluster by swapping
between pre-fix and post-fix FE jars against the same BE:

- EditLog persistence: with pre-fix FE, ALTER #1, ALTER #2, FE
  restart, ALTER #3 left BE holding a higher version than FE, with
  FE logging "BE flat_json_config version is N greater than version
  of FE". With post-fix FE the same sequence applied versions 1 and
  2 cleanly and produced no such warning.

- Orphan reconciliation: with pre-fix FE, an ALTER fired while BE
  was down (so the initial push timed out) left the tablet without
  flat_json_config and the FE skipped it on every subsequent tablet
  report. With post-fix FE the same setup, after restarting FE to
  drain any in-memory agent task queue, BE applied the config 21 ms
  after its first post-restart tablet report -- proving heartbeat
  reconciliation alone reaches orphans.

Co-Authored-By: 김영진 <jini.kim@navercorp.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: 이모원[Log data] <moweon.lee@navercorp.com>
moweonlee added a commit that referenced this pull request May 28, 2026
…le orphans

Address two follow-up review comments on flat_json ALTER propagation:

- Round-trip flat_json.version through FlatJsonConfig.toProperties()
  and TableProperty.buildFlatJsonConfig() so FE failover preserves
  the version monotonicity the BE version-gate depends on. Without
  this, OP_MODIFY_FLAT_JSON_CONFIG replay reset version to 0 while
  BEs already held higher versions, causing subsequent ALTERs to be
  silently dropped by BE (new_version <= old_version).

- Treat an unset flat_json_config_version on a tablet report as 0 in
  ReportHandler so tablets that never received an initial ALTER push
  (orphans from missed pushes) are picked up by heartbeat
  reconciliation instead of being skipped indefinitely.

Verified both bugs end-to-end on a local FE+BE cluster by swapping
between pre-fix and post-fix FE jars against the same BE:

- EditLog persistence: with pre-fix FE, ALTER #1, ALTER #2, FE
  restart, ALTER #3 left BE holding a higher version than FE, with
  FE logging "BE flat_json_config version is N greater than version
  of FE". With post-fix FE the same sequence applied versions 1 and
  2 cleanly and produced no such warning.

- Orphan reconciliation: with pre-fix FE, an ALTER fired while BE
  was down (so the initial push timed out) left the tablet without
  flat_json_config and the FE skipped it on every subsequent tablet
  report. With post-fix FE the same setup, after restarting FE to
  drain any in-memory agent task queue, BE applied the config 21 ms
  after its first post-restart tablet report -- proving heartbeat
  reconciliation alone reaches orphans.

Co-Authored-By: 김영진 <jini.kim@navercorp.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: 이모원[Log data] <moweon.lee@navercorp.com>
moweonlee added a commit that referenced this pull request May 28, 2026
…le orphans

Address two follow-up review comments on flat_json ALTER propagation:

- Round-trip flat_json.version through FlatJsonConfig.toProperties()
  and TableProperty.buildFlatJsonConfig() so FE failover preserves
  the version monotonicity the BE version-gate depends on. Without
  this, OP_MODIFY_FLAT_JSON_CONFIG replay reset version to 0 while
  BEs already held higher versions, causing subsequent ALTERs to be
  silently dropped by BE (new_version <= old_version).

- Treat an unset flat_json_config_version on a tablet report as 0 in
  ReportHandler so tablets that never received an initial ALTER push
  (orphans from missed pushes) are picked up by heartbeat
  reconciliation instead of being skipped indefinitely.

Verified both bugs end-to-end on a local FE+BE cluster by swapping
between pre-fix and post-fix FE jars against the same BE:

- EditLog persistence: with pre-fix FE, ALTER #1, ALTER #2, FE
  restart, ALTER #3 left BE holding a higher version than FE, with
  FE logging "BE flat_json_config version is N greater than version
  of FE". With post-fix FE the same sequence applied versions 1 and
  2 cleanly and produced no such warning.

- Orphan reconciliation: with pre-fix FE, an ALTER fired while BE
  was down (so the initial push timed out) left the tablet without
  flat_json_config and the FE skipped it on every subsequent tablet
  report. With post-fix FE the same setup, after restarting FE to
  drain any in-memory agent task queue, BE applied the config 21 ms
  after its first post-restart tablet report -- proving heartbeat
  reconciliation alone reaches orphans.

Co-Authored-By: 김영진 <jini.kim@navercorp.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: 이모원[Log data] <moweon.lee@navercorp.com>
moweonlee added a commit that referenced this pull request Jun 9, 2026
…le orphans

Address two follow-up review comments on flat_json ALTER propagation:

- Round-trip flat_json.version through FlatJsonConfig.toProperties()
  and TableProperty.buildFlatJsonConfig() so FE failover preserves
  the version monotonicity the BE version-gate depends on. Without
  this, OP_MODIFY_FLAT_JSON_CONFIG replay reset version to 0 while
  BEs already held higher versions, causing subsequent ALTERs to be
  silently dropped by BE (new_version <= old_version).

- Treat an unset flat_json_config_version on a tablet report as 0 in
  ReportHandler so tablets that never received an initial ALTER push
  (orphans from missed pushes) are picked up by heartbeat
  reconciliation instead of being skipped indefinitely.

Verified both bugs end-to-end on a local FE+BE cluster by swapping
between pre-fix and post-fix FE jars against the same BE:

- EditLog persistence: with pre-fix FE, ALTER #1, ALTER #2, FE
  restart, ALTER #3 left BE holding a higher version than FE, with
  FE logging "BE flat_json_config version is N greater than version
  of FE". With post-fix FE the same sequence applied versions 1 and
  2 cleanly and produced no such warning.

- Orphan reconciliation: with pre-fix FE, an ALTER fired while BE
  was down (so the initial push timed out) left the tablet without
  flat_json_config and the FE skipped it on every subsequent tablet
  report. With post-fix FE the same setup, after restarting FE to
  drain any in-memory agent task queue, BE applied the config 21 ms
  after its first post-restart tablet report -- proving heartbeat
  reconciliation alone reaches orphans.

Co-Authored-By: 김영진 <jini.kim@navercorp.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: 이모원[Log data] <moweon.lee@navercorp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-maintainer documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant