trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
9.9k stars 2.86k forks source link

Trino + Pinot Connector - Lowercasing table name in query #6789

Closed Nguyen-Kha closed 2 years ago

Nguyen-Kha commented 3 years ago

When querying through the Trino CLI for data stored in Apache Pinot (both inside docker container), all query characters are converted to lowercase which causes an issue for querying tables with an uppercase character in its name.

For example, a table in Pinot is called baseballStats When sending this query through the Trino CLI: SELECT * FROM baseballStats LIMIT 10; Pinot will receive it as: select * from baseballstats limit 10 which will cause an error on the pinot side since the query sent from Trino is being lowercased.

Is there a way to keep the casing of queries in Trino?

hashhar commented 3 years ago

This shouldn't happen as long as the table was not very recently created (older than pinot.metadata-expiry) since the Pinot connector tries to resolve the name as it appears in Pinot. See https://github.com/trinodb/trino/blob/7fd62db50aec490907e93412441fe65dbfea6052/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotMetadata.java#L302-L316 for the relevant code-path.

Can you share the full-stack trace (edit the original issue) and the Pinot connector config, specially pinot.metadata-expiry?

Also, let's continue this discussion on Slack since you may find other Pinot users there who might have more info.

kokosing commented 3 years ago

Is this related to https://github.com/trinodb/trino/issues/17?

findepi commented 3 years ago

@hashhar thanks for the link ref. I wasn't aware that Pinot connector does equivalent of case-insensitive-name-matching configuration, but unconditionally.

ebyhr commented 2 years ago

Leaving this comment to clarify the current status. PinotMetadata.getPinotTableNameFromTrinoTableName() exactly finds the table case-insensitively, but PinotTableHandle lowercase it. I assume case insensitive matching for table names isn't working in this connector now. We need extra work as #7630.