apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.82k stars 3.3k forks source link

[Bug] Syntax checking is not rigorous. 语法检查不严谨 #41490

Open xqg1316 opened 2 months ago

xqg1316 commented 2 months ago

Search before asking

Version

Doris-2.1.3

What's Wrong?

有一段SQL语句如下: -- 投资项目评审批复详情 ALTER TABLE dwd.dwd_inv_proj_resc_dtl_d DROP PARTITION IF EXISTS p20240928; ALTER TABLE dwd.dwd_inv_proj_resc_dtl_d ADD PARTITION IF NOT EXISTS p20240928 VALUES IN ('2024-09-28');

INSERT INTO dwd.dwd_inv_proj_resc_dtl_d PARTITION (p20240928) SELECT NULL AS proj_md_code ,t1.inv_pro_id AS proj_code ,t1.reply_category AS resc_type ,round(t1.jaf, 2) AS const_install_fee ,round(t1.zcf, 2) AS relocation_fee ,round(t1.glf, 2) AS manage_fee ,round(t1.jlf, 2) AS supervision_fee ,round(t1.kcsjf, 2) AS survey_design_fee ,round(t1.oth, 2) AS other ,round((t1.jaf + t1.zcf + t1.glf + t1.jlf + t1.kcsjf + t1.oth), 2) AS resc_tot_amt ,t1.reply_date AS resc_date ,t1.pg_pf AS eva_resc ,t1.bz AS remark ,current_timestamp() AS etl_time ,'' AS source_system ,'ods_cfhec_pro_inv_basic_pfinfo_f_d' AS source_table ,'2024-09-28' AS etl_part FROM ods.ods_cfhec_pro_inv_basic_pfinfo_f_d PARTITION (p20240928) ;


执行方式1:

整体选中执行(上面的SQL语句), 当FROM 的表名, 没有别名, 居然可以执行通过, 如

  1. ALTER TABLE DROP PARTITION
  2. ALTER TABLE ADD PARTITION
  3. INSERT INTO SELECT FROM -- 注: 当FROM 的表名, 没有别名, 居然可以执行通过

执行方式2:

当单独执行 INSERT INTO SELECT FROM 时, 才能正常检测出语法错误

INSERT INTO dwd.dwd_inv_proj_resc_dtl_d PARTITION (p20240928) SELECT NULL AS proj_md_code ,t1.inv_pro_id AS proj_code ,t1.reply_category AS resc_type ,round(t1.jaf, 2) AS const_install_fee ,round(t1.zcf, 2) AS relocation_fee ,round(t1.glf, 2) AS manage_fee ,round(t1.jlf, 2) AS supervision_fee ,round(t1.kcsjf, 2) AS survey_design_fee ,round(t1.oth, 2) AS other ,round((t1.jaf + t1.zcf + t1.glf + t1.jlf + t1.kcsjf + t1.oth), 2) AS resc_tot_amt ,t1.reply_date AS resc_date ,t1.pg_pf AS eva_resc ,t1.bz AS remark ,current_timestamp() AS etl_time ,'' AS source_system ,'ods_cfhec_pro_inv_basic_pfinfo_f_d' AS source_table ,'2024-09-28' AS etl_part FROM ods.ods_cfhec_pro_inv_basic_pfinfo_f_d PARTITION (p20240928) ;

8c8f31053da2976f75eb4daa16a8bb8 d6c839287cedf09f8fefa2aba8694e4 37b5cdc088500fb866e0d8daf0ee50f

What You Expected?

严重bug

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

Code of Conduct

ihadoop commented 1 month ago

mark

xqg1316 commented 1 month ago

在黑窗界面, 可以正常检测到问题

ee891ee39aa7e2e7a50e948766bd532