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

Allow tables with same name in different schemas in Blackhole #550

Conversation

kokosing
Copy link
Member

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

@cla-bot
Copy link

cla-bot bot commented Mar 27, 2019

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<>();
Copy link
Member

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.

Copy link
Member Author

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.

@findepi findepi changed the title Minor bug fix in BlackHoleConnector Allow tables with same name in different schemas in Blackhole Mar 27, 2019
@findepi
Copy link
Member

findepi commented Mar 27, 2019

@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);
Copy link
Member

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?

Copy link
Contributor

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);
Copy link
Member

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");
Copy link
Member

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?

Copy link
Contributor

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 :)

Copy link
Member

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!

@wenleix
Copy link
Contributor

wenleix commented Mar 27, 2019

@findepi

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.

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 :/

@kokosing kokosing force-pushed the origin/master/113_port_12457_from_legacy_presto branch from 9e74199 to c855e65 Compare April 9, 2019 07:49
@cla-bot
Copy link

cla-bot bot commented Apr 9, 2019

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.

Copy link
Member Author

@kokosing kokosing left a 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<>();
Copy link
Member Author

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
@kokosing kokosing force-pushed the origin/master/113_port_12457_from_legacy_presto branch from c855e65 to 8ed4664 Compare May 1, 2019 08:11
@cla-bot
Copy link

cla-bot bot commented May 1, 2019

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.

@kokosing kokosing merged commit 207665e into trinodb:master May 1, 2019
@kokosing kokosing deleted the origin/master/113_port_12457_from_legacy_presto branch May 1, 2019 13:15
@kokosing kokosing added this to the 310 milestone May 1, 2019
@kokosing kokosing mentioned this pull request May 1, 2019
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants