@Test public void testNodeTraversal3() { ExpressionNode n1 = FACTORY.newInstance(); ExpressionNode n2 = FACTORY.newInstance(); n1.type = FUNCTION; n2.type = FUNCTION; n1.lhs = FACTORY.newInstance(); assertFalse(GroupByUtils.compareNodes(n1, n2)); }
public static boolean compareNodes(ExpressionNode groupBy, ExpressionNode selectNode) { if (groupBy == null && selectNode == null) { return true; } if (groupBy == null || selectNode == null || groupBy.type != selectNode.type) { return false; } int dotIndex = groupBy.token != null ? Chars.indexOf(groupBy.token, '.') : -1; if ((dotIndex < 0 && !Chars.equals(groupBy.token, selectNode.token)) || (dotIndex > -1 && !Chars.equals(selectNode.token, groupBy.token, dotIndex + 1, groupBy.token.length()))) { return false; } int groupByArgsSize = groupBy.args.size(); int selectNodeArgsSize = selectNode.args.size(); if (groupByArgsSize != selectNodeArgsSize) { return false; } if (groupByArgsSize < 3) { return compareNodes(groupBy.lhs, selectNode.lhs) && compareNodes(groupBy.rhs, selectNode.rhs); } for (int i = 0; i < groupByArgsSize; i++) { if (!compareNodes(groupBy.args.get(i), selectNode.args.get(i))) { return false; } } return true; }
GroupByUtils { public static boolean compareNodes(ExpressionNode groupBy, ExpressionNode selectNode) { if (groupBy == null && selectNode == null) { return true; } if (groupBy == null || selectNode == null || groupBy.type != selectNode.type) { return false; } int dotIndex = groupBy.token != null ? Chars.indexOf(groupBy.token, '.') : -1; if ((dotIndex < 0 && !Chars.equals(groupBy.token, selectNode.token)) || (dotIndex > -1 && !Chars.equals(selectNode.token, groupBy.token, dotIndex + 1, groupBy.token.length()))) { return false; } int groupByArgsSize = groupBy.args.size(); int selectNodeArgsSize = selectNode.args.size(); if (groupByArgsSize != selectNodeArgsSize) { return false; } if (groupByArgsSize < 3) { return compareNodes(groupBy.lhs, selectNode.lhs) && compareNodes(groupBy.rhs, selectNode.rhs); } for (int i = 0; i < groupByArgsSize; i++) { if (!compareNodes(groupBy.args.get(i), selectNode.args.get(i))) { return false; } } return true; } }
GroupByUtils { public static boolean compareNodes(ExpressionNode groupBy, ExpressionNode selectNode) { if (groupBy == null && selectNode == null) { return true; } if (groupBy == null || selectNode == null || groupBy.type != selectNode.type) { return false; } int dotIndex = groupBy.token != null ? Chars.indexOf(groupBy.token, '.') : -1; if ((dotIndex < 0 && !Chars.equals(groupBy.token, selectNode.token)) || (dotIndex > -1 && !Chars.equals(selectNode.token, groupBy.token, dotIndex + 1, groupBy.token.length()))) { return false; } int groupByArgsSize = groupBy.args.size(); int selectNodeArgsSize = selectNode.args.size(); if (groupByArgsSize != selectNodeArgsSize) { return false; } if (groupByArgsSize < 3) { return compareNodes(groupBy.lhs, selectNode.lhs) && compareNodes(groupBy.rhs, selectNode.rhs); } for (int i = 0; i < groupByArgsSize; i++) { if (!compareNodes(groupBy.args.get(i), selectNode.args.get(i))) { return false; } } return true; }  }
GroupByUtils { public static boolean compareNodes(ExpressionNode groupBy, ExpressionNode selectNode) { if (groupBy == null && selectNode == null) { return true; } if (groupBy == null || selectNode == null || groupBy.type != selectNode.type) { return false; } int dotIndex = groupBy.token != null ? Chars.indexOf(groupBy.token, '.') : -1; if ((dotIndex < 0 && !Chars.equals(groupBy.token, selectNode.token)) || (dotIndex > -1 && !Chars.equals(selectNode.token, groupBy.token, dotIndex + 1, groupBy.token.length()))) { return false; } int groupByArgsSize = groupBy.args.size(); int selectNodeArgsSize = selectNode.args.size(); if (groupByArgsSize != selectNodeArgsSize) { return false; } if (groupByArgsSize < 3) { return compareNodes(groupBy.lhs, selectNode.lhs) && compareNodes(groupBy.rhs, selectNode.rhs); } for (int i = 0; i < groupByArgsSize; i++) { if (!compareNodes(groupBy.args.get(i), selectNode.args.get(i))) { return false; } } return true; }  static void checkGroupBy(ObjList<ExpressionNode> groupBys, ObjList<QueryColumn> selectColumns, int groupByColumnCount, ExpressionNode alias); static boolean compareNodes(ExpressionNode groupBy, ExpressionNode selectNode); static void prepareGroupByFunctions(
            QueryModel model,
            RecordMetadata metadata,
            FunctionParser functionParser,
            SqlExecutionContext executionContext,
            ObjList<GroupByFunction> groupByFunctions,
            ArrayColumnTypes valueTypes
    ); static void prepareGroupByRecordFunctions(
            @NotNull QueryModel model,
            RecordMetadata metadata,
            @NotNull ListColumnFilter listColumnFilter,
            ObjList<GroupByFunction> groupByFunctions,
            ObjList<Function> recordFunctions,
            GenericRecordMetadata groupByMetadata,
            ArrayColumnTypes keyTypes,
            int keyColumnIndex,
            boolean timestampUnimportant,
            int timestampIndex
    ); static void toTop(ObjList<? extends Function> args); static void updateExisting(ObjList<GroupByFunction> groupByFunctions, int n, MapValue value, Record record); static void updateNew(ObjList<GroupByFunction> groupByFunctions, int n, MapValue value, Record record); static void validateGroupByColumns(@NotNull QueryModel model, ObjList<QueryColumn> columns, int groupByColumnCount); }
