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

Issue sorting Tables #1018

Closed
the-dcruz opened this issue Aug 25, 2016 · 2 comments · Fixed by #3417
Closed

Issue sorting Tables #1018

the-dcruz opened this issue Aug 25, 2016 · 2 comments · Fixed by #3417

Comments

@the-dcruz
Copy link
Contributor

the-dcruz commented Aug 25, 2016

Sorting Sources->Tables by Database or SQL Editor returns an exception.

ProgrammingError: (_mysql_exceptions.ProgrammingError) 
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL 
server version for the right syntax to use near 'desc \n LIMIT 500' at line 2") 
[SQL: u'SELECT `tables`.created_on AS tables_created_on, `tables`.changed_on AS 
tables_changed_on, `tables`.id AS tables_id, `tables`.table_name AS tables_table_name, 
`tables`.main_dttm_col AS tables_main_dttm_col, `tables`.description AS tables_description, 
`tables`.default_endpoint AS tables_default_endpoint, `tables`.database_id AS tables_database_id,
`tables`.is_featured AS tables_is_featured, `tables`.annotation AS tables_annotation, 
`tables`.user_id AS tables_user_id, `tables`.offset AS tables_offset, `tables`.cache_timeout AS 
tables_cache_timeout, `tables`.`schema` AS tables_schema, `tables`.changed_by_fk AS 
tables_changed_by_fk, `tables`.created_by_fk AS tables_created_by_fk \nFROM `tables` ORDER BY 
database desc \n LIMIT %s'] [parameters: (500,)]
@the-dcruz
Copy link
Contributor Author

Looks like sorting by Database is probably an issue since it is a key word therefore causing the syntax issue.

I just now realized that sorting by SQL Editor actually returns a different error.

OperationalError: (_mysql_exceptions.OperationalError) 
(1054, "Unknown column 'sql_link' in 'order clause'") 
[SQL: u'SELECT `tables`.created_on AS tables_created_on, 
`tables`.changed_on AS tables_changed_on, 
`tables`.id AS tables_id, 
`tables`.table_name AS tables_table_name, 
`tables`.main_dttm_col AS tables_main_dttm_col,
`tables`.description AS tables_description, 
`tables`.default_endpoint AS tables_default_endpoint,
`tables`.database_id AS tables_database_id, 
`tables`.is_featured AS tables_is_featured,
`tables`.user_id AS tables_user_id, `tables`.offset AS tables_offset, 
`tables`.cache_timeout AS tables_cache_timeout, 
`tables`.`schema` AS tables_schema, 
`tables`.changed_by_fk AS tables_changed_by_fk, 
`tables`.created_by_fk AS tables_created_by_fk \n
FROM `tables` ORDER BY sql_link asc \n LIMIT %s'] [parameters: (500,)]

This issue is caused by sql_linkbeing a transient property defined as:

# Snippet from models.py

@property
    def sql_link(self):
        return '<a href="{}">SQL</a>'.format(self.sql_url)

I guess the fix would be to sort by database.id instead or have the column not sortable at all.

@ratb3rt
Copy link

ratb3rt commented Feb 7, 2017

Several other sorts affected by the same issue:
Databases: backend, creator
Tables: table, database
Slices: slice, creator
Dashboards: creator

zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 17, 2021
* initial

* tests added,1 typing issue present

* remove log

* remove color

* remove duplicate tooltip

* Update plugins/plugin-chart-echarts/src/Tree/transformProps.ts

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* clean

* merge

* optional name column,more tests...

* bug fix

* remove unused imports

* lint

* bug fix

* tying fix

* clean,typing fix

* stories added

* optional metric control

* bigger thumbnail

* optional root node name

* storybokk updated

* children list seperated instead of mutating data,if root node not provided defaault it to node with most children

* remove logs,optimization needed

* find best node if root not provided,use seperate children list to avoid issues if column name is children

* remove unused import

* type fix

* Update transformProps.ts

* Update debugging.md

* better todo

* updated radio button with new signature

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 24, 2021
* initial

* tests added,1 typing issue present

* remove log

* remove color

* remove duplicate tooltip

* Update plugins/plugin-chart-echarts/src/Tree/transformProps.ts

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* clean

* merge

* optional name column,more tests...

* bug fix

* remove unused imports

* lint

* bug fix

* tying fix

* clean,typing fix

* stories added

* optional metric control

* bigger thumbnail

* optional root node name

* storybokk updated

* children list seperated instead of mutating data,if root node not provided defaault it to node with most children

* remove logs,optimization needed

* find best node if root not provided,use seperate children list to avoid issues if column name is children

* remove unused import

* type fix

* Update transformProps.ts

* Update debugging.md

* better todo

* updated radio button with new signature

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 25, 2021
* initial

* tests added,1 typing issue present

* remove log

* remove color

* remove duplicate tooltip

* Update plugins/plugin-chart-echarts/src/Tree/transformProps.ts

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* clean

* merge

* optional name column,more tests...

* bug fix

* remove unused imports

* lint

* bug fix

* tying fix

* clean,typing fix

* stories added

* optional metric control

* bigger thumbnail

* optional root node name

* storybokk updated

* children list seperated instead of mutating data,if root node not provided defaault it to node with most children

* remove logs,optimization needed

* find best node if root not provided,use seperate children list to avoid issues if column name is children

* remove unused import

* type fix

* Update transformProps.ts

* Update debugging.md

* better todo

* updated radio button with new signature

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 26, 2021
* initial

* tests added,1 typing issue present

* remove log

* remove color

* remove duplicate tooltip

* Update plugins/plugin-chart-echarts/src/Tree/transformProps.ts

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* clean

* merge

* optional name column,more tests...

* bug fix

* remove unused imports

* lint

* bug fix

* tying fix

* clean,typing fix

* stories added

* optional metric control

* bigger thumbnail

* optional root node name

* storybokk updated

* children list seperated instead of mutating data,if root node not provided defaault it to node with most children

* remove logs,optimization needed

* find best node if root not provided,use seperate children list to avoid issues if column name is children

* remove unused import

* type fix

* Update transformProps.ts

* Update debugging.md

* better todo

* updated radio button with new signature

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
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 a pull request may close this issue.

2 participants