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

Phoenix Connector Lowercase Table/View could not be find #858

Closed
SimonWan1029 opened this issue May 31, 2019 · 4 comments
Closed

Phoenix Connector Lowercase Table/View could not be find #858

SimonWan1029 opened this issue May 31, 2019 · 4 comments
Assignees

Comments

@SimonWan1029
Copy link

Once create a phoenix view which schema or table name is lowercased, then presto could not find these table ;

@findepi
Copy link
Member

findepi commented May 31, 2019

Upon cursory reading of the source, I would assume this line might be responsible:
https://github.com/prestosql/presto/blob/b763176ff1c33bce413911908bda67b63ee5e2f4/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/BaseJdbcClient.java#L649-L652

If the uppercase is the default case for Phoenix, it may be it works as intended. JDBC-based connectors support case-insensitive name matching
https://github.com/prestosql/presto/blob/03bb0a426732f6ea947844dcc652a3ae2c76af1b/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/BaseJdbcConfig.java#L107-L112
It's not available for Phoenix though, as the connector does not bind/configure the BaseJdbcConfig object.

@vincentpoon would you like to take a look?

@vincentpoon vincentpoon self-assigned this May 31, 2019
@vincentpoon
Copy link
Member

For DatabaseMetaData#storesUpperCaseIdentifiers, Phoenix returns true, so by default unquoted identifiers are uppercased.

I think the issue here is with quoted identifiers. My general recommendation would be to not use quoted mixed/lowercase identifiers. Phoenix does support them, but certain areas can be confusing and/or not implemented well. For example, both PhoenixDatabaseMetaData#storesUpperCaseQuotedIdentifiers and PhoenixDatabaseMetaData#storesMixedCaseQuotedIdentifiers return true. But I'll see if we can support mixed case quoted here in the connector.

@findepi
Copy link
Member

findepi commented May 31, 2019

@vincentpoon proper support for case sensitive identifiers requires engine changes (#17).
Part of that will be to add case insensitive table name resolution when user does not quote the identifier in the query.
So when #17 is done, then:

  1. SELECT .. FROM "some_table" in Presto ⇒ table needs to be exactly lower case (some_table)
  2. SELECT .. FROM "SOME_TABLE" in Presto ⇒ table needs to be exactly upper case (SOME_TABLE)
  3. SELECT .. FROM some_table in Presto ⇒ table needs to be some_table case insensitively (some_table, SomE_TabLe, SOME_TABLE, etc.)

To support 3. the connector will need to be able to do case insensitive name resolution.
In JDBC connectors this is currently supported as an opt-in feature (the case-insensitive-name-matching configuration toggle).

Would it be possible to expose this functionality in Phoenix connector as well?
I guess you didn't bind BaseJdbcConfig in guice because not all its configuration toggles make sense.
Make we introduce a separate config class for the opt-in case insensitive name matching?

cc @electrum

@vincentpoon
Copy link
Member

@SimonWan1029 @findepi Check out #872 , which adds support for case-insensitive-name-matching

You'll need to add the following line into your phoenix catalog properties file:
case-insensitive-name-matching=true. Then you should be able to query your case sensitive tables.

@electrum electrum closed this as completed Jun 1, 2019
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

4 participants