@VisibleForTesting
    static Optional<String> buildGlueExpressionForSingleDomain(String columnName, Domain domain)
    {
        checkState(!domain.isAll());
        ValueSet valueSet = domain.getValues();

        if (!canConvertSqlTypeToStringForGlue(domain.getType())) {
            return Optional.empty();
        }

        if (domain.getValues().isAll()) {
            return Optional.of(format("(%s <> '%s')", columnName, HIVE_DEFAULT_DYNAMIC_PARTITION));
        }

        // null must be allowed for this case since callers must filter Domain.none() out
        if (domain.getValues().isNone()) {
            return Optional.of(format("(%s = '%s')", columnName, HIVE_DEFAULT_DYNAMIC_PARTITION));
        }

        List<String> disjuncts = new ArrayList<>();
        List<String> singleValues = new ArrayList<>();
        for (Range range : valueSet.getRanges().getOrderedRanges()) {
            checkState(!range.isAll()); // Already checked
            if (range.isSingleValue()) {
                singleValues.add(valueToString(range.getSingleValue(), range.getType()));
            }
            else {
                List<String> rangeConjuncts = new ArrayList<>();
                if (!range.isLowUnbounded()) {
                    rangeConjuncts.add(format(
                            "%s %s %s",
                            columnName,
                            range.isLowInclusive() ? ">=" : ">",
                            valueToString(range.getLowBoundedValue(), range.getType())));
                }
                if (!range.isHighUnbounded()) {
                    rangeConjuncts.add(format(
                            "%s %s %s",
                            columnName,
                            range.isHighInclusive() ? "<=" : "<",
                            valueToString(range.getHighBoundedValue(), range.getType())));
                }
                // If rangeConjuncts is null, then the range was ALL, which should already have been checked for by callers
                checkState(!rangeConjuncts.isEmpty());
                disjuncts.add("(" + CONJUNCT_JOINER.join(rangeConjuncts) + ")");
            }
        }

        if (singleValues.size() == 1) {
            String equalsTest = format("(%s = %s)", columnName, getOnlyElement(singleValues.listIterator()));
            disjuncts.add(equalsTest);
        }
        else if (singleValues.size() > 1) {
            String values = Joiner.on(", ").join(singleValues);
            String inClause = format("(%s in (%s))", columnName, values);

            disjuncts.add(inClause);
        }

        return Optional.of("(" + DISJUNCT_JOINER.join(disjuncts) + ")");
    }
@Test
    public void testBuildGlueExpressionDomainEqualsSingleValue()
    {
        Domain domain = Domain.singleValue(VarcharType.VARCHAR, utf8Slice("2020-01-01"));
        Optional<String> foo = buildGlueExpressionForSingleDomain("foo", domain);
        assertEquals(foo.get(), "((foo = '2020-01-01'))");
    }