diff --git a/coral-trino/src/main/java/com/linkedin/coral/trino/trino2rel/TrinoToRelConverter.java b/coral-trino/src/main/java/com/linkedin/coral/trino/trino2rel/TrinoToRelConverter.java index d306d8392..a17fb0764 100644 --- a/coral-trino/src/main/java/com/linkedin/coral/trino/trino2rel/TrinoToRelConverter.java +++ b/coral-trino/src/main/java/com/linkedin/coral/trino/trino2rel/TrinoToRelConverter.java @@ -83,7 +83,7 @@ protected SqlToRelConverter getSqlToRelConverter() { @Override protected SqlNode toSqlNode(String sql, Table trinoView) { - String trimmedSql = trimParenthesis(sql.toUpperCase()); + String trimmedSql = standardizeSql(sql); SqlNode parsedSqlNode = PrestoParserDriver.parse(trimmedSql).accept(parseTreeBuilder, parserVisitorContext); SqlNode convertedSqlNode = parsedSqlNode.accept(new Trino2CoralOperatorConverter()); return convertedSqlNode; @@ -94,12 +94,15 @@ protected RelNode standardizeRel(RelNode relNode) { return relNode; } - private static String trimParenthesis(String value) { + /* + * Standardizing Sql to ensure compatability with Sql Parser. + */ + private static String standardizeSql(String value) { String str = value.trim(); if (str.startsWith("(") && str.endsWith(")")) { - return trimParenthesis(str.substring(1, str.length() - 1)); + return standardizeSql(str.substring(1, str.length() - 1)); } - return str; + return str.toUpperCase().replaceAll("`", "\""); } }