3.2.x版本 查询view 复杂的多表join报错表达式统计信息异常

为了更快的定位您的问题,请提供以下信息,谢谢
【详述】多表join查询视图如果有比较复杂的表达式会有统计信息报错
报错信息


【背景】做过哪些操作?
【业务影响】
【是否存算分离】
【StarRocks版本】3.2.14
【集群规模】例如:3fe(1 follower+2observer)+5be(fe与be混部)
【机器信息】CPU虚拟核/内存/网卡,例如:48C/64G/万兆
【联系方式】社区群22 hpp
【附件】
复现数据构造sql
统计信息.sql (3.0 KB)

问题的sql
explain SELECT COUNT(*) AS _count FROM ((SELECT $f12 FROM (SELECT CONCAT(CONCAT(CASE WHEN _persist_TABLE_5HqSC16dHW_WORKING.split_sku_no IS NOT NULL THEN _persist_TABLE_5HqSC16dHW_WORKING.split_sku_no ELSE ‘’ END, ‘–’), CASE WHEN _persist_TABLE_5HqSC16dHW_WORKING.code IS NOT NULL THEN _persist_TABLE_5HqSC16dHW_WORKING.code ELSE ‘’ END) AS $f12 FROM ((SELECT _persist_TABLE_5HqSC16dHW_WORKING.code, _persist_TABLE_5HqSC16dHW_WORKING.split_sku_no, _persist_TABLE_5HqSC16dHW_WORKING.customer_id FROM dev._persist_TABLE_5HqSC16dHW_WORKING) AS _persist_TABLE_5HqSC16dHW_WORKING LEFT JOIN (SELECT _persist_TABLE_lE6FfryyMt_WORKING.id FROM ((SELECT _persist_TABLE_lE6FfryyMt_WORKING.id, _persist_TABLE_lE6FfryyMt_WORKING.country_id FROM dev._persist_TABLE_lE6FfryyMt_WORKING) AS _persist_TABLE_lE6FfryyMt_WORKING LEFT JOIN (SELECT dim_db_erp_country_f.bsn_id FROM dev.dim_db_erp_country_f GROUP BY dim_db_erp_country_f.bsn_id, dim_db_erp_country_f.name_cn) AS dim_db_erp_country_f ON _persist_TABLE_lE6FfryyMt_WORKING.country_id = dim_db_erp_country_f.bsn_id)) AS t ON _persist_TABLE_5HqSC16dHW_WORKING.customer_id = t.id)) AS t1) AS t2 INNER JOIN (SELECT $f5 FROM (SELECT CONCAT(CONCAT(CASE WHEN _persist_TABLE_u9eoIQAn9J_WORKING.split_sku_no IS NOT NULL THEN _persist_TABLE_u9eoIQAn9J_WORKING.split_sku_no ELSE ‘’ END, ‘–’), CASE WHEN _persist_TABLE_u9eoIQAn9J_WORKING.so_code IS NOT NULL THEN _persist_TABLE_u9eoIQAn9J_WORKING.so_code ELSE ‘’ END) AS $f5 FROM dev._persist_TABLE_u9eoIQAn9J_WORKING) AS _persist_TABLE_u9eoIQAn9J_WORKING) AS _persist_TABLE_u9eoIQAn9J_WORKING ON t2.$f12 = _persist_TABLE_u9eoIQAn9J_WORKING.$f5);
如果切换成正常的表 不走视图是可以查询的

用view的任意函数带有字段作为join条件时(例如 concat(column1)),统计信息中的左表会丢失这个表达式的统计信息

