[
https://issues.apache.org/jira/browse/CALCITE-6604?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dongsheng He updated CALCITE-6604:
----------------------------------
Description:
Converting the `RelNode` with `SqlWindowTableFunction` will fail with exception:
For example the employee table:
{code:java}
Column | Type |
-----------+-------------------------------
id | integer |
salary | double precision |
hire_rate | timestamp(0) without time zone |
{code}
and the sql:
{code:java}
SELECT * FROM TABLE(TUMBLE(TABLE employee, DESCRIPTOR(hire_date), INTERVAL '1'
MINUTE)){code}
Conver it to RelNode like this:
{code:java}
LogicalProject
|
| -- inputs: <-----------
| |--- LogicalTableScan |
| |
|-- RexCall: |
| |- op: SqlWindowFunction |
| |- operands: [DESCRIPTOR(INPUT_REF(2)), INTERVAL]
|
|--- fieldList [`id`, `salary`, `hire_date`, `window_start`, `window_end`]{code}
When convert the RelNode to SqlNode, the operand( INPUT_REF(2)) of operator
`DESCRIPTOR` incorrectly refers to the RelNode (TableScan) in current
implemention, it should refer to input rows:
{code:java}
LogicalProject
|-
| -- inputs:
| |--- LogicalTableScan
|
|-- RexCall:
| |- op: SqlWindowFunction
| |- operands: [DESCRIPTOR(INPUT_REF(2)), INTERVAL]
| |
| |
| \/
|--- fieldList [`id`, `salary`, `hire_date`, `window_start`, `window_end`]
{code}
was:
Converting the `RelNode` with `SqlWindowTableFunction` will fail with exception:
For example
{code:java}
SELECT * FROM TABLE(TUMBLE(TABLE employee, DESCRIPTOR(hire_date), INTERVAL '1'
MINUTE)){code}
RelNode like this:
{color:#ce9178}LogicalProject{color}
{color:#cccccc}
{color}{color:#c586c0}|{color}{color:#569cd6}-{color}{color:#f44747} {color}
{color:#ce9178} | -- inputs: <-----------{color}
{color:#ce9178} | |--- LogicalTableScan |{color}
{color:#ce9178} | |{color}
{color:#ce9178} -- RexCall: |{color}
{color:#ce9178} | op: SqlWindowFunction |{color}
{color:#ce9178} | operands: [DESCRIPTOR(INPUT_REF(3)), INTERVAL]{color}
{code:java}
{code}
The cause of this issue is:
{code:java}
visit(TableFunctionScan e) {
...
final Context context = tableFunctionScanContext(inputSqlNodes);
...
}{code}
`tableFunctionScanContext` only refer `inputSqlNodes` to fields, when handle
`DESCRIPTOR(hire_date)`, the `hire_date` is a `RexInputRef` with index 3, but
there is only one field (`inputSqlNodes`) , it cause a
IndexOutOfBoundsException.
> Add support for SqlWindowTableFunction in RelToSql Converter
> ------------------------------------------------------------
>
> Key: CALCITE-6604
> URL: https://issues.apache.org/jira/browse/CALCITE-6604
> Project: Calcite
> Issue Type: New Feature
> Components: core
> Reporter: Dongsheng He
> Assignee: Dongsheng He
> Priority: Minor
>
> Converting the `RelNode` with `SqlWindowTableFunction` will fail with
> exception:
> For example the employee table:
>
>
>
> {code:java}
> Column | Type |
> -----------+-------------------------------
> id | integer |
> salary | double precision |
> hire_rate | timestamp(0) without time zone |
>
> {code}
> and the sql:
> {code:java}
> SELECT * FROM TABLE(TUMBLE(TABLE employee, DESCRIPTOR(hire_date), INTERVAL
> '1' MINUTE)){code}
> Conver it to RelNode like this:
> {code:java}
> LogicalProject
> |
> | -- inputs: <-----------
> | |--- LogicalTableScan |
> | |
> |-- RexCall: |
> | |- op: SqlWindowFunction |
> | |- operands: [DESCRIPTOR(INPUT_REF(2)), INTERVAL]
> |
> |--- fieldList [`id`, `salary`, `hire_date`, `window_start`,
> `window_end`]{code}
> When convert the RelNode to SqlNode, the operand( INPUT_REF(2)) of operator
> `DESCRIPTOR` incorrectly refers to the RelNode (TableScan) in current
> implemention, it should refer to input rows:
> {code:java}
> LogicalProject
> |-
> | -- inputs:
> | |--- LogicalTableScan
> |
> |-- RexCall:
> | |- op: SqlWindowFunction
> | |- operands: [DESCRIPTOR(INPUT_REF(2)), INTERVAL]
> | |
> | |
> | \/
> |--- fieldList [`id`, `salary`, `hire_date`, `window_start`, `window_end`]
> {code}
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)