Skip to content

fix(eap): flatten nested attributes_array JSON for dotted keys#7911

Open
manessaraj wants to merge 3 commits intomasterfrom
sarajmanes/feat/exp-915-silently-ignore-parsing-errors
Open

fix(eap): flatten nested attributes_array JSON for dotted keys#7911
manessaraj wants to merge 3 commits intomasterfrom
sarajmanes/feat/exp-915-silently-ignore-parsing-errors

Conversation

@manessaraj
Copy link
Copy Markdown
Contributor

ClickHouse can emit nested objects for dotted keys under toJSONString(attributes_array). Flatten that shape back to dotted attribute names before decoding tagged array elements. All parsing stays in process_arrays (common.py); bad JSON or structure raises BadSnubaRPCRequestException.

fixes EXP-915

@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 28, 2026

ClickHouse can emit nested objects for dotted keys under toJSONString(attributes_array).
Flatten that shape back to dotted attribute names before decoding tagged array elements.
All parsing stays in process_arrays (common.py); bad JSON or structure raises
BadSnubaRPCRequestException.

fixes EXP-915
@manessaraj manessaraj force-pushed the sarajmanes/feat/exp-915-silently-ignore-parsing-errors branch from 260fd78 to c8d50c0 Compare April 28, 2026 19:29
@manessaraj manessaraj marked this pull request as ready for review April 28, 2026 19:30
@manessaraj manessaraj requested review from a team as code owners April 28, 2026 19:30


def _flatten_attributes_array_json(node: dict[str, Any], prefix: str = "") -> dict[str, list[Any]]:
"""Flatten nested dicts into dotted keys (name -> list). ClickHouse often nests dotted paths."""
Copy link
Copy Markdown
Contributor

@onewland onewland Apr 28, 2026

Choose a reason for hiding this comment

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

let's change this comment to say that ClickHouse stores all JSON objects as flat and interprets dotted paths in a special way to support nesting, then link to the relevant ClickHouse docs

Copy link
Copy Markdown
Member

@kylemumma kylemumma left a comment

Choose a reason for hiding this comment

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

lgtm once you address olivers comment



def transform_array_value(value: dict[str, str]) -> Any:
def transform_array_value(value: Any) -> Any:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you keep type as dict here instead of Any. (its not enforced at runtime so you can still keep your isinstance check)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants