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

[Sqllab] Error: no such column When there are same fields in two tables with a join #5739

Closed
3 tasks done
Narcissus7 opened this issue Aug 27, 2018 · 9 comments · Fixed by #5778
Closed
3 tasks done

Comments

@Narcissus7
Copy link
Contributor

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if 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

Superset version

master

Actual results

wx20180827-143236 2x

but in Explore, can't get the field id__1
wx20180827-143439 2x

Steps to reproduce

Select * [choose two tables with same fields]
Run query
Explore

@mistercrunch
Copy link
Member

Which db engine is this? Looks like databases and drivers do different things to manage duplicated column names.

@Narcissus7
Copy link
Contributor Author

Narcissus7 commented Aug 28, 2018

Above db engine is SQLite. I have just tested MySQL.
wx20180828

What can i do to avoid this error?

@mistercrunch
Copy link
Member

The workaround is to alias your fields uniquely as in:

SELECT a.id as foo_id, b.id as bar_id

@Narcissus7
Copy link
Contributor Author

Thanks.
But there may be many fields. For instance:(tables and table_columns are original tables of superset)
SELECT * FROM tables a LEFT JOIN table_columns b ON a.id=b.table_id
I still want to find a way to use SELECT *

@villebro
Copy link
Member

@Narcissus7 As Superset wraps the SQL Lab query into a subquery, I don't think there is any way for Superset to select the deduplicated column without explicit aliases as @mistercrunch suggested. One approach would be to somehow reconstruct the the SELECT *... into explicit SELECT a.col as col, b.col as col__1..., but I don't think that's really feasible. I think it might be better to raise an Exception in SQL Lab if there are duplicates.

@Narcissus7
Copy link
Contributor Author

@villebro I see. Thanks a lot

@mistercrunch
Copy link
Member

mistercrunch commented Aug 30, 2018

Here's what the query in the explore view looks like

SELECT id AS id,
       id__1 AS id__1
FROM
  (SELECT a.id,
          b.id
   FROM ab_view_menu a
   LEFT JOIN ab_permission_view b ON a.id = b.view_menu_id) AS expr_qry
LIMIT 1000

@mistercrunch
Copy link
Member

We could try to detect the double underscore __ when users click the Explore button and tell people to alias their columns properly.

@mistercrunch
Copy link
Member

#5778

mistercrunch added a commit that referenced this issue Sep 19, 2018
* [explore flow] handling duplicated column aliases

closes #5739

* lint
mistercrunch added a commit to lyft/incubator-superset that referenced this issue Sep 21, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
mistercrunch added a commit to lyft/incubator-superset that referenced this issue Sep 21, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
betodealmeida pushed a commit to lyft/incubator-superset that referenced this issue Oct 11, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
betodealmeida pushed a commit to lyft/incubator-superset that referenced this issue Oct 12, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint
betodealmeida pushed a commit to lyft/incubator-superset that referenced this issue Oct 12, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
betodealmeida pushed a commit to lyft/incubator-superset that referenced this issue Oct 12, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
youngyjd pushed a commit to lyft/incubator-superset that referenced this issue Oct 17, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
youngyjd pushed a commit to lyft/incubator-superset that referenced this issue Oct 17, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
youngyjd pushed a commit to lyft/incubator-superset that referenced this issue Oct 17, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
youngyjd pushed a commit to lyft/incubator-superset that referenced this issue Oct 17, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
mistercrunch added a commit to lyft/incubator-superset that referenced this issue Oct 29, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
betodealmeida pushed a commit to lyft/incubator-superset that referenced this issue Oct 30, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
betodealmeida pushed a commit to lyft/incubator-superset that referenced this issue Oct 30, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
betodealmeida pushed a commit to lyft/incubator-superset that referenced this issue Oct 30, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
betodealmeida pushed a commit to lyft/incubator-superset that referenced this issue Oct 30, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
betodealmeida pushed a commit to lyft/incubator-superset that referenced this issue Oct 30, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
youngyjd pushed a commit to lyft/incubator-superset that referenced this issue Nov 2, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
youngyjd pushed a commit to lyft/incubator-superset that referenced this issue Nov 2, 2018
* [explore flow] handling duplicated column aliases

closes apache#5739

* lint

(cherry picked from commit 75bc501)
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.

3 participants