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

trino table column is case Insensetive for elasticsearch connector #7276

Closed
waitingF opened this issue Mar 12, 2021 · 2 comments
Closed

trino table column is case Insensetive for elasticsearch connector #7276

waitingF opened this issue Mar 12, 2021 · 2 comments

Comments

@waitingF
Copy link

While using trino to perform sql base on Elasticsearch cluster, I found presto is NOT case sensetive for columns. For Example, I have an Index in elasticsearch with mapping like(with fields[age, Age, name, Name]):

{
  "myindex" : {
    "mappings" : {
      "properties" : {
        "Age" : {
          "type" : "long"
        },
        "Name" : {
          "type" : "keyword"
        },
        "age" : {
          "type" : "long"
        },
        "name" : {
          "type" : "keyword"
        }
      }
    }
  }
}

When use "DESC myindex" in trino-cli, it shows nothing:
image

Then, I dive into elasticsearch connector plugin, I found the following code which cause "DESC myindex" shows no rows.
image

Then, I remove the toLowCase function with the thought trino might show the correct columns:
image

But I was wrong. This time, trino show below. All column are lower case:
image
And, I could not select any data from elasticsearch.
image
below is the Exeption stack:
image

In my case, I need trino to treat columns like age & Age. Could anyone tell me how to make trino case sensetive? THANKS~

@hashhar
Copy link
Member

hashhar commented Mar 14, 2021

Requires #17 to fix correctly. The optimizer normalizes every input to lowercase today. We do support case-insensitive name matching as long as there are no collisions - which is not true in your case.

You can try once using the query passthrough feature of the ElasticSearch connector (but I don't think it would work since the query is embedded in the table name which itself would be lowercased). See https://trino.io/docs/current/connector/elasticsearch.html#pass-through-queries.

@findepi
Copy link
Member

findepi commented Mar 14, 2021

You can try once using the query passthrough feature of the ElasticSearch connector (but I don't think it would work since the query is embedded in the table name which itself would be lowercased). See https://trino.io/docs/current/connector/elasticsearch.html#pass-through-queries.

Note that (from the docs):

The Elasticsearch query string es-query is base32-encoded to avoid having to deal with escaping quotes and case sensitivity issues in table identifiers.

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

3 participants