Clickhouse中的某些精选行为期货

时间:2019-05-28 15:28:42

标签: clickhouse

我真的不明白为什么3个选择查询具有不同的行为,尽管2nd和3rd感觉相似。第二次查询有错误,第三次查询无错误

第一个查询-1个具有别名属性的联接-确定

SELECT 
    id as bet_slip_id,
    placed,
    settled,
    status,
    fk_user as user_id,
    tax_system_id,
    tax_system_name,
    fk_agent as agent_id
FROM
    stage.bet_slip
ANY LEFT JOIN (
    SELECT
        id as tax_system_id,
        name as tax_system_name
    FROM stage.tax_system
            ) ts
   ON fk_tax_system = ts.tax_system_id
WHERE
    settled < '2019-05-01 00:00:00'
    AND settled >= '2019-04-16 00:00:00'
limit $limit

第二次查询-2个具有别名属性的联接-错误

SELECT 
    id as bet_slip_id,
    placed,
    settled,
    status,
    fk_user as user_id,
    tax_system_id,
    tax_system_name,
    leg_bonus_scheme_id,
    leg_bonus_scheme_name,
    fk_agent as agent_id
FROM
    stage.bet_slip
ANY LEFT JOIN (
    SELECT
        id as tax_system_id,
        name as tax_system_name
    FROM stage.tax_system
            ) ts
   ON fk_tax_system = ts.tax_system_id
ANY LEFT JOIN (
    SELECT
        id as leg_bonus_scheme_id,
        name as leg_bonus_scheme_name
    FROM stage.leg_bonus_scheme
            ) ls
   ON fk_leg_bonus_scheme = ls.leg_bonus_scheme_id       
WHERE
    settled < '2019-05-01 00:00:00'
    AND settled >= '2019-04-16 00:00:00'
limit $limit        

第三个查询-2个具有另一个别名属性的联接-确定

SELECT 
    id as bet_slip_id,
    placed,
    settled,
    status,
    fk_user as user_id,
    fk_tax_system as tax_system_id,
    tax_system_name,
    leg_bonus_scheme_id,
    leg_bonus_scheme_name,
    fk_agent as agent_id
FROM
    stage.bet_slip
ANY LEFT JOIN (
    SELECT
        id as fk_tax_system,
        name as tax_system_name
    FROM stage.tax_system
            ) ts
   ON fk_tax_system = ts.fk_tax_system  
ANY LEFT JOIN (
    SELECT
        id as leg_bonus_scheme_id,
        name as leg_bonus_scheme_name
    FROM stage.leg_bonus_scheme
            ) ls
   ON fk_leg_bonus_scheme = ls.leg_bonus_scheme_id       
WHERE
    settled < '2019-05-01 00:00:00'
    AND settled >= '2019-04-16 00:00:00'
limit $limit

第2个查询结果错误:

  

代码:47,e.displayText()= DB :: Exception:未知标识符:   tax_system_id,上下文:查询:“ SELECT id AS bet_slip_id,已放置,   已结算,状态,fk_user AS用户名,tax_system_id,tax_system_name,   leg_bonus_scheme_id,leg_bonus_scheme_name,fk_agent AS agent_id FROM   (SELECT * FROM stage.bet_slip任何左联接(SELECT id AS   tax_system_id,名称为AS tax_system_name FROM stage.tax_system)AS ts   ON fk_tax_system = --ts.tax_system_id)任意左联接(SELECT ID AS)   leg_bonus_scheme_id,名称为AS leg_bonus_scheme_name FROM   stage.leg_bonus_scheme)AS ls ON fk_leg_bonus_scheme =   leg_bonus_scheme_id WHERE(已结算<'2019-05-01 00:00:00')并且   (已结算> ='2019-04-16 00:00:00')LIMIT 100000'required_names:   'fk_leg_bonus_scheme'fk_agent'/'agent_id'leg_bonus_scheme_id'placed'id'/'bet_slip_id'已结算'leg_bonus_scheme_name'status'tax_system_name'fk_user'/'user_id'tax_system_id'   source_tables:'ls'table_aliases:'ls'complex_aliases:   masked_columns:array_join_columns:source_columns:'id''fk_user'   '已放置''状态''已结算''fk_agent''fk_leg_bonus_scheme'   'tax_system_name'(版本19.5.3.8(正式版本))

0 个答案:

没有答案