We're trying to use the date extract & floor functions via the relbuilder,
but can't figure out the right syntax.

1. Trying YEAR(field)
...Relbuilder builder;
// could use SqlStdOperatorTable.EXTRACT, but then how do we pass YEAR as
an argument?
builder.call(SqlStdOperatorTable.YEAR,
    builder.field(1, 0, "my_date")
);

Cause: java.lang.RuntimeException: cannot translate call YEAR($t2)
at
org.apache.calcite.adapter.enumerable.RexToLixTranslator.translateCall(RexToLixTranslator.java:563)
at
org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate0(RexToLixTranslator.java:537)
at
org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate(RexToLixTranslator.java:223)

2. Using floor
builder.call(SqlStdOperatorTable.FLOOR,
    // -> need to specify `YEAR` here somehow as a RexNode
    builder.field(1, 0, "my_date")
);

Thanks in advance!

Reply via email to