calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Renato MarroquĂ­n Mogrovejo <renatoj.marroq...@gmail.com>
Subject Fwd: Parsing SQL
Date Sun, 22 Feb 2015 23:42:22 GMT
Hi there,

I have an application that reads data from HDFS using Spark but I need to
add specific relation filters programatically. I could do this by parsing
the SQL string but I thought that Apache Calcite could help on this. I
tried using this:

<code>
    private static SqlParser getSqlParser(String sql) {
        Quoting quoting = Quoting.DOUBLE_QUOTE;
        Casing unquotedCasing = Casing.TO_UPPER;
        Casing quotedCasing = Casing.UNCHANGED;
        return SqlParser.create(
                sql,
                SqlParser.configBuilder().setQuoting(quoting)
                        .setUnquotedCasing(unquotedCasing)
                        .setQuotedCasing(quotedCasing).build());

    }
</code>

with a query like "select *\n from \"foodmart\".\"sales_fact_1997\" as s\n
join \"hr\".\"emps\" as e\n on e.\"empid\" = s.\"cust_id\"" (borrowed from
Calcite tests), but I get:

org.apache.calcite.sql.parser.SqlParseException: Encountered "select" at
line 1, column 1.
Was expecting one of:
    "+" ...

Any help is highly appreciated! Thanks!


Renato M.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message