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

Little questions about filtering logic in ThriftHiveMetastoreClient.getTableMeta when using wildcard characters #24789

Open
HymnToLife opened this issue Jan 24, 2025 · 0 comments

Comments

@HymnToLife
Copy link

HymnToLife commented Jan 24, 2025

I have some questions about the getTableMeta method in the ThriftHiveMetastoreClient class in Trino's version 453. The problem arises when the databaseName contains wildcard characters (* or |).
According to the current implementation:

if (databaseName.indexOf('*') >= 0 || databaseName.indexOf('|') >= 0) {
    // in this case we replace any pipes with a glob and then filter the output
    return client.getTableMeta(prependCatalogToDbName(catalogName, databaseName.replace('|', '*')), "*", ImmutableList.of()).stream()
            .filter(tableMeta -> tableMeta.getDbName().equals(databaseName))
            .collect(toImmutableList());
}

It applies a filter on the result stream that checks for exact matches of tableMeta.getDbName() against the original databaseName, which includes wildcards. This would definitely lead to an empty list being returned because no database name can exactly match a pattern containing wildcards.

For example, assuming there are four schemas in Hive: a1, a2, b1, b2, if we execute:

SELECT * FROM hive.information_schema.tables WHERE table_schema IN ('a*|b*');

And the execution enters the aforementioned logic, it will return an empty list. However, if we directly pass the dbpattern into getTableMeta without the extra filtering, it returns the correct results.

Is this normal implementation logic or is there any extra purpose?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant