-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix SHOW TABLES for hidden tpch and tpcds schemas #1007
Conversation
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.
Thanks @Praveen2112 for picking this up!
@Override | ||
public boolean schemaExists(ConnectorSession session, String schemaName) | ||
{ | ||
return schemaNameToScaleFactor(schemaName) < 0 ? false : true; |
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.
- sf0 does not exists
- this needs to be handled the same way as in
io.prestosql.plugin.tpcds.TpcdsMetadata#getTableHandle
return schemaNameToScaleFactor(schemaName) < 0 ? false : true; | |
return schemaNameToScaleFactor(schemaName) > 0; |
@Override | ||
public boolean schemaExists(ConnectorSession session, String schemaName) | ||
{ | ||
return schemaNameToScaleFactor(schemaName) < 0 ? false : true; |
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.
TPCH has a bug -- io.prestosql.plugin.tpch.TpchMetadata#getTableHandle
accepts scale factor 0, and so
select count(*) from tpch.sf0.nation;
- should fail with schema not found
- but it fails with:
java.lang.IllegalArgumentException: Scale factor must be larger than 0
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:141)
at io.prestosql.plugin.tpch.TpchTableHandle.<init>(TpchTableHandle.java:46)
at io.prestosql.plugin.tpch.TpchTableHandle.<init>(TpchTableHandle.java:36)
at io.prestosql.plugin.tpch.TpchMetadata.getTableHandle(TpchMetadata.java:176)
So:
- fix io.prestosql.plugin.tpch.TpchMetadata#getTableHandle's
if (scaleFactor
as it is in tpcds - make this line the same as in tpcds
presto-tpch/src/test/java/io/prestosql/plugin/tpch/TestTpchMetadata.java
Show resolved
Hide resolved
53df09a
to
fa6a179
Compare
@findepi Thanks for your insights. Have applied the comments |
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.
Just minor comments
|
||
public void testShowTables() | ||
{ | ||
Session session = testSessionBuilder() |
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.
- inline (it's used only once)
- create a helper method that constructs a Session for given schema
if (scaleFactor < 0) { | ||
return null; | ||
if (scaleFactor > 0) { | ||
return new TpchTableHandle(tableName.getTableName(), scaleFactor); |
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.
please revert.
Just make the comparison:
if (scaleFactor <= 0) {
return null;
}
if (scaleFactor <= 0) { | ||
return null; | ||
if (scaleFactor > 0) { | ||
return new TpcdsTableHandle(tableName.getTableName(), scaleFactor); |
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.
please revert
@Test | ||
public void testShowTables() | ||
{ | ||
Session session = testSessionBuilder() |
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.
as in tpch case
fa6a179
to
8ef6c7f
Compare
Merged, thanks! |
Fixes #1005