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.46k stars 3.01k forks source link

Sql keyword not quoted during serialization of query plan. #13293

Open Felicity-3786 opened 2 years ago

Felicity-3786 commented 2 years ago

When a field has the name of Sql reserved keyword, trino fails to quote the word which results in JsonMappingException. For example, the sample query with the word "end" will fail:

CREATE TABLE base_table_test (a bigint, b row(c0 bigint, "end" bigint), c bigint);
INSERT INTO base_table_test values (5, row(6, 7), 8);

From the trace: Caused by: com.fasterxml.jackson.databind.JsonMappingException: line 1:34: mismatched input 'end'. Expecting: <identifier>, <type> (through reference chain: io.trino.server.TaskUpdateRequest["fragment"]->io.trino.sql.planner.PlanFragment["root"]->io.trino.sql.planner.plan.ProjectNode["assignments"]->io.trino.sql.planner.plan.Assignments["assignments"]->java.util.LinkedHashMap["b"])

phd3 commented 2 years ago

Looks like the DataType serialization for RowDataType is missing quoting during serialization.

@Felicity-3786 would you like to pick this up to fix it?

Felicity-3786 commented 2 years ago

Sure, will open a PR. Thanks!