Skip to content

Add support for joined filters in mbql #29

Description

@chasleslr

Metabase allows filtering on fields from another table joined through a foreign key. It compiles the MBQL for such filter as follows:

["=", ["field", 27, {source-field: 11}], 4]

This differs from a "regular" filter on a direct table field:

["=", ["field", 11, null], 5]

Here, {source-field: 11} represents the fieldID of the foreign key in the local table. For example, if using Orders as the base table with a foreign key userID to Users with a name field that we wanted to filter on:

  • Users.name has a fieldID = 27 in the example above.
  • Orders.userID has a fieldID = 11 in the example above.

We should allow Filter subclasses to filter on fields on foreign tables.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions