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

Labels of table columns with "custom sql" can not be changed #30040

Closed
3 tasks done
torbenw opened this issue Aug 28, 2024 · 3 comments
Closed
3 tasks done

Labels of table columns with "custom sql" can not be changed #30040

torbenw opened this issue Aug 28, 2024 · 3 comments
Labels
viz:charts:table Related to the Table chart

Comments

@torbenw
Copy link

torbenw commented Aug 28, 2024

Bug description

A chart of type "table" allows to edit columns. The column edit view has a tab "custom sql". When this tab is active changing the label of the column becomes available. After saving the changes and updating the column the table does not show the new label, it is still showing the name of the column from the data set.

Being able to rename column labels in "simple" column mode would also be helpful.

How to reproduce the bug

  1. Create a new chart of type "table"
  2. Add a column from a data set to the chart.
  3. Click on the column to open the edit dialog.
  4. Click on "custom sql".
  5. Click on the pencil icon next to the name of the column and change the column label.
  6. Click "save" in the column edit dialog.
  7. Click "update chart".
  8. Click "save" on the chart.
  9. The table is still showing the original column label, not the changed column label.

Screenshots/recordings

RenamedTableColumn

Superset version

4.0.2

Python version

I don't know

Node version

I don't know

Browser

Firefox

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
@torbenw torbenw changed the title Lables of table columns with "custom sql" can not be changed Labels of table columns with "custom sql" can not be changed Aug 28, 2024
@dosubot dosubot bot added the viz:charts:table Related to the Table chart label Aug 28, 2024
Copy link

dosubot bot commented Aug 28, 2024

Hey @torbenw! I'm here to help with any bugs, questions, or contributions you have for the project. Let's squash those bugs together! 🤖

I found a similar open issue that might be relevant to your problem: Can't use cross-filtering on a column from a table whose name has been overridden. The suggested solution in that issue is to allow for a UI-only change in the "Customize column" section instead of renaming the columns in SQL. This approach could potentially address the problem you're facing with the column labels not updating in the table view.

Additionally, there are existing unit tests that cover the functionality of renaming column labels in the "custom sql" tab. These tests ensure that the label updates correctly when switching to the SQL tab and saving the changes. You can find these tests in the following files:

  1. superset-frontend/src/explore/components/controls/DndColumnSelectControl/ColumnSelectPopover.test.tsx [1].
  2. superset-frontend/packages/superset-ui-core/test/query/getColumnLabel.test.ts [2].

The key differences between the "simple" column mode and the "custom sql" mode in terms of label customization and display are as follows:

  • Simple Mode: Automatically sets the label based on the selected column's name.
  • Custom SQL Mode: Allows for manual label customization and displays a SQL editor for custom expressions [3].

The column label update process in the context of the "custom sql" tab is implemented using the assign_column_label function, which ensures that the column names in the DataFrame correspond to what is expected by the visualization components [4].

You might want to check if the label update process is correctly implemented in your setup and if the UI-only change approach could be a viable solution for your issue.

To continue talking to Dosu, mention @dosu.

@torbenw
Copy link
Author

torbenw commented Aug 29, 2024

It works when you add a space in the "custom sql" window. Like if the column is called "date" you have to save "date " in that text window. Looks like a bug to me.

@torbenw
Copy link
Author

torbenw commented Aug 29, 2024

I guess this is already fixed in 4.1.0 with PR #29420: https://github.com/apache/superset/blob/4.1.0rc1/CHANGELOG/4.1.0.md

@torbenw torbenw closed this as completed Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
viz:charts:table Related to the Table chart
Projects
None yet
Development

No branches or pull requests

1 participant