metabase / metabase

The simplest, fastest way to get business intelligence and analytics to everyone in your company :yum:
https://metabase.com
Other
38.69k stars 5.14k forks source link

findColumnIndexesFromLegacyRefs doesn't handle columns with the same name #39033

Open ranquild opened 8 months ago

ranquild commented 8 months ago

Describe the bug

When there are columns with the same name coming from different sources (e.g. source table and a joined table) then findColumnIndexesFromLegacyRefs won't match the columns correctly even if field_ref has the correct join alias.

To Reproduce

  1. Create native question Q1 select ID, PRODUCT_ID, TOTAL from orders
  2. Create native question Q2 select * from products
  3. Create GUI question Q3 based on Q1, joins Q2 on Q1.PRODUCT_ID = Q2.ID
  4. Visualize the question in branch new-table-viz-settings-2
  5. Q2.ID column would not be shown in the table because the corresponding table setting wasn't matched with the column

For this question

findColumnIndexesFromLegacyRefs(
  query,
  -1,
  data.cols,
  data.cols.map(col => col.field_ref)
);

doesn't match for one of the joined columns.

Screenshot 2024-02-22 at 00 39 18

Expected behavior

All columns should be matched given that all data here is coming from QP

Logs

No response

Information about your Metabase installation

-

Severity

P1/P2 no data shown

Additional context

No response

bshepherdson commented 8 months ago

Context: @ranquild lowered the priority here because he found a workaround for the worst symptoms and committed it. This should still be fixed, but it's not on fire now.