You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by CPC <ac...@gmail.com> on 2016/03/16 21:15:30 UTC
RelBuilder examples with a schema
Hello everyone,
I have developed a small timeseries db on rocksdb and wrote parser that can
parse influxdb query language. Next step for me is to translate ast to
RelNode via RelNodeBuilder. But i could not find any example to run given
RelNode against a schema with a FrameworkConfig and even i dont know
whether i use "Frameworks.newConfigBuilder" correctly. Is there any
examples inside calcite or in other frameworks that use calcite in this
way? Thank you in advance.
Thanks,
Anıl
Re: RelBuilder examples with a schema
Posted by CPC <ac...@gmail.com>.
Hi,
After searching code and debugging i found a way to use RelBuilder(snippets
are scala by the way)
> Frameworks.newConfigBuilder.parserConfig(SqlParser.Config.DEFAULT)
> .defaultSchema(heimdallSchema)
>
> .traitDefs(null).programs(Programs.heuristicJoinOrder(Programs.RULE_SET,
> true, 2)).build()
> val node=RelBuilder.create(config)
> .scan("TEST")
> .build()
>From org.apache.calcite.test.RelBuilderTest.testRun method i found that one
way to run RelNode is RelRunners.run method. But when i execute it and then
executeQuery method it throws NullPointerException from above line:
(dump via -Dcalcite.debug=true)
/* 1 */ org.apache.calcite.DataContext root;
/* 2 */
/* 3 */ public org.apache.calcite.linq4j.Enumerable bind(final
org.apache.calcite.DataContext root0) {
/* 4 */ root = root0;
/* 5 */ return ((com.globalmaksimum.heimdall.ts.calcite.HeimdallTable)
root.getRootSchema().getSubSchema("TEST").getTable("TEST")).project();
/* 6 */ }
/* 7 */
because it couldnt find my schema. getSubSchema method returns null. But
when i do it in this way
> val calciteConnection = DriverManager.getConnection("jdbc:calcite:",
> properties).unwrap(classOf[CalciteConnection])
> calciteConnection.getRootSchema.add("TEST",heimdallSchema)
> val relRunner=connection.unwrap(classOf[RelRunner])
> val resultSet = relRunner.prepare(node).executeQuery()
it finds my schema and execute RelNode. But in
org.apache.calcite.test.RelBuilderTest.testRun method it can run RelNode
via RelRunners. Am i doing something wrong?
Second question, when i build my relnode via Relbuilder,is calcite
optimizing it via given program that i gave to FrameworkConfig or should i
do something else as an extra step?
Thanks,
Anıl
On 16 March 2016 at 22:15, CPC <ac...@gmail.com> wrote:
> Hello everyone,
>
> I have developed a small timeseries db on rocksdb and wrote parser that
> can parse influxdb query language. Next step for me is to translate ast to
> RelNode via RelNodeBuilder. But i could not find any example to run given
> RelNode against a schema with a FrameworkConfig and even i dont know
> whether i use "Frameworks.newConfigBuilder" correctly. Is there any
> examples inside calcite or in other frameworks that use calcite in this
> way? Thank you in advance.
>
> Thanks,
> Anıl
>