关联子查询,主表不用别名则查询错误

【详述】关联子查询,主表不用别名则查询错误
【背景】

  1. 不起别名的sql,关联查询的结果是错误的。
    select
    #app_id
    ,(
    select
    max(#app_id@app_name)
    from
    ods_dim_event_0preset_app_id td
    where
    #app_id = td.#app_id
    ) as #app_id@app_name
    from ods_fact_event_track
    where 1=1
    and #event in (’#login’)
    and #days BETWEEN ‘2022-11-03’ and ‘2022-11-03’
    and #app_id = ‘264’
    ;
    结果截图如下:这里的关联结果是错误的。
    image

  2. 带别名的sql, 关联查询的结果是正确的
    select
    #app_id
    ,(
    select
    max(#app_id@app_name)
    from
    ods_dim_event_0preset_app_id td
    where
    t.#app_id = td.#app_id
    ) as #app_id@app_name
    from ods_fact_event_track t
    where 1=1
    and #event in (’#login’)
    and #days BETWEEN ‘2022-11-03’ and ‘2022-11-03’
    and #app_id = ‘264’
    ;
    结果截图如下:这里的关联结果是正确的。
    image

想问一下,如果不带别名的,是sr解析有问题吗?还是必须得加别名?

【业务影响】
【StarRocks版本】2.4.0
【集群规模】3fe + 5be

是不是两个表都有相同的字段名?

只有关联字段相同。 t. #app_id = td. #app_id,其他就没有相同字段了

字段名相同 原理上是需要表要有别名的

不起别名的话,先执行子查询,子查询的max为 ‘[看到速回]打开符合’ ,然后执行外查询,然后结果就是错误的。应该是这样的逻辑。