in src/main/scala/com/amazon/deequ/analyzers/catalyst/AttributeReferenceCreation.java [73:118]
public static AttributeReference createSafe(String name) throws IllegalStateException {
try {
Class clazz = AttributeReference$.class;
Method apply = null;
for (Method method : clazz.getMethods()) {
if (method.getName().equals("apply")) {
apply = method;
break;
}
}
if (apply == null) {
throw new IllegalStateException("Unable to find apply method!");
}
LongType dataType = LongType$.MODULE$.asNullable();
Metadata emptyMetadata = Metadata$.MODULE$.empty();
scala.Option none = scala.Option.apply(null);
ExprId exprId = NamedExpression$.MODULE$.newExprId();
Object companion = AttributeReference$.MODULE$;
if (apply.getParameterCount() == 7) {
// Spark 2.2
return (AttributeReference) apply.invoke(companion, name, dataType, true,
emptyMetadata, exprId, none, false);
} else {
// Spark 2.4
Class<?> qualifierParameterType = apply.getParameterTypes()[5];
boolean qualifierParameterTypeIsSeq =
Seq.class.isAssignableFrom(qualifierParameterType);
if (qualifierParameterTypeIsSeq) {
return (AttributeReference) apply.invoke(companion, name, dataType, true,
emptyMetadata, exprId, Seq$.MODULE$.<String>empty());
} else {
// Spark 2.3
return (AttributeReference) apply.invoke(companion, name, dataType, true,
emptyMetadata, exprId, none);
}
}
} catch (Exception e) {
throw new IllegalStateException(e);
}
}