incubator-doris [BUG] [materialized view] If the sql can hit the materialized view, then the FE will throw Exception: errCode = 2, detailMessage = Unknown column 'mv_count_columnname' ....

oymdgrw7  于 2022-04-22  发布在  Java
关注(0)|答案(3)|浏览(633)

Describe the bug

If the sql can hit the materialized view, the query will be failed and in the fe.warn.log has Exception that 'Unknown column'
(sql查询一旦命中物化视图, FE就会报出Unknown column的异常而查询失败.)

To Reproduce

  1. create db and table: t_event. its columns were: event_time_dayinweek / event_define_id / event_id / ... and so on.
  2. create materialized view
create materialized view mv_dayinweek_count as 
select 
  a.`event_time_dayinweek`, 
  a.`event_define_id`, 
  count(event_id)
from t_event a 
group by a.`event_time_dayinweek`, a.`event_define_id`;
  1. my query sql is:
select 
  a.`event_time_dayinweek`, 
  event_define_id, 
  count(event_id)
from t_event a 
group by a.`event_time_dayinweek`,a.`event_define_id` 
order by a.event_time_dayinweek, count(event_id);
  1. the query will be failed and in the fe.warn.log has Exception:
[StmtExecutor.analyze():507] Analyze failed because
java.lang.IllegalStateException: org.apache.doris.common.AnalysisException: errCode = 2, detailMessage = Unknown column 'mv_count_event_id' in 'default_cluster:smg_user_new_65.t_event'
	at org.apache.doris.analysis.Expr.analyzeNoThrow(Expr.java:535) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.rewrite.mvrewrite.CountFieldToSum.rewriteExpr(CountFieldToSum.java:95) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.rewrite.mvrewrite.CountFieldToSum.apply(CountFieldToSum.java:83) ~[palo-fe.jar:3.4.0]

Doris Server Information

  • Version: Baidu Doris(Palo) version 0.13.15-4e19c23
hc2pp10m

hc2pp10m1#

the full exception stack:

2021-01-25 16:31:15,607 WARN (doris-mysql-nio-pool-13|188) [StmtExecutor.analyze():507] Analyze failed because
java.lang.IllegalStateException: org.apache.doris.common.AnalysisException: errCode = 2, detailMessage = Unknown column 'mv_count_event_id' in 'default_cluster:smg_user_new_65.t_event'
	at org.apache.doris.analysis.Expr.analyzeNoThrow(Expr.java:535) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.rewrite.mvrewrite.CountFieldToSum.rewriteExpr(CountFieldToSum.java:95) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.rewrite.mvrewrite.CountFieldToSum.apply(CountFieldToSum.java:83) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.rewrite.ExprRewriter.applyRuleBottomUp(ExprRewriter.java:110) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.rewrite.ExprRewriter.applyRuleRepeatedly(ExprRewriter.java:96) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.rewrite.ExprRewriter.rewrite(ExprRewriter.java:61) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.analysis.QueryStmt.rewriteQueryExprByMvColumnExpr(QueryStmt.java:255) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.analysis.SelectStmt.analyze(SelectStmt.java:392) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.StmtExecutor.analyzeAndGenerateQueryPlan(StmtExecutor.java:525) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.StmtExecutor.analyze(StmtExecutor.java:495) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:274) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:245) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:202) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.ConnectProcessor.dispatch(ConnectProcessor.java:334) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.ConnectProcessor.processOnce(ConnectProcessor.java:536) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.mysql.nio.ReadListener.lambda$handleEvent$0(ReadListener.java:50) ~[palo-fe.jar:3.4.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_251]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_251]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_251]
Caused by: org.apache.doris.common.AnalysisException: errCode = 2, detailMessage = Unknown column 'mv_count_event_id' in 'default_cluster:smg_user_new_65.t_event'
	at org.apache.doris.common.ErrorReport.reportAnalysisException(ErrorReport.java:52) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.common.ErrorReport.reportAnalysisException(ErrorReport.java:47) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.analysis.Analyzer.registerColumnRef(Analyzer.java:598) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.analysis.SlotRef.analyzeImpl(SlotRef.java:139) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.analysis.Expr.analyze(Expr.java:380) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.analysis.Expr.analyze(Expr.java:374) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.analysis.Expr.analyzeNoThrow(Expr.java:533) ~[palo-fe.jar:3.4.0]
	... 18 more
2021-01-25 16:31:15,608 WARN (doris-mysql-nio-pool-13|188) [StmtExecutor.execute():360] execute Exception. {}
org.apache.doris.common.AnalysisException: errCode = 2, detailMessage = Unexpected exception: org.apache.doris.common.AnalysisException: errCode = 2, detailMessage = Unknown column 'mv_count_event_id' in 'default_cluster:smg_user_new_65.t_event'
	at org.apache.doris.qe.StmtExecutor.analyze(StmtExecutor.java:508) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:274) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:245) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:202) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.ConnectProcessor.dispatch(ConnectProcessor.java:334) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.qe.ConnectProcessor.processOnce(ConnectProcessor.java:536) ~[palo-fe.jar:3.4.0]
	at org.apache.doris.mysql.nio.ReadListener.lambda$handleEvent$0(ReadListener.java:50) ~[palo-fe.jar:3.4.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_251]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_251]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_251]
relj7zay

relj7zay2#

This bug may be caused by table alias, the following sql is OK:

select 
  `event_time_dayinweek`, 
  event_define_id, 
  count(event_id)
from t_event
group by `event_time_dayinweek`,`event_define_id` 
order by event_time_dayinweek, count(event_id);

We will look deep into it.

5q4ezhmt

5q4ezhmt3#

This bug may be caused by table alias, the following sql is OK:

select 
  `event_time_dayinweek`, 
  event_define_id, 
  count(event_id)
from t_event
group by `event_time_dayinweek`,`event_define_id` 
order by event_time_dayinweek, count(event_id);

We will look deep into it.

yeah, after remove the alias, it work. thanks :-)

相关问题