question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot create table with same name from a different datasource

See original GitHub issue

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

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:closed
  • Created 6 years ago
  • Comments:27 (8 by maintainers)

github_iconTop GitHub Comments

6reactions
SanjayJoshcommented, Jul 2, 2018

I am using 0.25.6 . This still seems to be an issue. screen shot 2018-07-02 at 2 35 46 pm I tried adding another nyc_data_external from a different database customer_data, which also happens to have nyc_data_external table. The error was still thrown, @mistercrunch

4reactions
FredericLatourcommented, Feb 24, 2020

I just can’( believe it’s not possible to have two databases with tables having the same name??!! I must be missing something … am I ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot create table with same name from a different ...
Solution would be to rename table, create new table and copy over data in a new migration. Or use some other db :) ......
Read more >
Can't create a table with the same name I deleted before
3 - I'm trying to create a table with the same name, and stay with error in the table_name, written: "There is already...
Read more >
sql - Unable to create temp table with same name but in ...
The easiest solution would be to create the temp table with the minimum columns needed, then add columns as necessary based on the...
Read more >
Is it possible to have 2 tables with the same name in ...
It is not possible to create two tables with same name in same schema. A user can own one schema with his own...
Read more >
CREATE TABLE (Transact-SQL) - SQL Server
Creates a new table in SQL Server and Azure SQL Database. ... table names (names prefixed with a single number sign ( #...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found