java - 如何从 java 调用 Amazon Deequ hasDataType

标签 java scala amazon-deequ

我正在尝试通过 Java 实现 Amazon Deequ 功能。

我正在尝试添加数据类型包含,但无法从 java 传递第三个参数(断言)

 com.amazon.deequ.constraints.Constraint constrains = Constraint.dataTypeConstraint("test", ConstrainableDataTypes.Numeric(), ?,x);

scala中的方法声明如下

 * @param column Column to compute the data type distribution for.
    * @param dataType The data type that should be checked in the assertion.
    * @param assertion Function from the ratio of the data type in the specified column to boolean.
    * @param hint A hint to provide additional context why a constraint could have failed
    * @return
    */
  def dataTypeConstraint(
      column: String,
      dataType: ConstrainableDataTypes.Value,
      assertion: Double => Boolean,
      hint: Option[String] = None)
    : Constraint = {

最佳答案

在 Java 中,您应该能够通过实现 AbstractFunction1 并将其作为参数传递来调用 dataTypeConstraint:

scala.Function1<Double, Boolean> function = new scala.runtime.AbstractFunction1<Double, Boolean>() {
    public Boolean apply(Double value) {
        // implement the actual assertion here
        return value >= 0;
    }
};

Constraint.dataTypeConstraint("column", dataType, function, scala.Option.apply("a hint"));

关于java - 如何从 java 调用 Amazon Deequ hasDataType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60955449/

相关文章:

java - 如何在基于范围的 for 循环内获取进度信息?

scala - 函数组合导致方法首先缺少参数列表

scala - 使用 -feature 重新运行以获取详细信息,如何在使用 gradle 构建时查看 scala 功能警告?

scala - Deequ中的唯一性检查

java - 使用 DropWizard 提供数据库配置详细信息而不使用 config.yml?

java - Java代码注释中使用方括号的目的是什么?

java - tomcat spring项目上运行HotswapAgent的异常

java - scala/java 中的异常

scala - Deequ 检查的结果数据帧的列有何含义?

scala - 如何检查 DateType 列的值是否在指定日期范围内?