-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Allow tables with same name in different schemas in Blackhole #550
Allow tables with same name in different schemas in Blackhole #550
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/prestosql/cla. |
@@ -62,7 +62,7 @@ | |||
public static final String SCHEMA_NAME = "default"; | |||
|
|||
private final List<String> schemas = new ArrayList<>(); | |||
private final Map<String, BlackHoleTableHandle> tables = new ConcurrentHashMap<>(); | |||
private final Map<SchemaTableName, BlackHoleTableHandle> tables = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a check now that disallows table with same name in different schemas?
I don't see it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would this be needed? SchemaTableName
is a pair of schema and table name.
@kokosing please fix the cmt msg so that it says what the commit does. I edited the PR title with my suggestion for the cmt title. |
@@ -69,8 +69,14 @@ public void tearDown() | |||
public void testCreateSchema() | |||
{ | |||
assertEquals(queryRunner.execute("SHOW SCHEMAS FROM blackhole").getRowCount(), 2); | |||
assertThatQueryReturnsValue("CREATE TABLE nation as SELECT * FROM tpch.tiny.nation", 25L); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't really belong to testCreateSchema
, does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... I remember ending up doing this for some reason but didn't remember exactly ... it relates to the fact that we cannot cleanup new created schema in BlackholeConnector.
queryRunner.execute("CREATE SCHEMA blackhole.test"); | ||
assertEquals(queryRunner.execute("SHOW SCHEMAS FROM blackhole").getRowCount(), 3); | ||
assertThatQueryReturnsValue("CREATE TABLE test.nation as SELECT * FROM tpch.tiny.nation", 25L); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since default.nation and test.nation are identical, we cannot test whether we have 2 tables or just one.
Create tables with same name, but with different "type" (column list).
@@ -1435,7 +1435,7 @@ public void testQueryCancelByInterrupt() | |||
AtomicReference<Throwable> queryFailure = new AtomicReference<>(); | |||
|
|||
Future<?> queryFuture = executorService.submit(() -> { | |||
try (Connection connection = createConnection("blackhole", "default"); | |||
try (Connection connection = createConnection("blackhole", "blackhole"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the changes in this file necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findepi They are :) . Since before the schema name is not used to lookup the table, so it doesn't matter which schema you used... you still end up find the table in other schemas :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wenleix thanks for the clarification!
I assume "cmt msg" actually means "cmt title" ;) ? Since the whole commit message explained what this commit tries to fix. For the commit title, there is always the tradeoff of making commit title too long (50 characters) vs. make things clear in commit title :/ |
9e74199
to
c855e65
Compare
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/prestosql/cla. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased and responded to comments.
@@ -62,7 +62,7 @@ | |||
public static final String SCHEMA_NAME = "default"; | |||
|
|||
private final List<String> schemas = new ArrayList<>(); | |||
private final Map<String, BlackHoleTableHandle> tables = new ConcurrentHashMap<>(); | |||
private final Map<SchemaTableName, BlackHoleTableHandle> tables = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would this be needed? SchemaTableName
is a pair of schema and table name.
BlackholeConnector cannot have tables with same table names in different schemas. This is because originally BlackHoleConnector only supports `default` schema so it use the table name string to identify table. When creating schema was supported in 4e522f355ed7f0711d877e2259e489a8ebf626b9, the table identity should be updated to use SchemaTableName. Extracted from: prestodb/presto#12457
c855e65
to
8ed4664
Compare
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/prestosql/cla. |
Minor bug fix in BlackHoleConnector
BlackholeConnector cannot have tables with same table names in different
schemas.
This is because originally BlackHoleConnector only supports
default
schema so it use the table name string to identify table. When creating
schema was supported in 4e522f355ed7f0711d877e2259e489a8ebf626b9, the
table identity should be updated to use SchemaTableName.
Extracted from: prestodb/presto#12457