com.starrocks.sql.common.StarRocksPlannerException: only found column statistics: {1: dpbh, 2: dpmc, 4: zzh, 20: shop_name, 23: concat}, but missing statistic of col: 17: concat.
    at com.starrocks.sql.optimizer.statistics.Statistics.getColumnStatistic(Statistics.java:93)
    at com.starrocks.sql.optimizer.statistics.ExpressionStatisticCalculator$ExpressionStatisticVisitor.visitVariableReference(ExpressionStatisticCalculator.java:81)
    at com.starrocks.sql.optimizer.statistics.ExpressionStatisticCalculator$ExpressionStatisticVisitor.visitVariableReference(ExpressionStatisticCalculator.java:60)
    at com.starrocks.sql.optimizer.operator.scalar.ColumnRefOperator.accept(ColumnRefOperator.java:131)
    at com.starrocks.sql.optimizer.statistics.ExpressionStatisticCalculator.calculate(ExpressionStatisticCalculator.java:57)
    at com.starrocks.sql.optimizer.statistics.ExpressionStatisticCalculator.calculate(ExpressionStatisticCalculator.java:49)
    at com.starrocks.sql.optimizer.statistics.PredicateStatisticsCalculator$BaseCalculatingVisitor.getExpressionStatistic(PredicateStatisticsCalculator.java:369)
    at com.starrocks.sql.optimizer.statistics.PredicateStatisticsCalculator$BaseCalculatingVisitor.visitBinaryPredicate(PredicateStatisticsCalculator.java:249)
    at com.starrocks.sql.optimizer.statistics.PredicateStatisticsCalculator$BaseCalculatingVisitor.visitBinaryPredicate(PredicateStatisticsCalculator.java:62)
    at com.starrocks.sql.optimizer.operator.scalar.BinaryPredicateOperator.accept(BinaryPredicateOperator.java:79)
    at com.starrocks.sql.optimizer.statistics.PredicateStatisticsCalculator.statisticsCalculate(PredicateStatisticsCalculator.java:45)
    at com.starrocks.sql.optimizer.statistics.StatisticsCalculator.estimateStatistics(StatisticsCalculator.java:1509)
    at com.starrocks.sql.optimizer.statistics.StatisticsCalculator.computeJoinNode(StatisticsCalculator.java:1009)
    at com.starrocks.sql.optimizer.statistics.StatisticsCalculator.visitLogicalJoin(StatisticsCalculator.java:867)
    at com.starrocks.sql.optimizer.statistics.StatisticsCalculator.visitLogicalJoin(StatisticsCalculator.java:174)
    at com.starrocks.sql.optimizer.operator.logical.LogicalJoinOperator.accept(LogicalJoinOperator.java:209)
    at com.starrocks.sql.optimizer.statistics.StatisticsCalculator.estimatorStats(StatisticsCalculator.java:197)
    at com.starrocks.sql.optimizer.task.DeriveStatsTask.execute(DeriveStatsTask.java:63)
    at com.starrocks.sql.optimizer.task.SeriallyTaskScheduler.executeTasks(SeriallyTaskScheduler.java:65)
    at com.starrocks.sql.optimizer.Optimizer.memoOptimize(Optimizer.java:759)
    at com.starrocks.sql.optimizer.Optimizer.optimizeByCost(Optimizer.java:257)
    at com.starrocks.sql.optimizer.Optimizer.optimize(Optimizer.java:181)
    at com.starrocks.sql.StatementPlanner.createQueryPlanWithReTry(StatementPlanner.java:320)
    at com.starrocks.sql.StatementPlanner.plan(StatementPlanner.java:137)
    at com.starrocks.sql.StatementPlanner.plan(StatementPlanner.java:95)
    at com.starrocks.qe.StmtExecutor.execute(StmtExecutor.java:545)
    at com.starrocks.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:343)
    at com.starrocks.qe.ConnectProcessor.dispatch(ConnectProcessor.java:537)
    at com.starrocks.qe.ConnectProcessor.processOnce(ConnectProcessor.java:845)
    at com.starrocks.mysql.nio.ReadListener.lambda$handleEvent$0(ReadListener.java:69)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

把这个表达式放到前一个join查询的时候是正常的 挺奇怪的一个问题