Skip to content

feat: Support dot key filtering for map columns in ClickHouse LQL#3385

Merged
Ziinc merged 7 commits intomainfrom
adammokan/o11y-1674-support-dot-key-filtering-in-clickhouse-lql
Apr 17, 2026
Merged

feat: Support dot key filtering for map columns in ClickHouse LQL#3385
Ziinc merged 7 commits intomainfrom
adammokan/o11y-1674-support-dot-key-filtering-in-clickhouse-lql

Conversation

@amokan
Copy link
Copy Markdown
Contributor

@amokan amokan commented Apr 16, 2026

Adds support for dot-key filtering on ClickHouse Map columns in LQL. Previously, a query like log_attributes.parsed.backend_type:~"client" would fail because the ClickHouse transformer treated the entire dotted path as a column name (l0."log_attributes.parsed.backend_type") instead of using Map bracket access (l0."log_attributes"['parsed.backend_type']).

Key Changes:

  • lib/logflare/lql/backend_transformer/clickhouse.ex — Added split_map_path/1 to detect when a field path starts with a known ClickHouse Map column and splits it into column + map key.
  • test/logflare/lql/backend_transformer/clickhouse_test.exs — Added unit tests for split_map_path/1 and dot-key filter/select rules (equality, range, negation, select with alias). Consolidated some old describe blocks. Fixed pipe-style Macro.to_string assertions throughout to improve readability.
  • test/logflare/backends/adaptor/clickhouse_adaptor_test.exs — Added "LQL query integration" describe block with a round-trip test: inserts events with dotted map keys into ClickHouse, queries them back using an LQL filter rule, and validates correct row filtering.

@amokan amokan requested review from Ziinc and chasers April 16, 2026 00:25
@amokan amokan changed the title feature: Support dot key filtering for map columns in ClickHouse LQL feat: Support dot key filtering for map columns in ClickHouse LQL Apr 16, 2026

query = from(l in "logs")
query_with_filter = where(query, ^result)
assert %Ecto.Query{wheres: [_where_clause]} = query_with_filter
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.

can assert on the where clause for comprehensiveness

)

result = ClickHouse.apply_filter_rules_to_query(query, [filter_rule], [])
assert %Ecto.Query{wheres: [_where_clause]} = result
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.

as above, can verify the where clause.

result = ClickHouse.apply_select_rules_to_query(query, [select_rule], [])

assert %Ecto.Query{select: %{expr: expr}} = result
assert Macro.to_string(expr) =~ "log_attributes_parsed_backend_type"
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.

side note: select rules would need to support aliases in future, like s:my.nested.field@my_alias or something like this.

@Ziinc Ziinc merged commit 869d2af into main Apr 17, 2026
12 checks passed
@Ziinc Ziinc deleted the adammokan/o11y-1674-support-dot-key-filtering-in-clickhouse-lql branch April 17, 2026 10:27
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.

2 participants