为了更快的定位您的问题,请提供以下信息,谢谢
【详述】问题详细描述
嵌套case when触发了SQL解析的异常: (conn=99) Unknown error
【背景】做过哪些操作?
CREATE TABLE `table_1` (
`id` bigint(20) NULL COMMENT "",
`name` varchar(65533) NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`id`, `name`)
COMMENT "新建工作表1"
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"enable_persistent_index" = "false",
"replicated_storage" = "true",
"compression" = "LZ4"
);
insert into table_1 values(1,"11223");
-- 执行两遍,第一遍不触发 AddDecodeNodeForDictStringRule
explain select
case
when `name`<>'' then
(case mod(cast(substring(`name`, 0, 1) as int), 10)
when '1' then 'AAA'
when '0' then 'BBB'
else null
end)
else null
end as `c1`
from
`table_1`;
【业务影响】SQL查询异常
【是否存算分离】 否
【StarRocks版本】3.1.8
【集群规模】3fe+3be
【机器信息】
【联系方式】541166058@qq.com
【附件】
fe.warn.log:
WARN (starrocks-mysql-nio-pool-27|45692) [StmtExecutor.execute():653] execute Exception, sql explain select case when `name`<>'' then (case mod(cast(substring(`name`, 0, 1) as int), 10) when '1' then 'AAA' when '0' then 'BBB' else null end) else null end as `c1` from `table_1`
java.lang.IllegalStateException: null
at com.google.common.base.Preconditions.checkState(Preconditions.java:496) ~[spark-dpp-1.0.0.jar:?]
at com.starrocks.sql.optimizer.rule.tree.DictMappingRewriter.rewriteAsDictMapping(DictMappingRewriter.java:79) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.rule.tree.DictMappingRewriter.rewrite(DictMappingRewriter.java:58) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.rule.tree.AddDecodeNodeForDictStringRule$DecodeVisitor.rewriteOneScalarOperatorForProjection(AddDecodeNodeForDictStringRule.java:582) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.rule.tree.AddDecodeNodeForDictStringRule$DecodeVisitor.rewriteProjectOperator(AddDecodeNodeForDictStringRule.java:511) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.rule.tree.AddDecodeNodeForDictStringRule$DecodeVisitor.visitProjectionAfter(AddDecodeNodeForDictStringRule.java:275) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.rule.tree.AddDecodeNodeForDictStringRule$DecodeVisitor.visitPhysicalOlapScan(AddDecodeNodeForDictStringRule.java:480) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.rule.tree.AddDecodeNodeForDictStringRule$DecodeVisitor.visitPhysicalOlapScan(AddDecodeNodeForDictStringRule.java:184) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.operator.physical.PhysicalOlapScanOperator.accept(PhysicalOlapScanOperator.java:168) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.rule.tree.AddDecodeNodeForDictStringRule.rewrite(AddDecodeNodeForDictStringRule.java:959) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.Optimizer.physicalRuleRewrite(Optimizer.java:641) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.Optimizer.optimizeByCost(Optimizer.java:226) ~[starrocks-fe.jar:?]
at com.starrocks.sql.optimizer.Optimizer.optimize(Optimizer.java:134) ~[starrocks-fe.jar:?]
at com.starrocks.sql.StatementPlanner.createQueryPlanWithReTry(StatementPlanner.java:210) ~[starrocks-fe.jar:?]
at com.starrocks.sql.StatementPlanner.planQuery(StatementPlanner.java:129) ~[starrocks-fe.jar:?]
at com.starrocks.sql.StatementPlanner.plan(StatementPlanner.java:93) ~[starrocks-fe.jar:?]
at com.starrocks.sql.StatementPlanner.plan(StatementPlanner.java:62) ~[starrocks-fe.jar:?]
at com.starrocks.qe.StmtExecutor.execute(StmtExecutor.java:458) ~[starrocks-fe.jar:?]
at com.starrocks.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:374) ~[starrocks-fe.jar:?]
at com.starrocks.qe.ConnectProcessor.dispatch(ConnectProcessor.java:488) ~[starrocks-fe.jar:?]
at com.starrocks.qe.ConnectProcessor.processOnce(ConnectProcessor.java:764) ~[starrocks-fe.jar:?]
at com.starrocks.mysql.nio.ReadListener.lambda$handleEvent$0(ReadListener.java:69) ~[starrocks-fe.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]