Source:
<code>public List<SingleColumn> generateChecksumColumns(Column column) { checkArgument(column.getType() instanceof MapType, "Expect MapType, found %s", column.getType().getDisplayName()); Type keyType = ((MapType) column.getType()).getKeyType(); Type valueType = ((MapType) column.getType()).getValueType(); ImmutableList.Builder<Expression> checksums = ImmutableList.builder(); checksums.add(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(column.getIdentifier()))); Expression mapCardinalitySum = new CoalesceExpression( new FunctionCall( QualifiedName.of("sum"), ImmutableList.of(new FunctionCall(QualifiedName.of("cardinality"), ImmutableList.of(column.getIdentifier())))), new LongLiteral("0")); if (keyType.isOrderable()) { FunctionCall mapKeys = new FunctionCall(QualifiedName.of("map_keys"), ImmutableList.of(column.getIdentifier())); FunctionCall sortKeys = new FunctionCall(QualifiedName.of("array_sort"), ImmutableList.of(mapKeys)); checksums.add(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(sortKeys))); } if (valueType.isOrderable()) { FunctionCall mapValues = new FunctionCall(QualifiedName.of("map_values"), ImmutableList.of(column.getIdentifier())); FunctionCall sortValues = new FunctionCall(QualifiedName.of("array_sort"), ImmutableList.of(mapValues)); checksums.add(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(sortValues))); } return ImmutableList.of( <START> new SingleColumn(new CoalesceExpression(checksums.build()), Optional.of(delimitedIdentifier(getChecksumColumnAlias(column)))), <END> new SingleColumn(mapCardinalitySum, Optional.of(delimitedIdentifier(getCardinalitySumColumnAlias(column))))); }</code><technical_language>This right. I need multiple columns here, e.g. checksum(m), checksum(array_sort(map_keys(m))) checksum(array_sort(map_values(m)))</technical_language>

Target:
public List<SingleColumn> generateChecksumColumns(Column column) { checkArgument(column.getType() instanceof MapType, "Expect MapType, found %s", column.getType().getDisplayName()); Type keyType = ((MapType) column.getType()).getKeyType(); Type valueType = ((MapType) column.getType()).getValueType(); Expression checksum = functionCall("checksum", column.getExpression()); Expression keys = functionCall("map_keys", column.getExpression()); if (keyType.isOrderable()) { keys = functionCall("array_sort", keys); } Expression keysChecksum = functionCall("checksum", keys); Expression values = functionCall("map_values", column.getExpression()); if (valueType.isOrderable()) { values = functionCall("array_sort", values); } Expression valuesChecksum = functionCall("checksum", values); Expression mapCardinalitySum = new CoalesceExpression( functionCall("sum", functionCall("cardinality", column.getExpression())), new LongLiteral("0")); return ImmutableList.of( new SingleColumn(checksum, Optional.of(delimitedIdentifier(getChecksumColumnAlias(column)))), new SingleColumn(keysChecksum, Optional.of(delimitedIdentifier(getKeysChecksumColumnAlias(column)))), new SingleColumn(valuesChecksum, Optional.of(delimitedIdentifier(getValuesChecksumColumnAlias(column)))), new SingleColumn(mapCardinalitySum, Optional.of(delimitedIdentifier(getCardinalitySumColumnAlias(column))))); }