Cannot create table with same name from a different datasource
See original GitHub issueMake 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
0.19.1
Expected results
That you could add the same table from a differnet datasource
Actual results
(raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (sqlite3.IntegrityError) UNIQUE constraint failed: tables.table_name [SQL: ‘INSERT INTO tables (created_on, changed_on, description, default_endpoint, is_featured, filter_select_enabled, “offset”, cache_timeout, params, perm, table_name, main_dttm_col, database_id, fetch_values_predicate, user_id, schema, sql, created_by_fk, changed_by_fk) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’] [parameters: (‘2017-11-10 16:36:45.635385’, ‘2017-11-10 16:36:45.635417’, None, None, 0, 0, 0, None, None, None, ‘<table_name>’, None, 2, None, None, ‘’, None, None, None)]
Steps to reproduce
We have a few datasources using the same schema. We would like to configure query tables from each.
It seems an easy fix would be just to change this line: https://github.com/apache/incubator-
superset/blob/master/superset/migrations/versions/4e6a06bad7a8_init.py#L84
to sa.UniqueConstraint('table_name', 'database_id')
. This line does have such a constraint ( with schema too), https://github.com/apache/incubator-superset/blob/1ea4521d0c116d96b51749613347279669529dd0/superset/connectors/sqla/models.py#L188
Its similar to https://github.com/apache/incubator-superset/pull/3583/files, so perhaps a fix could be included in that PR too?
Thanks, great project by the way!
Issue Analytics
- State:
- Created 6 years ago
- Comments:27 (8 by maintainers)
Top GitHub Comments
I am using 0.25.6 . This still seems to be an issue. I tried adding another
nyc_data_external
from a different databasecustomer_data
, which also happens to havenyc_data_external
table. The error was still thrown, @mistercrunchI just can’( believe it’s not possible to have two databases with tables having the same name??!! I must be missing something … am I ?