@@ -850,31 +850,29 @@ public static boolean checkIsDimTableGroupBy(SqlNode sqlNode, Collection<String>
850850 // 2.(sub query) as alias group by
851851 // 3.tableName group by
852852 // 4.tableName as alias group by
853- // 5.tableName no group by
854- // 6.tableName as alias no group by
855-
856- // 没有group by:5.no group by
857- if (fromNode .getKind () == IDENTIFIER
858- && (groupNodeList == null || groupNodeList .size () == 0 )) {
859- return false ;
860- }
853+ // 5.others return false
861854
862855 // (子查询) group by:1.(sub query) group by
863856 if (fromNode .getKind () == SELECT ) {
864857 return checkIsDimTableGroupBy (fromNode , newRegisterTableList );
865858 }
866859
867860 // 表名 as 别名 group by、(子查询) as 别名 group by、表名 group by
868- if (fromNode .getKind () == AS ) {
869- // 表名 as 别名 group by:4.tableName as alias group by
870- SqlNode operand = ((SqlBasicCall ) fromNode ).getOperands ()[0 ];
871- // (子查询) as 别名 group by:2.(sub query) as alias group by
872- if (operand .getKind () != IDENTIFIER ) {
873- return checkIsDimTableGroupBy (fromNode , newRegisterTableList );
861+ if (fromNode .getKind () == AS || fromNode .getKind () == IDENTIFIER ) {
862+ SqlNode operand ;
863+ // 表名 group by:3.tableName group by
864+ if (fromNode .getKind () == IDENTIFIER ) {
865+ operand = fromNode ;
866+ } else {
867+ // 表名 as 别名 group by:4.tableName as alias group by
868+ operand = ((SqlBasicCall ) fromNode ).getOperands ()[0 ];
869+ // (子查询) as 别名 group by:2.(sub query) as alias group by
870+ if (operand .getKind () != IDENTIFIER ) {
871+ return checkIsDimTableGroupBy (fromNode , newRegisterTableList );
872+ }
874873 }
875874
876875 // 最里层是表名 group by,且group by字段不为空,且表名包含在维表中
877- // 6.tableName as alias no group by,会在这一层过滤掉
878876 if (operand .getKind () == IDENTIFIER
879877 && groupNodeList != null
880878 && groupNodeList .size () != 0
0 commit comments