Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: alias column when fetching values #26120

Merged
merged 1 commit into from
Nov 28, 2023
Merged

fix: alias column when fetching values #26120

merged 1 commit into from
Nov 28, 2023

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Nov 28, 2023

SUMMARY

The endpoint that returns values for a given column, which powers filter dropdowns, is failing for some databases (Snowflake, Clickhouse) because the query generated has an unusual alias for the column.

For example, for Clickhouse, when selecting the values of a column called name we have the following query:

SELECT DISTINCT name AS name_12345
FROM ...

Clickhouse adds the stochastic alias name_#####, and reading the values from the Pandas dataframe fails because the column name is not present.

For Snowflake we have a different issue:

SELECT DISTINCT NAME AS NAME
FROM ...

Here, the resulting dataframe will have NAME but not name, since for Snowflake these are identical.

This PR fixes the problem by adding an alias to the projection. This way we know the alias is present in the dataframe.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link

codecov bot commented Nov 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (849ca64) 69.10% compared to head (bd26ad0) 69.10%.
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #26120   +/-   ##
=======================================
  Coverage   69.10%   69.10%           
=======================================
  Files        1940     1940           
  Lines       75869    75869           
  Branches     8445     8445           
=======================================
  Hits        52428    52428           
  Misses      21266    21266           
  Partials     2175     2175           
Flag Coverage Δ
hive 53.68% <0.00%> (ø)
javascript 56.28% <ø> (ø)
mysql 78.16% <100.00%> (ø)
postgres 78.25% <100.00%> (ø)
presto 53.63% <0.00%> (ø)
python 82.95% <100.00%> (ø)
sqlite 76.91% <100.00%> (ø)
unit 55.79% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@betodealmeida betodealmeida merged commit 7223633 into master Nov 28, 2023
57 checks passed
sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Nov 28, 2023
@sadpandajoe
Copy link
Member

🏷️ preset:2023.47

# automatically add a random alias to the projection because of the
# call to DISTINCT; others will uppercase the column names. This
# gives us a deterministic column name in the dataframe.
[target_col.get_sqla_col(template_processor=tp).label("column_values")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding a comment explaining the context! It's always helpful.

@michael-s-molina michael-s-molina added v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch labels Nov 29, 2023
michael-s-molina pushed a commit that referenced this pull request Dec 4, 2023
michael-s-molina pushed a commit that referenced this pull request Dec 4, 2023
josedev-union pushed a commit to Ortege-xyz/studio that referenced this pull request Jan 22, 2024
@mistercrunch mistercrunch added 🍒 3.0.3 🍒 3.0.4 🍒 3.1.0 🍒 3.1.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Mar 8, 2024
sfirke pushed a commit to sfirke/superset that referenced this pull request Mar 22, 2024
@mistercrunch mistercrunch deleted the sc-76910 branch March 26, 2024 18:06
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/S v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch 🍒 3.0.3 🍒 3.0.4 🍒 3.1.0 🍒 3.1.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants