Query won't download properly

So, the query I'm working with is natively written and ultimately outputs ~12K rows across 12 columns. When I download these results (as CSV or XLSX) and open the file, the spreadsheet is missing every column from the original query, save a single date column - this is after taking several minutes to download. Any ideas? We are on 0.41.2.

Hi @chadwicke
Post "Diagnostic Info" from Admin > Troubleshooting.
And can you include the output by going to the URL /api/card/123, where 123 is the question ID.

{"description":"This will count the number of Statements on each PDF/Bill Upload","archived":false,"collection_position":null,"table_id":null,"result_metadata":[{"name":"Group ID","display_name":"Group ID","base_type":"type/Text","effective_type":"type/Text","field_ref":["field","Group ID",{"base-type":"type/Text"}],"semantic_type":null,"fingerprint":{"global":{"distinct-count":5,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":5.0}}}},{"name":"Group","display_name":"Group","base_type":"type/Text","effective_type":"type/Text","field_ref":["field","Group",{"base-type":"type/Text"}],"semantic_type":null,"fingerprint":{"global":{"distinct-count":5,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":6.7085}}}},{"name":"subscription_number","display_name":"subscription_number","base_type":"type/Text","effective_type":"type/Text","field_ref":["field","subscription_number",{"base-type":"type/Text"}],"semantic_type":"type/Subscription","fingerprint":{"global":{"distinct-count":41,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":11.0}}}},{"name":"current_subscription_start_date","display_name":"current_subscription_start_date","base_type":"type/Text","effective_type":"type/Text","field_ref":["field","current_subscription_start_date",{"base-type":"type/Text"}],"semantic_type":"type/Subscription","fingerprint":{"global":{"distinct-count":5,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":10.0}}}},{"name":"estar_name","display_name":"estar_name","base_type":"type/Text","effective_type":"type/Text","field_ref":["field","estar_name",{"base-type":"type/Text"}],"semantic_type":null,"fingerprint":{"global":{"distinct-count":167,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":19.611}}}},{"name":"estar_building_id","display_name":"estar_building_id","base_type":"type/BigInteger","effective_type":"type/BigInteger","field_ref":["field","estar_building_id",{"base-type":"type/BigInteger"}],"semantic_type":null,"fingerprint":{"global":{"distinct-count":167,"nil%":0.0},"type":{"type/Number":{"min":1048407.0,"q1":5867544.989242617,"q3":8623173.9008974,"max":1.563579E7,"sd":2860004.1212774157,"avg":7202695.4185}}}},{"name":"delivered_at","display_name":"delivered_at","base_type":"type/DateTime","effective_type":"type/DateTime","field_ref":["field","delivered_at",{"base-type":"type/DateTime"}],"semantic_type":null,"fingerprint":{"global":{"distinct-count":751,"nil%":0.0},"type":{"type/DateTime":{"earliest":"2021-01-20T23:16:57-08:00","latest":"2021-11-26T14:35:47-08:00"}}}},{"name":"original_filename","display_name":"original_filename","base_type":"type/Text","effective_type":"type/Text","field_ref":["field","original_filename",{"base-type":"type/Text"}],"semantic_type":null,"fingerprint":{"global":{"distinct-count":1606,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":28.131}}}},{"name":"statement_id","display_name":"statement_id","base_type":"type/Text","effective_type":"type/Text","field_ref":["field","statement_id",{"base-type":"type/Text"}],"semantic_type":null,"fingerprint":{"global":{"distinct-count":1711,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":36.0}}}},{"name":"statement_date","display_name":"statement_date","base_type":"type/Date","effective_type":"type/Date","field_ref":["field","statement_date",{"base-type":"type/Date"}],"semantic_type":null,"fingerprint":{"global":{"distinct-count":607,"nil%":0.007},"type":{"type/DateTime":{"earliest":"2016-03-09T00:00:00-08:00","latest":"2021-11-24T00:00:00-08:00"}}}},{"name":"account_number","display_name":"account_number","base_type":"type/Text","effective_type":"type/Text","field_ref":["field","account_number",{"base-type":"type/Text"}],"semantic_type":null,"fingerprint":{"global":{"distinct-count":404,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":10.001}}}},{"name":"provider_code","display_name":"provider_code","base_type":"type/Text","effective_type":"type/Text","field_ref":["field","provider_code",{"base-type":"type/Text"}],"semantic_type":null,"fingerprint":{"global":{"distinct-count":118,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":15.4155}}}}],"creator":{"email":"john@example.com","first_name":"John","last_login":"2021-11-30T01:10:10.067973Z","is_qbnewb":false,"is_superuser":true,"id":3,"last_name":"Smith","date_joined":"2018-07-02T21:07:13.217Z","common_name":"John Smith"},"can_write":true,"database_id":10,"enable_embedding":false,"collection_id":null,"query_type":"native","name":"Offline Statement Uploads with Site Level Subscription Overrides","last_query_start":"2021-12-01T21:28:22.523111Z","dashboard_count":1,"average_query_time":364273.047619047619,"creator_id":3,"moderation_reviews":,"updated_at":"2021-12-01T21:34:47.871134Z","made_public_by_id":null,"embedding_params":null,"cache_ttl":null,"dataset_query":{"native":{"query":"-- WARNING: dem_sources_per_provider does not have records for bulk-uploads. We must join from reading->meter->util_acct to get the building to apply site-level-subscription.\n-- ALSO NOTE: It is possible for sources to have no sync_meter_readings if:\n-- • Either the corresponding data already matched or was contained by an existing reading (by dates) OR\n-- • Corresponding meter/readings were deleted\n-- We can query for the count of uploads, but do not know how many account x statements were present.\n\nSELECT\n CONVERT(rg.id, char) AS 'Group ID',\n rg.name AS 'Group',\n zs.subscription_number,\n DATE_ADD(zs.subscription_start_date, INTERVAL TIMESTAMPDIFF(YEAR, zs.subscription_start_date, DATE_SUB(NOW(), INTERVAL 1 MONTH)) YEAR) AS current_subscription_start_date,\n msub.estar_name,\n msub.estar_building_id,\n mas.delivered_at,\n mas.original_filename,\n ms.UUID_STRING(mas.statement_id_lsb, mas.statement_id_msb) AS statement_id,\n msmr.statement_date,\n msua.account_number,\n msua.provider_code\n\nFROM ms.dem_sources mas\nJOIN ms.sync_meter_readings msmr\n ON msmr.statement_id_lsb=mas.statement_id_lsb\n AND msmr.statement_id_msb=mas.statement_id_msb\nJOIN ms.sync_meters msm\n ON msm.id=msmr.meter_id\nJOIN ms.sync_utility_accounts msua\n ON msua.id=msm.utility_account_id\nJOIN ms.sync_user_buildings msub\n ON msub.id=msua.user_building_id\nJOIN ms.sync_accounts msa\n ON msa.sync_account_id=msub.sync_account_id\nJOIN railmodel.groups rg\n ON rg.id=msa.id\nJOIN zuora.site_subscription_overrides zsso\n ON zsso.building_id=COALESCE(msub.estar_parent_id, msub.estar_building_id)\n AND zsso.building_source='ENERGYSTAR'\nJOIN zuora.subscriptions zs\n ON zs.subscription_number=zsso.zuora_subscription_number\n\nWHERE zs.status = 'Active'\n AND mas.status = 'PROCESSED'\n AND mas.delivered_at >= (DATE_ADD(zs.subscription_start_date, INTERVAL TIMESTAMPDIFF(YEAR, zs.subscription_start_date, DATE_SUB(NOW(), INTERVAL 1 MONTH)) YEAR))\n AND mas.delivered_at < (DATE_ADD(zs.subscription_start_date, INTERVAL TIMESTAMPDIFF(YEAR, zs.subscription_start_date, NOW())+1 YEAR))\n\nGROUP BY mas.statement_id_lsb, mas.statement_id_msb,\n msm.utility_account_id,\n msmr.statement_date,\n zs.subscription_number, zs.subscription_start_date\n\nORDER BY rg.id, mas.delivered_at desc;","template-tags":{}},"type":"native","database":10},"id":651,"display":"table","last-edit-info":{"id":30,"email":"john@example.com","first_name":"John","last_name":"Smith","timestamp":"2021-02-12T22:07:22.327242Z"},"visualization_settings":{"table.pivot_column":"Group ID","table.cell_column":"subscription_number","table.columns":[{"name":"meter_id","enabled":true},{"name":"from_date","enabled":true},{"name":"orig_urja_from_date","enabled":true},{"name":"to_date","enabled":true},{"name":"orig_urja_to_date","enabled":true},{"name":"cost","enabled":true},{"name":"usage","enabled":true},{"name":"estar_id","enabled":true},{"name":"received","enabled":true},{"name":"source_url_id","enabled":true},{"name":"statement_id_lsb","enabled":true},{"name":"statement_id_msb","enabled":true},{"name":"batch_timestamp","enabled":true},{"name":"statement_date","enabled":true},{"name":"demand","enabled":true},{"name":"demand_charge","enabled":true},{"name":"data_source","enabled":true},{"name":"created_at","enabled":true},{"name":"updated_at","enabled":true},{"name":"id","enabled":true},{"name":"sync_account_id","enabled":true},{"name":"meter_number","enabled":true},{"name":"utility_account_id","enabled":true},{"name":"estar_id_2","enabled":true},{"name":"urja_type","enabled":true},{"name":"urja_units","enabled":true},{"name":"unshared","enabled":true},{"name":"first_bill_date","enabled":true},{"name":"inactive_date","enabled":true},{"name":"latest_definition_check","enabled":true},{"name":"is_active_in_estar","enabled":true},{"name":"urja_demand_units","enabled":true},{"name":"orig_currency","enabled":true},{"name":"orig_urja_units","enabled":true},{"name":"created_at_2","enabled":true},{"name":"updated_at_2","enabled":true}],"column_settings":{"["name","current_subscription_start_date"]":{"date_style":"MMMM D, YYYY","time_enabled":null}}},"collection":null,"created_at":"2019-10-11T15:44:27.691Z","public_uuid":null}

So there's what pops out when I use the API link you provided. I don't have superuser/admin access, but I'll try to get that Troubleshooting data for you.

@chadwicke I cannot reproduce, but I have absolutely no idea how you've ended up with those visualization settings. That shouldn't be possible, I cannot create a question that looks like that.

I'm guessing this problem only occurs on specific questions, but not others. So can you provide some way of reproducing this problem, or provide the metadata for two questions, where one works and another fails?

I have the diagnostic file for the query. Maybe this is a stupid question, but is it safe for me to just dump the file here?

@chadwicke What, "Diagnostic Info" from Admin > Troubleshooting? Yes, it contains no sensitive information.

But again, like I said, I have not been able to reproduce, so I would recommend that you get in touch with your administrators to figure out how to reproduce the problem preferably with Sample Dataset.