Skip to content

Issue with window function in CTE + alias clash #47422

Closed

Description

@filimonov
DROP TEMPORARY TABLE IF EXISTS test;
CREATE TEMPORARY TABLE test (a Float32, id UInt64);
INSERT INTO test VALUES (10,10),(20,20);

SELECT 'query1';
-- alias clash (a is redefined in CTE)
-- 21.8: no error, bad result
-- 21.9 and newer: error "Block structure mismatch in (columns with identical name must have identical structure) stream"

WITH avg(a) OVER () AS a SELECT a, id FROM test SETTINGS allow_experimental_window_functions = 1;

SELECT 'query2';
-- no aliases clash, good result
WITH avg(a) OVER () AS a2 SELECT a2, id FROM test SETTINGS allow_experimental_window_functions = 1;

SELECT 'query3';
-- aliases clash without CTE
SELECT avg(a) OVER () AS a, id FROM test SETTINGS allow_experimental_window_functions = 1;

Activity

  1. added
    unexpected behaviour
    on Mar 10, 2023
  2. self-assigned this
    on Mar 10, 2023
  3. kitaisreal commented on Mar 10, 2023

    @kitaisreal
    Contributor

    Related to #42648. Works in new analyzer.

  4. added a commit that references this issue on Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    unexpected behaviour

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions