Cannot Select Columns in the Query Builder After Joining a Native SQL Model
Describe the bug
In the Query Builder/Notebook, when joining a model created using native SQL to a table, and then joining another table that references the base table (the one from which the question is being created), some columns cannot be selected.
To Reproduce
Using the sample dataset:
-
Create a SQL Native Model with a query like the one shown below:
-
Create a new question using the ‘Accounts’ table as the base.
-
Join the model created in step 1 to this question using an inner join, matching ‘Accounts.ID’ with the model’s ID column.
-
In the same question, join the ‘Invoices’ table using an inner join, where ‘Accounts.ID’ = ‘Invoices.Account ID’.
-
Deselect all columns from all tables and models.
-
Now, try selecting the ‘ID’ column from the ‘Invoices’ table.
When you click on this column, it does not get selected.
However, if you click “Select all”, the column is correctly selected. Similarly, creating a custom column works as expected.
The issue occurs only when trying to select the column directly from the table.
Resulting Query
The final query generated looks like this:
Originally, I encountered this issue in a real database with production data, so I cannot provide an exact replication.
Expected behavior
Some columns cannot be selected when this join structure is used; however, they should be selectable.
Logs
Below are the logs from my Chrome browser console:
These logs are very similar to those produced with my real data.
In the real dataset, I also encountered an additional error that I could not replicate using the Metabase sample data.
In that setup, I had the same query structure described in this ticket (base table → join model → join another table).
When trying to select a column from the third joined table, it failed to select (as shown above).
Then, after re-running the query, I got this error:
I replaced the model and column names for privacy.
For example, the real reference could look like: ‘[Dummy] Accounts.ID’.
The issue seems to be that the Query Builder is trying to access the column from the model instead of the correct joined table, suggesting it is not pointing to the right table reference.
Information about your Metabase installation
{
"browser-info": {
"language": "en-US",
"platform": "Win32",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36",
"vendor": "Google Inc."
},
"metabase-info": {
"databases": [
"h2"
],
"run-mode": "prod",
"plan-alias": "",
"version": {
"date": "2025-10-08",
"tag": "v0.56.9",
"hash": "ecf7bcf"
},
"settings": {
"report-timezone": null
},
"hosting-env": "unknown",
"application-database": "h2",
"application-database-details": {
"database": {
"name": "H2",
"version": "2.1.214 (2022-06-13)"
},
"jdbc-driver": {
"name": "H2 JDBC Driver",
"version": "2.1.214 (2022-06-13)"
}
}
},
"system-info": {
"file.encoding": "UTF-8",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "21.0.8+9-LTS",
"java.vendor": "Eclipse Adoptium",
"java.vendor.url": "https://adoptium.net/",
"java.version": "21.0.8",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "21.0.8+9-LTS",
"os.name": "Linux",
"os.version": "6.8.0-64-generic",
"user.language": "en",
"user.timezone": "GMT"
}
}
Severity
It is very severe.
Additional context
No response
Possibly trouble with lib.field.resolution not being able to select certain columns? Hard to know at a glance.
Tried everything and couldn't break it on the mentioned version, other 56 version, and 57. Everything works
@ToniSeas is it still an issue for you? if yes, could you provide more detailed steps so that we could repro?