You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Jing Zhang (Jira)" <ji...@apache.org> on 2022/01/03 00:52:00 UTC

[jira] [Commented] (FLINK-25499) Column 'window_start' is ambiguous

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

Jing Zhang commented on FLINK-25499:
------------------------------------

[~zhitom], Thanks for reporting the bug.
This is not a bug, I think.
The return value of [Window TVF|https://nightlies.apache.org/flink/flink-docs-release-1.14/docs/dev/table/sql/queries/window-tvf/] is a new relation that includes all columns of original relation as well as additional 3 columns named “window_start”, “window_end”, “window_time” to indicate the assigned window. You could find more information in [Doc[1]|https://nightlies.apache.org/flink/flink-docs-release-1.14/docs/dev/table/sql/queries/window-tvf/).

When you use cascade window tvf, there would be two window_start, which caused the exception with error message "Column 'window_start' is ambiguous".


> Column 'window_start' is ambiguous
> ----------------------------------
>
>                 Key: FLINK-25499
>                 URL: https://issues.apache.org/jira/browse/FLINK-25499
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / API
>    Affects Versions: 1.14.2
>         Environment: Flink 1.14.0
>            Reporter: Shandy
>            Priority: Major
>              Labels: ambiguous, window_start
>
> *For docs: [Window Aggregation|https://nightlies.apache.org/flink/flink-docs-release-1.14/docs/dev/table/sql/queries/window-agg/#cascading-window-aggregation]*
> *use sql-client create view such as:*
> =================================================
> CREATE TEMPORARY VIEW IF NOT EXISTS telemetry_r_yangchen_standard_t
> AS
> (
>     SELECT a.window_start,a.window_end,a.window_time as rowTime,last_value(a.tenantId) as tenantId      
>     FROM TABLE(TUMBLE(TABLE telemetry_r_yangchen_normal, DESCRIPTOR(receiveTimeTS), INTERVAL '10' MINUTES)) as a
>     group by a.window_start, a.window_end,a.window_time
> );
> SELECT b.window_start, b.window_end,b.window_time as rowTime,sum(b.tenantId) as tenantId
>     FROM TABLE(TUMBLE(TABLE telemetry_r_yangchen_standard_t, DESCRIPTOR(rowTime), INTERVAL '60' MINUTES)) as b
>     group by b.window_start, b.window_end,b.window_time;
> =================================================
> *above select occurs error message:*
> {color:#ff0000}*[ERROR] Could not execute SQL statement. Reason:
> org.apache.calcite.sql.validate.SqlValidatorException: Column 'window_start' is ambiguous
> *{color}
> *if modify create sql like this :*
> ============================================
> CREATE TEMPORARY VIEW IF NOT EXISTS telemetry_r_yangchen_standard_t
> AS
> (
>     SELECT {color:#de350b}-a.windw_start,-{color}a.window_end,a.window_time as rowTime,last_value(a.tenantId) as tenantId      
>     FROM TABLE(TUMBLE(TABLE telemetry_r_yangchen_normal, DESCRIPTOR(receiveTimeTS), INTERVAL '10' MINUTES)) as a
>     group by a.window_start, a.window_end,a.window_time
> );
> *or*
> CREATE TEMPORARY VIEW IF NOT EXISTS telemetry_r_yangchen_standard_t
> AS
> (
>     SELECT {color:#de350b}cast(a.window_start as timestamp) as windowStart,cast(a.window_end as timestamp) as windowEnd,{color}a.window_time as rowTime,last_value(a.tenantId) as tenantId      
>     FROM TABLE(TUMBLE(TABLE telemetry_r_yangchen_normal, DESCRIPTOR(receiveTimeTS), INTERVAL '10' MINUTES)) as a
>     group by a.window_start, a.window_end,a.window_time
> );
> ============================================
> *then, above select-sql can be executed ok!*



--
This message was sent by Atlassian Jira
(v8.20.1#820001)