GroupByUtils { public static boolean compareNodes(ExpressionNode groupBy, ExpressionNode selectNode) { if (groupBy == null && selectNode == null) { return true; } if (groupBy == null || selectNode == null || groupBy.type != selectNode.type) { return false; } int dotIndex = groupBy.token != null ? Chars.indexOf(groupBy.token, '.') : -1; if ((dotIndex < 0 && !Chars.equals(groupBy.token, selectNode.token)) || (dotIndex > -1 && !Chars.equals(selectNode.token, groupBy.token, dotIndex + 1, groupBy.token.length()))) { return false; } int groupByArgsSize = groupBy.args.size(); int selectNodeArgsSize = selectNode.args.size(); if (groupByArgsSize != selectNodeArgsSize) { return false; } if (groupByArgsSize < 3) { return compareNodes(groupBy.lhs, selectNode.lhs) && compareNodes(groupBy.rhs, selectNode.rhs); } for (int i = 0; i < groupByArgsSize; i++) { if (!compareNodes(groupBy.args.get(i), selectNode.args.get(i))) { return false; } } return true; }  static void checkGroupBy(ObjList<ExpressionNode> groupBys, ObjList<QueryColumn> selectColumns, int groupByColumnCount, ExpressionNode alias); static boolean compareNodes(ExpressionNode groupBy, ExpressionNode selectNode); static void prepareGroupByFunctions(
            QueryModel model,
            RecordMetadata metadata,
            FunctionParser functionParser,
            SqlExecutionContext executionContext,
            ObjList<GroupByFunction> groupByFunctions,
            ArrayColumnTypes valueTypes
    ); static void prepareGroupByRecordFunctions(
            @NotNull QueryModel model,
            RecordMetadata metadata,
            @NotNull ListColumnFilter listColumnFilter,
            ObjList<GroupByFunction> groupByFunctions,
            ObjList<Function> recordFunctions,
            GenericRecordMetadata groupByMetadata,
            ArrayColumnTypes keyTypes,
            int keyColumnIndex,
            boolean timestampUnimportant,
            int timestampIndex
    ); static void toTop(ObjList<? extends Function> args); static void updateExisting(ObjList<GroupByFunction> groupByFunctions, int n, MapValue value, Record record); static void updateNew(ObjList<GroupByFunction> groupByFunctions, int n, MapValue value, Record record); static void validateGroupByColumns(@NotNull QueryModel model, ObjList<QueryColumn> columns, int groupByColumnCount);  }