osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Avoid SqlParser.toSqlString() adding double quotes to select identifiers


I am trying to modify a SQL statement using SQL Parser and implementing
SQLVisitor interface to modify select column variables.
However after modification when I am trying to convert back to sql
statement, I am getting double quotes in identifiers which is causing sql
to break on Elastic Search.

My input query is as follows:
    SELECT user FROM logs;

I want to change it to
    SELECT _MAP['user'] as "user" FROM "logs";

toSqlString(SqlDialect.DatabaseProduct.CALCITE.getDialect()) is returning

  SELECT "_MAP['user']" AS "user" FROM "logs"


How should I do this? Thank you in advance for any suggestions.

-- 
Regards
Shashwat Kumar