You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2017/01/03 17:47:58 UTC

[jira] [Comment Edited] (CALCITE-1515) Support TableFunctionScan in RelBuilder

    [ https://issues.apache.org/jira/browse/CALCITE-1515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15723305#comment-15723305 ] 

Julian Hyde edited comment on CALCITE-1515 at 1/3/17 5:47 PM:
--------------------------------------------------------------

[~anmu], It would be great if you fixed this.

I note that we don't use {{Table}} in the {{RelBuilder}} API so we shouldn't use {{TableFunction}} either. The {{scan}} function has the overloads {{scan(String...)}} and {{scan(Iterable<String>)}} (basically, looking up a table in a catalog based on its fully-qualified name), and so {{functionScan}} should do something similar. I think the signature should be

{code}
RelBuilder functionScan(
    Iterable<String> tableFunctionNames,
    Iterable<? extends RexNode> operands);

RexNode cursor(int ordinal);
{code}

The operands will be a mixture of scalar values (mainly literals) and references to input relations. Since an input relation is not a RexNode, the caller should use the new {{cursor}} method, which references a particular relational input (already on the RelBuilder's stack). To illustrate, we will need a complicated contrived example:

{code}
// Here's the SQL
SELECT *
FROM TABLE("mySchema"."myFunction"(
  'abc',
  (SELECT * FROM "emp"),
 123,
  (SELECT * FROM "dept")));

// And here's the equivalent RelBuilder code
RelBuilder builder;
builder.scan("EMP")
  .scan("DEPT")
  .functionScan(Arrays.asList("mySchema", "myFunction"),
      builder.literal("abc"),
      builder.cursor(0),
      builder.literal(123),
      builder.cursor(1));
{code}

The {{cursor}} function will create a {{RexCall}} to the {{SqlStdOperatorTable.CURSOR}} function.


was (Author: julianhyde):
[~anmu], It would be great if you fixed this.

I note that we don't use {{Table}} in the {{RelBuilder}} API so we shouldn't use {{TableFunction}} either. The {{scan}} function has the overloads {{scan(String...)}} and {{scan(Iterable<String>)}} (basically, looking up a table in a catalog based on its fully-qualified name), and so {{functionScan}} should do something similar. I think the signature should be

{code}
RelBuilder functionScan(
    Iterable<String> tableFunctionNames,
    Iterable<? extends RexNode> operands);

RexNode cursor(int ordinal);
{code}

The operands will be a mixture of scalar values (mainly literals) and references to input relations. Since an input relation is not a RexNode, the caller should use the new {{cursor}} method, which references a particular relational input (already on the RelBuilder's stack). To illustrate, we will need a complicated contrived example:

{code}
// Here's the SQL
SELECT *
FROM TABLE("mySchema"."myFunction"(
  'abc',
  (SELECT * FROM "emp"),
 123,
  (SELECT * FROM "dept")));

// And here's the equivalent RelBuilder code
RelBuilder builder;
builder.scan("EMP")
  .scan("DEPT")
  .functionScan(Arrays.asList("mySchema"."myFunction"),
      builder.literal("abc"),
      builder.cursor(0),
      builder.literal(123),
      builder.cursor(1));
{code}

The {{cursor}} function will create a {{RexCall}} to the {{SqlStdOperatorTable.CURSOR}} function.

> Support TableFunctionScan in RelBuilder
> ---------------------------------------
>
>                 Key: CALCITE-1515
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1515
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.10.0
>            Reporter: Anton Mushin
>            Assignee: Julian Hyde
>            Priority: Minor
>
> Calcite has a TableFunctionScan, which is a RelNode, takes a function, 0 or more RelNode inputs, and 0 or more other arguments.
> RelBuilder does not support TableFunctionScan yet. 
> add In RelBuilder TableFunctionScanFactory which will create LogicalTableFunctionScan like as for LogicalTableScan and factory for others RelNodes [ [example|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/tools/RelBuilder.java#L125] ]
> also adding a functionScan method, analogous to the scan method but for table functions.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)