Invalid query when sandboxing table with foreign key - Ask a question

‘Ask a question’ errors when used on a table that is configured with the following properties:

  • Sandboxing based on column values
  • A column with a foreign key relationship
  • A display value taken from the foreign table
    The ‘Ask a question’ features appears to generate an invalid query. When attempting to use the feature with a simple question based on the table in question, the UI immediately shows an error ‘There was a problem with your question’ after selecting the table.

Step to reproduce:

  1. Create a model with a fact table that looks rougly like this
    orders (tenant_id, id, widget_id)
    widgets (tenant_id, id, name)
  2. Set the widget_id on the order table as foreign key mapping to widgets (id)
  3. Change the display value for the widget_id column to the foreign value widgets (name)
  4. Define a sandbox permission on the orders table restricting access to users that have an attribute which matches the tenant_id column
  5. Using a sandboxed user account, select: Ask a Question -> Simple Question -> Database -> Orders table
    Expected:
    A table with some set of orders are shown as usually
    Actual:
    The UI immediately display an error: ‘There was a problem with your question’, and the error details explains Unknown column 'source.name' in 'field list'

This has been reproduced using both a AWS Redshift database and an MySQL database

Hi @Jls - :denmark:?
Please use support [at] metabase.com for problems/questions with Enterprise Edition.
And include “Diagnostic Info” from Admin > Troubleshooting.