metabase / metabase/metabase

[MBQL lib] `filter-parts` wrongly assumes the first argument is always a `:field`-like clause

Open
#44,376 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

.Backend .metabase-lib .Team/Querying [DEPRECATED] .Team/QueryingPlatform Querying/MBQL
Dominant language
Clojure
Stars
49.3k
Forks
6.8k
Avg merge
1d 13h
Merged PRs (30d)
653

Description

That assumption is true in the GUI but other features can add queries which don't fit this pattern.

In particular, sandboxing adds filters where the LHS is a `[:!= {} [:field ...] 0]` subexpression. `filter-parts` tries to pass that as `a-ref` to `lib.equality/find-matching-column` and it throws because `:!=` is not `:field`, `:expression` or `:aggregation`.

It's not clear whether this is the cause of the performance regression reported in #44359.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating `filter-parts` and tracing its call to `lib.equality/find-matching-column`. Reproduce the sandboxing case where the LHS is `[:!= {} [:field ...] 0]`, and compare it with the GUI filter shape. Done means the non-`:field`-like clause no longer causes an exception; investigate #44359 separately for the possible performance connection.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.