public Binder(Pattern pattern, GroupExpression groupExpression) {
        this.pattern = pattern;
        this.groupExpression = groupExpression;
        this.groupExpressionIndex = Lists.newArrayList(0);

        // MULTI_JOIN is a special pattern which can contain children groups if the input group expression
        // is not a scan node.
        this.isPatternWithoutChildren = pattern.isPatternMultiJoin()
                ? Pattern.ALL_SCAN_TYPES.contains(groupExpression.getOp().getOpType())
                : pattern.children().size() == 0;
    }
@Test
    public void testBinder() {
        OlapTable table1 = new OlapTable();
        table1.setDefaultDistributionInfo(new HashDistributionInfo());
        OlapTable table2 = new OlapTable();
        table2.setDefaultDistributionInfo(new HashDistributionInfo());
        OptExpression expr = OptExpression.create(new LogicalJoinOperator(),
                new OptExpression(new LogicalOlapScanOperator(table1)),
                new OptExpression(new LogicalOlapScanOperator(table2)));

        Pattern pattern = Pattern.create(OperatorType.LOGICAL_JOIN)
                .addChildren(Pattern.create(OperatorType.PATTERN_LEAF))
                .addChildren(Pattern.create(OperatorType.PATTERN_LEAF));

        Memo memo = new Memo();
        OptExpression result = Binder.bind(pattern, memo.init(expr));

        assertEquals(OperatorType.LOGICAL_JOIN, result.getOp().getOpType());
        assertEquals(OperatorType.LOGICAL_OLAP_SCAN, result.inputAt(0).getOp().getOpType());
        assertEquals(OperatorType.LOGICAL_OLAP_SCAN, result.inputAt(1).getOp().getOpType());
    }