Calcite’s SQL parser is case-sensitive but converts unquoted identifiers to 
upper-case. To get the result you want you should enclose table and column 
names in double-quotes:

  SELECT * FROM “Students" WHERE “age" > 15.0

(There are also connect-string options such as Lex=JAVA [1].)

To see the plan use the EXPLAIN command:

  # Logical plan
  EXPLAIN PLAN FOR SELECT * FROM “Students”;

  # In XML format
  EXPLAIN PLAN AS XML FOR SELECT * FROM “Students”;

  # Physical plan
  EXPLAIN PLAN WITH IMPLEMENTATION FOR SELECT * FROM “Students”;

Julian

[1] https://calcite.apache.org/apidocs/org/apache/calcite/config/Lex.html 
<https://calcite.apache.org/apidocs/org/apache/calcite/config/Lex.html>


> On Jan 19, 2016, at 7:40 PM, David Holland <[email protected]> wrote:
> 
> Calcite developers,
> 
> I am a university researcher trying to use Calcite to develop a distributed 
> query capability. I have read the Calcite tutorial and some example code, but 
> am still unclear on how to create a calcite SQL parser, parse a simple SQL 
> statement and examine its associated relational expression (tree).
> 
> I start by building a JSON object that represents operands  consumed by a 
> JdbcSchema.Factory(), which  builds a JdbcSchema supplied by a SQLite 
> database. Once I have the schema, I assign it to the Calcite framework using 
> the FrameworkConfig builder, then configure the SQL parser to ignore case in 
> a  query (case insensitive). I verify the schema has been build and print out 
> its tables successfully, e.g. "Students", "Grades". I then obtain the PLANNER 
> and parser the following statement:
> 
>  "SELECT * FROM Students WHERE age > 15.0" 
> 
> Next, when I attempt to VALIDATE the syntax correctness of the statement, an 
> error reports:
> 
> org.apache.calcite.sql.validate.SqlValidatorException: Table 'STUDENTS' not 
> found
> 
> The framework appears to convert schema table names to UPPERCASE, even though 
> I try to configure the SQL parser to be case insensitive. It therefore fails 
> to find the "Students" table imported from the SQLite database and reports 
> the error.
> 
> Finally, If and when I get the SQL parser working, I want to examine the 
> relational tree produced by the Calcite planner, and perhaps display it 
> graphically? Later I intend to add rules to the planner that support 
> distributing a query across multiple nodes.
> 
> I see value in the Calcite project and would like to learn more to 
> contribute. My simple Eclipse program ParseSql.java is attached along with 
> the trivial SQLite database used to experiment with the parser. Your 
> suggestion and guidance is very much appreciated. 
> 
> Is there a developer chat room?
> 
> Regards
> David Holland
> 
> 
> -- 
> David Holland
> 512-300-8396 <tel:512-300-8396><ParseSQL.java>

Reply via email to