Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for joined filters in mbql #29

Open
chasleslr opened this issue Feb 24, 2022 · 0 comments
Open

Add support for joined filters in mbql #29

chasleslr opened this issue Feb 24, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@chasleslr
Copy link
Owner

chasleslr commented Feb 24, 2022

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.

@chasleslr chasleslr added the enhancement New feature or request label Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant