Drill down from stacked graph generates broken query

Hey there,

Using version 0.35.1, I have a stacked graph chart with drill downs enabled. When I select a point and drill into it, I get an error that says one of the fields does not exist in the field list. When I look at the sql generated by Metabase, I can see why the error is getting thrown. I have included that sql and commented on the problem.

            SELECT `source`.`date` AS `date`, 
            `source`.`hour` AS `hour`, 
            `source`.`checkin` AS `checkin`, 
            `source`.`checkin_change` AS `checkin_change`, 
            `source`.`checkin_dyspnea` AS `checkin_dyspnea`, 
            `source`.`completed_checkin` AS `completed_checkin`, 
            `source`.`completed_enrollment` AS `completed_enrollment`, 
            `source`.`completed_extension` AS `completed_extension`, 
            `source`.`completed_finished` AS `completed_finished`, 
            `source`.`completed_nurse_followup` AS `completed_nurse_followup`, 
            `source`.`completed_worse` AS `completed_worse`, 
            `source`.`covid_patient_id` AS `covid_patient_id`, 
            `source`.`enrollment` AS `enrollment`, 
            `source`.`escalation_count` AS `escalation_count`, 
            `source`.`extended` AS `extended`, 
            `source`.`formatted_date` AS `formatted_date`, 
            `source`.`formatted_hour` AS `formatted_hour`, 
            `source`.`has_activity` AS `has_activity`, 
            `source`.`has_admit` AS `has_admit`, 
            `source`.`has_checkin` AS `has_checkin`, 
            `source`.`has_discharge` AS `has_discharge`, 
            `source`.`has_end` AS `has_end`, 
            `source`.`has_enrollment` AS `has_enrollment`, 
            `source`.`has_extension` AS `has_extension`, 
            `source`.`has_finished` AS `has_finished`, 
            `source`.`has_nurse_followup` AS `has_nurse_followup`, 
            `source`.`has_worse` AS `has_worse`, `source`.`nps_rating` AS `nps_rating`, 
            `source`.`nurse_followup` AS `nurse_followup`, 
            `source`.`offset` AS `offset`, `source`.`site` AS `site`, 
            `source`.`study_id` AS `study_id`, 

    /*
     * These are the missing columns.
     * They should be referenced as `source`.
     */
           `covid_patient_event`.`worse` AS `worse`, 
           `covid_patient_event`.`worse_dyspnea` AS `worse_dyspnea`,
  /* end of problem columns */

            `Enrollment Status` AS `Enrollment Status`
            FROM (SELECT CASE WHEN `covid_patient_event`.`completed_enrollment` = 1 THEN 'Enrolled' ELSE 'Not Enrolled' END AS `Enrollment Status`, 
            `covid_patient_event`.`has_enrollment` AS `has_enrollment`, 
            `covid_patient_event`.`study_id` AS `study_id`, 
            `covid_patient_event`.`site` AS `site`, 
            `covid_patient_event`.`formatted_date` AS `formatted_date`, `covid_patient_event`.`completed_enrollment` AS `completed_enrollment`, `covid_patient_event`.`date` AS `date`, 
            `covid_patient_event`.`hour` AS `hour`, 
            `covid_patient_event`.`checkin` AS `checkin`,
             `covid_patient_event`.`checkin_change` AS `checkin_change`, `covid_patient_event`.`checkin_dyspnea` AS `checkin_dyspnea`, `covid_patient_event`.`completed_checkin` AS `completed_checkin`, `covid_patient_event`.`completed_extension` AS `completed_extension`, `covid_patient_event`.`completed_finished` AS `completed_finished`, `covid_patient_event`.`completed_nurse_followup` AS `completed_nurse_followup`, `covid_patient_event`.`completed_worse` AS `completed_worse`, `covid_patient_event`.`covid_patient_id` AS `covid_patient_id`, 
            `covid_patient_event`.`enrollment` AS `enrollment`, 
            `covid_patient_event`.`escalation_count` AS `escalation_count`, 
            `covid_patient_event`.`extended` AS `extended`, 
            `covid_patient_event`.`formatted_hour` AS `formatted_hour`, 
            `covid_patient_event`.`has_activity` AS `has_activity`, 
            `covid_patient_event`.`has_admit` AS `has_admit`, 
            `covid_patient_event`.`has_checkin` AS `has_checkin`, 
            `covid_patient_event`.`has_discharge` AS `has_discharge`, 
            `covid_patient_event`.`has_end` AS `has_end`, 
            `covid_patient_event`.`has_extension` AS `has_extension`, 
            `covid_patient_event`.`has_finished` AS `has_finished`, 
            `covid_patient_event`.`has_nurse_followup` AS `has_nurse_followup`, `covid_patient_event`.`has_worse` AS `has_worse`, 
            `covid_patient_event`.`nps_rating` AS `nps_rating`, 
            `covid_patient_event`.`nurse_followup` AS `nurse_followup`, 
            `covid_patient_event`.`offset` AS `offset`, 
            `covid_patient_event`.`worse` AS `worse`, 
            `covid_patient_event`.`worse_dyspnea` AS `worse_dyspnea` FROM `covid_patient_event`) `source`
            WHERE (`source`.`has_enrollment` = TRUE
               AND `source`.`study_id` = 123 AND `source`.`site` = 'Main' AND `source`.`Enrollment Status` = 'Enrolled' AND `source`.`formatted_date` = '04/05/20')
            LIMIT 1048576

Is this a known issue or is there a work around? I have searched your open issues and the closest one I could find was https://github.com/metabase/metabase/issues/12507

Warmly,

Skip

Hi @scoon
You’re seeing this issue, which has been fixed and will be part of next release:
https://github.com/metabase/metabase/issues/12481

Great, thank you so much for the response!