You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "slim bouguerra (JIRA)" <ji...@apache.org> on 2017/05/02 17:56:04 UTC
[jira] [Commented] (CALCITE-1772) Add a hook to allow RelNode
expressions to be executed by JDBC driver
[ https://issues.apache.org/jira/browse/CALCITE-1772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15993400#comment-15993400 ]
slim bouguerra commented on CALCITE-1772:
-----------------------------------------
[~julianhyde] i am not sure if i getting this right please help me,
So i am trying to run this dummy test below
{code}
@Test public void testPushNumericCastOverLiteral() {
sql("?")
.withRel(new Function<RelBuilder, RelNode>() {
public RelNode apply(RelBuilder b) {
// select count(*) as c
// from foodmart.foodmart
// where product_id = 'id'
return b.scan("foodmart", "foodmart")
.filter(b.call(SqlStdOperatorTable.EQUALS, b.field("product_id"), b.literal("id")))
.aggregate(b.groupKey(), b.countStar("c"))
.build();
}
})
.queryContains(druidChecker("'queryType':'timeseries'"));
}
{code}
The issue when i run this none of the druid rules is triggered and the execution ends up with a select * from druid_backed_table then do the rest by calcite. I am not sure why the re-writing of the query to timeserises is not happening.
Am i missing something ?
> Add a hook to allow RelNode expressions to be executed by JDBC driver
> ---------------------------------------------------------------------
>
> Key: CALCITE-1772
> URL: https://issues.apache.org/jira/browse/CALCITE-1772
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Assignee: Julian Hyde
> Fix For: 1.13.0
>
>
> Add a hook to allow RelNode expressions to be executed by JDBC driver in the same way that SQL would.
> If you set Hook.STRING_TO_QUERY you can provide a function that creates a [CalcitePrepare.Query|https://calcite.apache.org/apidocs/org/apache/calcite/jdbc/CalcitePrepare.Query.html] object; this can wrap a String (SQL query), RelNode tree or Queryable.
> In tests, you can call convenience method {{AssertQuery.withRel}}, whose implementation sets the hook. For example,
> {code}
> sql("?")
> .withRel(new Function<RelBuilder, RelNode>() {
> public RelNode apply(RelBuilder b) {
> // select count(*) as c
> // from foodmart.foodmart
> // where product_id < cast(10 as varchar)
> return b.scan("foodmart", "foodmart")
> .filter(
> b.call(SqlStdOperatorTable.LESS_THAN,
> b.field("product_id"),
> b.getRexBuilder().makeCall(
> b.getTypeFactory().createSqlType(SqlTypeName.INTEGER),
> SqlStdOperatorTable.CAST,
> ImmutableList.<RexNode>of(b.literal("10")))))
> .aggregate(b.groupKey(), b.countStar("c"))
> .build();
> }
> })
> .returns("c=45");
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)