Hi,

I am trying to modify SQL query with Calcite (add select fields and where
statements). The schema are created from JDBC connection.

Executing simple SQL statement I get exception.

SqlParseException: Encounted ".timestamp" at line 1, column 10.

Can you help me and point me what is wrong? SQL are correct and executed
from sqlplus.

My Code:

              Class.*forName*("org.apache.calcite.jdbc.Driver");

              Connection connection = DriverManager.*getConnection*(
"jdbc:calcite:");

              CalciteConnection calciteConnection =connection
.unwrap(CalciteConnection.*class*);

              calciteConnection.setSchema("latency");

              SchemaPlus rootSchema = calciteConnection.getRootSchema();

              JdbcSchema defaultSchema = JdbcSchema.*create*(rootSchema,
"latency", dataSource, *null*,*null*);

              rootSchema.add("latency", defaultSchema);



              List<*RelTraitDef*> traitDefs = *new*ArrayList<*RelTraitDef*
>();

              SchemaPlus *defaultSchema1*;

              FrameworkConfig calciteFrameworkConfig = Frameworks.
*newConfigBuilder*()

                           .parserConfig(SqlParser.*configBuilder*
().setLex(Lex.*ORACLE*).build())

                            .defaultSchema(rootSchema.getSubSchema(
calciteConnection.getSchema())).traitDefs(traitDefs)

                           .context(Contexts.*EMPTY_CONTEXT*
).ruleSets(RuleSets.*ofList*()).costFactory(*null*)

                           .typeSystem(RelDataTypeSystem.*DEFAULT*).build();

              Planner planner1 = Frameworks.*getPlanner*(
calciteFrameworkConfig);

              SqlNode sqlNode1 = planner1.parse("select i1.timestamp
timestamp from latency i1");

              SqlNode validatedSqlNode1 =planner1.validate(sqlNode1);

              RelNode *logicalPlan* =planner1.rel(validatedSqlNode1
).project();


Thanks,
--Kiril

Reply via email to