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

Can't sync column from source on complex queries #13865

Closed
2 of 3 tasks
ValentinC-BR opened this issue Mar 30, 2021 · 5 comments
Closed
2 of 3 tasks

Can't sync column from source on complex queries #13865

ValentinC-BR opened this issue Mar 30, 2021 · 5 comments
Assignees
Labels
#bug Bug report explore:dataset Related to the dataset of Explore P2 Priority item - High question & help wanted Use Github discussions instead

Comments

@ValentinC-BR
Copy link

I can't use "sync column from source" on virtual datasets whose query doesn't start with SELECT.

Expected results

Whatever my query is, I should be able to sync column from source for my virtual datasets.

Actual results

When my query starts with SELECT, there's no problem.
When my query start with "WITH" statements :

  • I can create a virtual dataset using the "EXPLORE" feature in SQL Lab
  • I can't update it and sync columns from source : I get the "ONLY SELECT STATEMENTS ARE ALLOWED" error

I'm forced to re-run the query in SQL Lab, and save is over the previous virtual dataset

What's more, contrary to the previous version of superset (0.x.x), the time columns are not detected, but this seems to be a different issue.

Screenshots

image

How to reproduce the bug

  1. Run a query in SQL Lab starting with a "WITH" statement
  2. Click on Explore and create a virtual dataset
  3. Go to dataset, update the query (you can add/remove/modify a column, anything works, even a mere filter)
  4. Save
  5. Click on 'Sync Columns from source' (it should get your new column list)
  6. See error

Environment

(please complete the following information):

  • superset version: 1.0.1
  • python version: 3.7.9
  • node.js version: doesn't apply, I run on Kubernetes, using gunicorn as server
  • source : Athena

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

Nothing to report

@ValentinC-BR ValentinC-BR added the #bug Bug report label Mar 30, 2021
@junlincc junlincc added P2 Priority item - High question & help wanted Use Github discussions instead explore:dataset Related to the dataset of Explore labels May 21, 2021
@betodealmeida
Copy link
Member

Taking a look.

@betodealmeida
Copy link
Member

I tested with a simple query and it worked:

WITH RAW AS (SELECT name, color FROM bart_lines)
SELECT * FROM RAW

We've had problems in the past with our SQL parser not being able to identify CTEs as SELECT statements correctly, and I fixed a few of them lately:

I suspect the original SQL that triggered this problem fell into this category.

@ValentinC-BR I'm going to close the ticket, but feel free to reopen if you can still repro it — if I have the SQL of the virtual dataset I can fix it.

@ValentinC-BR
Copy link
Author

ValentinC-BR commented Jan 5, 2022

My bad, maybe it didn't come from queries that don't start with SELECT, but with queries with comments.
.
It seems that the comments (-- MY COMMENT HERE) are not well supported.

@ValentinC-BR
Copy link
Author

ValentinC-BR commented Jan 5, 2022

The title of this issue could be changed, as it might not be related to complex queries.

@betodealmeida
Copy link
Member

No worries, sorry for the delay, this ticket fell under my radar.

If the problem was comments then #16769 should fix it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report explore:dataset Related to the dataset of Explore P2 Priority item - High question & help wanted Use Github discussions instead
Projects
None yet
Development

No branches or pull requests

4 participants