【已解决】create view as select 里面包含 count(distinct xxx)执行失败,异常信息不明确,版本2.0.3

Viewed 61

1.执行失败的语句,count时没问题,加上distinct执行异常,异常信息:execute error=errCode = 2, detailMessage = Unexpected exception: null

CREATE VIEW index_products_cnt_hotel_yesterday_values ( data_day COMMENT 'data_day', resort COMMENT 'resort', index_num COMMENT 'index_num', index_name COMMENT 'index_name', index_code COMMENT 'index_code', snapshot_day COMMENT 'snapshot_day' ) AS SELECT
data_day AS data_day,resort AS resort,
round( COUNT( DISTINCT productsn ), 2 ) AS index_num,'商城有交易产品数_copy' AS index_name,
CAST(
'SZ042' AS VARCHAR ( 4000 )) AS index_code,'1970-01-01' AS snapshot_day
FROM
kunlun_doris.ds_mt_order_product
WHERE
123456 <> 123456
GROUP BY
data_day,
resort,
'商城有交易产品数_copy',
CAST(
'SZ042' AS VARCHAR ( 4000 )),
'1970-01-01'

2.下面为关联的表和视图信息:
CREATE TABLE ds_mt_order_product (
data_day varchar(10) NULL,
tenant_id varchar(50) NULL,
data_year varchar(4) NULL,
data_year_month varchar(7) NULL,
saleorgid varchar(20) NULL,
saleorgname varchar(255) NULL,
resort varchar(255) NULL,
resort_sdp varchar(255) NULL,
hotelname varchar(255) NULL,
hotel_abbr varchar(255) NULL,
management varchar(255) NULL,
region varchar(255) NULL,
brand varchar(255) NULL,
productsn varchar(255) NULL,
productname varchar(255) NULL,
selectedstatus varchar(255) NULL,
status varchar(255) NULL,
refundstatus varchar(255) NULL,
refundflag varchar(255) NULL,
number bigint(20) NULL,
payprice DECIMAL(38, 4) NULL,
refundnum bigint(20) NULL,
refundprice DECIMAL(38, 4) NULL,
order_nums bigint(20) NULL
) ENGINE=OLAP
DUPLICATE KEY(data_day)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(resort) BUCKETS 4
PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"is_being_synced" = "false",
"storage_format" = "V2",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false"
);

CREATE VIEW ds_mt_order_product COMMENT 'VIEW' AS SELECT tenant_id AS tenant_id, data_day AS data_day, data_year AS data_year, data_year_month AS data_year_month, saleorgid AS saleorgid, saleorgname AS saleorgname, resort AS resort, resort_sdp AS resort_sdp, hotelname AS hotelname, hotel_abbr AS hotel_abbr, management AS management, region AS region, brand AS brand, productsn AS productsn, productname AS productname, selectedstatus AS selectedstatus, status AS status, refundstatus AS refundstatus, refundflag AS refundflag, number AS number, payprice AS payprice, refundnum AS refundnum, refundprice AS refundprice, order_nums AS order_nums FROM default_cluster:ent_0x1y2z_oey8krmq_a.ds_mt_order_product;

doris运行时的异常日志:

