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
10.54k stars 3.03k forks source link

Query responses contain rows with field/column names that are changed to lower case and no longer match the original. #24356

Open PredatorVI opened 16 hours ago

PredatorVI commented 16 hours ago

We are currently using Trino version v445 in Google Kubernetes Engine to query a large set of JSON documents. One of the many fields in the original source are named using camel case such as:

"riskGroups": {
  "0": 0,
  "30": 2
}

and can be queried using the original camel case name just fine such as SELECT doc.riskGroups FROM ...

However if I do SELECT doc FROM .... the resulting value for this field looks like:

"riskgroups": {
  "0": 0,
  "30": 2
}

I'm specifically calling CAST(doc AS JSON) in order to convert the resulting JSON string to a Java POJO and the Jackson ObjectMapper() call subsequently fails because the field/property name does not match. Is there a way to tell Trino to maintain the case of the original? It seems like an issue if the query result is changing the original data as a side effect.

(Edited to reflect that the case conversion isn't specific to the CAST() call I was using.)

PredatorVI commented 15 hours ago

Upon further investigation, it isn't related to CAST(). If I simply call SELECT doc FROM ... , the riskgroup name is also returned as all lowercase in the resulting string:

riskgroups = {
    0 = 0,
    30 = 2
}
ebyhr commented 3 hours ago

What connector are you using? How did you create the table? Please share the entire steps to reproduce.