@Override
    public List<OptExpression> transform(OptExpression input, OptimizerContext context) {
        LogicalOlapScanOperator logicalOlapScanOperator = (LogicalOlapScanOperator) input.getOp();
        LogicalOlapScanOperator prunedOlapScanOperator = null;
        if (logicalOlapScanOperator.getSelectedPartitionId() == null) {
            prunedOlapScanOperator = OptOlapPartitionPruner.prunePartitions(logicalOlapScanOperator);
        } else {
            // do merge pruned partitions with new pruned partitions
            prunedOlapScanOperator = OptOlapPartitionPruner.mergePartitionPrune(logicalOlapScanOperator);
        }
        Utils.setOpAppliedRule(prunedOlapScanOperator, Operator.OP_PARTITION_PRUNE_BIT);
        return Lists.newArrayList(OptExpression.create(prunedOlapScanOperator, input.getInputs()));
    }
@Test
    public void transformForSingleItemListPartition(@Mocked OlapTable olapTable,
                                                    @Mocked ListPartitionInfo partitionInfo)
            throws AnalysisException {
        FeConstants.runningUnitTest = true;
        ColumnRefFactory columnRefFactory = new ColumnRefFactory();
        ColumnRefOperator column = columnRefFactory.create("province", ScalarType.STRING, false);
        Map<ColumnRefOperator, Column> scanColumnMap = Maps.newHashMap();
        scanColumnMap.put(column, new Column("province", Type.STRING, false));
        Map<Column, ColumnRefOperator> columnMetaToColRefMap = new HashMap<>();
        columnMetaToColRefMap.put(new Column(column.getName(), column.getType()),
                new ColumnRefOperator(1, column.getType(), column.getName(), false));

        BinaryPredicateOperator binaryPredicateOperator =
                new BinaryPredicateOperator(BinaryType.EQ, column,
                        ConstantOperator.createVarchar("guangdong"));
        ScalarOperator predicate = Utils.compoundAnd(binaryPredicateOperator);

        LogicalOlapScanOperator operator =
                new LogicalOlapScanOperator(olapTable, scanColumnMap, columnMetaToColRefMap, null, -1, predicate);

        Partition part1 = new Partition(10001L, "p1", null, null);
        Partition part2 = new Partition(10002L, "p2", null, null);

        List<LiteralExpr> p1 = Lists.newArrayList(
                new PartitionValue("guangdong").getValue(Type.STRING),
                new PartitionValue("shanghai").getValue(Type.STRING));

        List<LiteralExpr> p2 = Lists.newArrayList(
                new PartitionValue("beijing").getValue(Type.STRING),
                new PartitionValue("chongqing").getValue(Type.STRING));

        Map<Long, List<LiteralExpr>> literalExprValues = new HashMap<>();
        literalExprValues.put(10001L, p1);
        literalExprValues.put(10002L, p2);

        List<ColumnId> partitionColumns = Lists.newArrayList(ColumnId.create("province"));

        new Expectations() {
            {
                olapTable.getPartitionInfo();
                result = partitionInfo;

                partitionInfo.getType();
                result = PartitionType.LIST;

                partitionInfo.getLiteralExprValues();
                result = literalExprValues;

                olapTable.getPartitions();
                result = Lists.newArrayList(part1, part2);
                minTimes = 0;

                partitionInfo.getPartitionColumns((Map<ColumnId, Column>) any);
                result = Lists.newArrayList(new Column("province", Type.STRING, false));
                minTimes = 0;

                partitionInfo.getPartitionIds(false);
                result = Lists.newArrayList(10001L, 10002L);

                olapTable.getPartition(10001L);
                result = part1;
                minTimes = 0;

                olapTable.getPartition(10002L);
                result = part2;
                minTimes = 0;
            }
        };

        PartitionPruneRule rule = new PartitionPruneRule();
        assertNull(operator.getSelectedPartitionId());
        OptExpression optExpression =
                rule.transform(new OptExpression(operator), new OptimizerContext(new Memo(), columnRefFactory)).get(0);

        List<Long> selectPartitionIds = ((LogicalOlapScanOperator) optExpression.getOp()).getSelectedPartitionId();
        assertEquals(1, selectPartitionIds.size());
        long actual = selectPartitionIds.get(0);
        assertEquals(10001L, actual);
    }