dosubot[bot] commented on issue #37609: URL: https://github.com/apache/superset/issues/37609#issuecomment-3834795689
<!-- Greeting --> Hi @SanthoshLakshmi! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team. <!-- Answer --> This is a known issue in Superset 6.0.0: when a SQL dataset query returns zero rows, column metadata is not persisted, causing the dataset schema to appear empty and breaking charts and filters. Superset extracts column metadata for virtual datasets by running the query with a limit of 1 and using the SQLAlchemy cursor description, but the current logic discards metadata if no rows are returned—even though the cursor contains column info. This affects all databases and is recognized as a workflow pain point in the community. A recent pull request was created to fix this by preserving column metadata for empty result sets, ensuring column names and types are retained in the UI and exports even when there are zero rows. However, there is no confirmation that this fix is included in Superset 6.0.0 or any later release yet, and it's not mentioned in the documentation or release notes [source](https://github.com/apache/superset/pull/35962). Workarounds include temporarily modifying your query to always return at least one row (using conditional SQL or adding a dummy row) to force metadata detection, but this can be cumbersome and misleading. Superset 6.0.0 introduces a "do you want to sync" feature and a checkbox to skip automatic column syncing, which may help prevent unwanted column removal but does not fully resolve the zero-row metadata issue without the PR fix [source](https://github.com/apache/superset/issues/34810). If you need to patch Superset, the relevant logic is in `superset/result_set.py` (SupersetResultSet) and `superset/connectors/sqla/utils.py` (get_columns_description). The fix involves creating zero-length null arrays for each column when the result set is empty, so downstream consumers receive an empty table with correct column headers and types. Let me know if you want more details on patching or SQL workarounds. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/302fd6bc-03c6-4dde-a1b7-f9f5707a5cda?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/302fd6bc-03c6-4dde-a1b7-f9f5707a5cda?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/302fd6bc-03c6-4dde-a1b7-f9f5707a5cda?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/302fd6bc-03c6-4dde-a1b7-f9f5707a5cda?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/302fd6bc-03c6-4dde-a1b7-f9f5707a5cda?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/302fd6bc-03c6-4dde-a1b7-f9f5707a5cda?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/302fd6bc-03c6-4dde-a1b7-f9f5707a5cda?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=This%20is%20a%20known%20issue%20in%20Superset%206.0.0%3A%20when%20a%20SQL%20dataset%20query%20returns%20zero%20rows%2C%20column%20metadata%20is%20not%20persisted%2C%20causing%20the%20dataset%20schema%20to%20appear%20empty%20and%20breaking%20charts%20and%20filters.%20Superset%20extracts%20column%20metadata%20for%20virtual%20datasets%20by%20running%20the%20query%20with%20a%20limit%20of%201%20and%20using%20the%20SQLAlchemy%20cursor%20description%2C%20but%20the%20current%20logic%20discards%20metadata%20if%20no%20rows%20are%20returned%E2%80%94even%20though%20the%20cursor%20contains%20column%20info.%20This%20affects%20all%20databases%20and%20is%20recognized%20as%20a%20workflow%20pain%20point%20in%20the%20community.%0A%0AA%20recent%20pull%20request%20was% 20created%20to%20fix%20this%20by%20preserving%20column%20metadata%20for%20empty%20result%20sets%2C%20ensuring%20column%20names%20and%20types%20are%20retained%20in%20the%20UI%20and%20exports%20even%20when%20there%20are%20zero%20rows.%20However%2C%20there%20is%20no%20confirmation%20that%20this%20fix%20is%20included%20in%20Superset%206.0.0%20or%20any%20later%20release%20yet%2C%20and%20it%27s%20not%20mentioned%20in%20the%20documentation%20or%20release%20notes%20%5Bsource%5D%28https%3A//github.com/apache/superset/pull/35962%29.%0A%0AWorkarounds%20include%20temporarily%20modifying%20your%20query%20to%20always%20return%20at%20least%20one%20row%20%28using%20conditional%20SQL%20or%20adding%20a%20dummy%20row%29%20to%20force%20metadata%20detection%2C%20but%20this%20can%20be%20cumbersome%20and%20misleading.%20Superset%206.0.0%20introduces%20a%20%22do%20you%20want%20to%20sync%22%20feature%20and%20a%20checkbox%20to%20skip%20automatic%20column%20syncing%2C%20which%20may%20help%20prevent%20unwanted %20column%20removal%20but%20does%20not%20fully%20resolve%20the%20zero-row%20metadata%20issue%20without%20the%20PR%20fix%20%5Bsource%5D%28https%3A//github.com/apache/superset/issues/34810%29.%0A%0AIf%20you%20need%20to%20patch%20Superset%2C%20the%20relevant%20logic%20is%20in%20%60superset/result_set.py%60%20%28SupersetResultSet%29%20and%20%60superset/connectors/sqla/utils.py%60%20%28get_columns_description%29.%20The%20fix%20involves%20creating%20zero-length%20null%20arrays%20for%20each%20column%20when%20the%20result%20set%20is%20empty%2C%20so%20downstream%20consumers%20receive%20an%20empty%20table%20with%20correct%20column%20headers%20and%20types.%0A%0ALet%20me%20know%20if%20you%20want%20more%20details%20on%20patching%20or%20SQL%20workarounds.) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu _ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/37609) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