2024-05-20 16:58:26,056 WARN (thrift-server-pool-12559|24560468) [StmtExecutor.analyze():1021] Analyze failed. stmt[3928201, 5ac5be02a9254751-b5ef9e97f5571c1e]
java.lang.IllegalStateException: null
at com.google.common.base.Preconditions.checkState(Preconditions.java:496) ~[guava-32.1.2-jre.jar:?]
at org.apache.doris.analysis.SlotRef.getTable(SlotRef.java:490) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.rewrite.mvrewrite.CountDistinctToBitmap.apply(CountDistinctToBitmap.java:72) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.rewrite.ExprRewriter.applyRuleUpBottom(ExprRewriter.java:248) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.rewrite.ExprRewriter.applyRuleUpBottom(ExprRewriter.java:253) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.rewrite.ExprRewriter.applyRule(ExprRewriter.java:224) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.rewrite.ExprRewriter.applyRuleRepeatedly(ExprRewriter.java:216) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.rewrite.ExprRewriter.rewrite(ExprRewriter.java:166) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.rewrite.ExprRewriter.rewrite(ExprRewriter.java:151) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.analysis.QueryStmt.rewriteQueryExprByMvColumnExpr(QueryStmt.java:286) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.analysis.SelectStmt.substituteSelectList(SelectStmt.java:2481) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.analysis.BaseViewStmt.createColumnAndViewDefs(BaseViewStmt.java:121) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.analysis.CreateViewStmt.analyze(CreateViewStmt.java:84) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.qe.StmtExecutor.analyze(StmtExecutor.java:1017) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.qe.StmtExecutor.executeByLegacy(StmtExecutor.java:684) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:456) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.qe.ConnectProcessor.proxyExecute(ConnectProcessor.java:775) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.service.FrontendServiceImpl.forward(FrontendServiceImpl.java:1089) ~[doris-fe.jar:1.2-SNAPSHOT]
at sun.reflect.GeneratedMethodAccessor1216.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_111]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_111]
at org.apache.doris.service.FeServer.lambda$start$0(FeServer.java:59) ~[doris-fe.jar:1.2-SNAPSHOT]
at com.sun.proxy.$Proxy36.forward(Unknown Source) ~[?:?]
at org.apache.doris.thrift.FrontendService$Processor$forward.getResult(FrontendService.java:3072) ~[fe-common-1.2-SNAPSHOT.jar:1.2-SNAPSHOT]
at org.apache.doris.thrift.FrontendService$Processor$forward.getResult(FrontendService.java:3052) ~[fe-common-1.2-SNAPSHOT.jar:1.2-SNAPSHOT]
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:38) ~[libthrift-0.16.0.jar:0.16.0]
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:38) ~[libthrift-0.16.0.jar:0.16.0]
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:250) ~[libthrift-0.16.0.jar:0.16.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_111]
at java.lang.Thread.run(Thread.java:745) ~[?:1.8.0_111]
2024-05-20 16:58:26,058 WARN (thrift-server-pool-12559|24560468) [StmtExecutor.executeByLegacy():790] execute Exception. stmt[3928201, 5ac5be02a9254751-b5ef9e97f5571c1e]
org.apache.doris.common.AnalysisException: errCode = 2, detailMessage = Unexpected exception: null
at org.apache.doris.qe.StmtExecutor.analyze(StmtExecutor.java:1022) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.qe.StmtExecutor.executeByLegacy(StmtExecutor.java:684) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:456) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.qe.ConnectProcessor.proxyExecute(ConnectProcessor.java:775) ~[doris-fe.jar:1.2-SNAPSHOT]
at org.apache.doris.service.FrontendServiceImpl.forward(FrontendServiceImpl.java:1089) ~[doris-fe.jar:1.2-SNAPSHOT]
at sun.reflect.GeneratedMethodAccessor1216.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_111]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_111]
at org.apache.doris.service.FeServer.lambda$start$0(FeServer.java:59) ~[doris-fe.jar:1.2-SNAPSHOT]
at com.sun.proxy.$Proxy36.forward(Unknown Source) ~[?:?]
at org.apache.doris.thrift.FrontendService$Processor$forward.getResult(FrontendService.java:3072) ~[fe-common-1.2-SNAPSHOT.jar:1.2-SNAPSHOT]
at org.apache.doris.thrift.FrontendService$Processor$forward.getResult(FrontendService.java:3052) ~[fe-common-1.2-SNAPSHOT.jar:1.2-SNAPSHOT]
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:38) ~[libthrift-0.16.0.jar:0.16.0]
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:38) ~[libthrift-0.16.0.jar:0.16.0]
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:250) ~[libthrift-0.16.0.jar:0.16.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_111]
at java.lang.Thread.run(Thread.java:745) ~[?:1.8.0_111]

1 Answers

已知问题,2.0.9测试已经修复,可以考虑升级2.0.10