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

Fix SHOW TABLES for hidden tpch and tpcds schemas #1007

Merged
merged 2 commits into from
Jul 2, 2019

Conversation

Praveen2112
Copy link
Member

Fixes #1005

@cla-bot cla-bot bot added the cla-signed label Jun 15, 2019
Copy link
Member

@findepi findepi left a 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;
Copy link
Member

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
Suggested change
return schemaNameToScaleFactor(schemaName) < 0 ? false : true;
return schemaNameToScaleFactor(schemaName) > 0;

@Override
public boolean schemaExists(ConnectorSession session, String schemaName)
{
return schemaNameToScaleFactor(schemaName) < 0 ? false : true;
Copy link
Member

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

@Praveen2112
Copy link
Member Author

@findepi Thanks for your insights. Have applied the comments

Copy link
Member

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

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

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as in tpch case

@findepi findepi merged commit 6be2956 into trinodb:master Jul 2, 2019
@findepi
Copy link
Member

findepi commented Jul 2, 2019

Merged, thanks!

@findepi findepi added this to the 316 milestone Jul 2, 2019
@findepi findepi mentioned this pull request Jul 2, 2019
6 tasks
@Praveen2112 Praveen2112 deleted the tpch_tpcds_hidden_schemas branch July 14, 2019 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

SHOW TABLES does not work for hidden tpch, tpcds schemas
2 participants