Source:
<code>public Optional<Partitioning> translateToCoalesce(Partitioning other, Metadata metadata, Session session) { <START> checkArgument(metadata.getCommonPartitioning(session, this.handle, other.handle).isPresent(), "incompatible partitioning handles: %s != %s", this.handle, other.handle); <END> checkArgument(this.arguments.size() == other.arguments.size(), "incompatible number of partitioning arguments: %s != %s", this.arguments.size(), other.arguments.size()); ImmutableList.Builder<RowExpression> arguments = ImmutableList.builder(); for (int i = 0; i < this.arguments.size(); i++) { RowExpression leftArgument = this.arguments.get(i); RowExpression rightArgument = other.arguments.get(i); if (leftArgument instanceof ConstantExpression) { arguments.add(leftArgument); } else if (rightArgument instanceof ConstantExpression) { arguments.add(rightArgument); } else if (leftArgument instanceof VariableReferenceExpression && rightArgument instanceof VariableReferenceExpression) { VariableReferenceExpression leftVariable = (VariableReferenceExpression) leftArgument; VariableReferenceExpression rightVariable = (VariableReferenceExpression) rightArgument; checkArgument(leftVariable.getType().equals(rightVariable.getType()), "incompatible types: %s != %s", leftVariable.getType(), rightVariable.getType()); arguments.add(new SpecialFormExpression(COALESCE, leftVariable.getType(), ImmutableList.of(leftVariable, rightVariable))); } else { return Optional.empty(); } } return Optional.of(new Partitioning(metadata.isRefinedPartitioningOver(session, other.handle, this.handle) ? this.handle : other.handle, arguments.build())); }</code><technical_language>update error message</technical_language>

Target:
public Optional<Partitioning> translateToCoalesce(Partitioning other, Metadata metadata, Session session) { checkArgument(arePartitionHandlesCompatibleForCoalesce(this.handle, other.handle, metadata, session), "incompatible partitioning handles: cannot coalesce %s and %s", this.handle, other.handle); checkArgument(this.arguments.size() == other.arguments.size(), "incompatible number of partitioning arguments: %s != %s", this.arguments.size(), other.arguments.size()); ImmutableList.Builder<RowExpression> arguments = ImmutableList.builder(); for (int i = 0; i < this.arguments.size(); i++) { RowExpression leftArgument = this.arguments.get(i); RowExpression rightArgument = other.arguments.get(i); if (leftArgument instanceof ConstantExpression) { arguments.add(leftArgument); } else if (rightArgument instanceof ConstantExpression) { arguments.add(rightArgument); } else if (leftArgument instanceof VariableReferenceExpression && rightArgument instanceof VariableReferenceExpression) { VariableReferenceExpression leftVariable = (VariableReferenceExpression) leftArgument; VariableReferenceExpression rightVariable = (VariableReferenceExpression) rightArgument; checkArgument(leftVariable.getType().equals(rightVariable.getType()), "incompatible types: %s != %s", leftVariable.getType(), rightVariable.getType()); arguments.add(new SpecialFormExpression(COALESCE, leftVariable.getType(), ImmutableList.of(leftVariable, rightVariable))); } else { return Optional.empty(); } } return Optional.of(new Partitioning(metadata.isRefinedPartitioningOver(session, other.handle, this.handle) ? this.handle : other.handle, arguments.build())); }