Skip to content

fix: Handle COUNT(*) as column name in KQL dialect#38

Closed
LiamTorrelli wants to merge 7 commits intomainfrom
fix-count-all
Closed

fix: Handle COUNT(*) as column name in KQL dialect#38
LiamTorrelli wants to merge 7 commits intomainfrom
fix-count-all

Conversation

@LiamTorrelli
Copy link

@LiamTorrelli LiamTorrelli commented Apr 25, 2025

This commit fixes an issue where using COUNT() as a column name in Apache
Superset's drill-by functionality would result in a 'Semantic error:
Unsupported calculated column name COUNT(
)' error.

Changes:

  • Add special handling for COUNT(*) as a column name
  • Refactor _get_projection_or_summarize method to reduce complexity
  • Add helper methods for processing columns and checking for COUNT(*)
  • Differentiate between literal_column and regular column usage of COUNT(*)
  • Add special handling for the case where there are WHERE clauses
  • Add handling for quoted "COUNT(*)" expressions
  • Add test case to verify the fix works correctly
  • Fix linting issues and format code according to Black style guidelines

The fix ensures that COUNT() is properly translated to count() when used as
a function and properly quoted as ["COUNT(
)"] when used as a column name or
alias, which resolves the error in Superset's drill-by functionality."

@LiamTorrelli LiamTorrelli requested a review from pa1ch April 25, 2025 10:16
@ag-ramachandran
Copy link
Contributor

@LiamTorrelli, I was working on this seperately as well. I have a PR (#39). The changes on that are a little more minimal. Perhaps, would you want to check if it works for all cases you had ?

@pa1ch pa1ch closed this May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants