public static Optional<String> makePartitionFilter(
            int partColOffset,
            List<String> partColNames,
            List<Expression> expressions,
            HiveShim hiveShim) {
        List<String> filters = new ArrayList<>(expressions.size());
        ExpressionExtractor extractor =
                new ExpressionExtractor(partColOffset, partColNames, hiveShim);
        for (Expression expression : expressions) {
            String str = expression.accept(extractor);
            if (str == null) {
                return Optional.empty();
            }
            filters.add(str);
        }
        return Optional.of(String.join(" and ", filters));
    }
@Test
    public void testMakePartitionFilter() {
        List<String> partColNames = Arrays.asList("p1", "p2", "p3");
        ResolvedExpression p1Ref = new FieldReferenceExpression("p1", DataTypes.INT(), 0, 2);
        ResolvedExpression p2Ref = new FieldReferenceExpression("p2", DataTypes.STRING(), 0, 3);
        ResolvedExpression p3Ref = new FieldReferenceExpression("p3", DataTypes.DOUBLE(), 0, 4);
        ResolvedExpression p1Exp =
                CallExpression.permanent(
                        BuiltInFunctionDefinitions.EQUALS,
                        Arrays.asList(p1Ref, valueLiteral(1)),
                        DataTypes.BOOLEAN());
        ResolvedExpression p2Exp =
                CallExpression.permanent(
                        BuiltInFunctionDefinitions.EQUALS,
                        Arrays.asList(p2Ref, valueLiteral("a", DataTypes.STRING().notNull())),
                        DataTypes.BOOLEAN());
        ResolvedExpression p3Exp =
                CallExpression.permanent(
                        BuiltInFunctionDefinitions.EQUALS,
                        Arrays.asList(p3Ref, valueLiteral(1.1)),
                        DataTypes.BOOLEAN());
        Optional<String> filter =
                HiveTableUtil.makePartitionFilter(2, partColNames, Arrays.asList(p1Exp), hiveShim);
        assertThat(filter.orElse(null)).isEqualTo("(p1 = 1)");

        filter =
                HiveTableUtil.makePartitionFilter(
                        2, partColNames, Arrays.asList(p1Exp, p3Exp), hiveShim);
        assertThat(filter.orElse(null)).isEqualTo("(p1 = 1) and (p3 = 1.1)");

        filter =
                HiveTableUtil.makePartitionFilter(
                        2,
                        partColNames,
                        Arrays.asList(
                                p2Exp,
                                CallExpression.permanent(
                                        BuiltInFunctionDefinitions.OR,
                                        Arrays.asList(p1Exp, p3Exp),
                                        DataTypes.BOOLEAN())),
                        hiveShim);
        assertThat(filter.orElse(null)).isEqualTo("(p2 = 'a') and ((p1 = 1) or (p3 = 1.1))");
    }