override def deserialize()

in src/main/scala/com/amazon/deequ/repository/AnalysisResultSerde.scala [370:487]


  override def deserialize(jsonElement: JsonElement, t: Type,
    context: JsonDeserializationContext): Analyzer[State[_], Metric[_]] = {

    val json = jsonElement.getAsJsonObject

    val analyzer = json.get(ANALYZER_NAME_FIELD).getAsString match {

      case "Size" =>
        Size(getOptionalWhereParam(json))

      case "Completeness" =>
        Completeness(json.get(COLUMN_FIELD).getAsString, getOptionalWhereParam(json))

      case "Compliance" =>
        Compliance(
          json.get("instance").getAsString,
          json.get("predicate").getAsString,
          getOptionalWhereParam(json))

      case "PatternMatch" =>
        PatternMatch(
          json.get(COLUMN_FIELD).getAsString,
          json.get("pattern").getAsString.r,
          getOptionalWhereParam(json))

      case "Sum" =>
        Sum(
          json.get(COLUMN_FIELD).getAsString,
          getOptionalWhereParam(json))

      case "Mean" =>
        Mean(
          json.get(COLUMN_FIELD).getAsString,
          getOptionalWhereParam(json))

      case "Minimum" =>
        Minimum(
          json.get(COLUMN_FIELD).getAsString,
          getOptionalWhereParam(json))

      case "Maximum" =>
        Maximum(
          json.get(COLUMN_FIELD).getAsString,
          getOptionalWhereParam(json))

      case "CountDistinct" =>
        CountDistinct(getColumnsAsSeq(context, json))

      case "Distinctness" =>
        Distinctness(getColumnsAsSeq(context, json))

      case "Entropy" =>
        Entropy(json.get(COLUMN_FIELD).getAsString)

      case "MutualInformation" =>
        MutualInformation(getColumnsAsSeq(context, json))

      case "UniqueValueRatio" =>
        UniqueValueRatio(getColumnsAsSeq(context, json))

      case "Uniqueness" =>
        Uniqueness(getColumnsAsSeq(context, json))

      case "Histogram" =>
        Histogram(
          json.get(COLUMN_FIELD).getAsString,
          None,
          json.get("maxDetailBins").getAsInt)

      case "DataType" =>
        DataType(
          json.get(COLUMN_FIELD).getAsString,
          getOptionalWhereParam(json))

      case "ApproxCountDistinct" =>
        ApproxCountDistinct(
          json.get(COLUMN_FIELD).getAsString,
          getOptionalWhereParam(json))

      case "Correlation" =>
        Correlation(
          json.get("firstColumn").getAsString,
          json.get("secondColumn").getAsString,
          getOptionalWhereParam(json))

      case "StandardDeviation" =>
        StandardDeviation(
          json.get(COLUMN_FIELD).getAsString,
          getOptionalWhereParam(json))

      case "ApproxQuantile" =>
        val column = json.get(COLUMN_FIELD).getAsString
        val quantile = json.get("quantile").getAsDouble
        val relativeError = json.get("relativeError").getAsDouble
        ApproxQuantile(column, quantile, relativeError)

      case "ApproxQuantiles" =>
        val column = json.get(COLUMN_FIELD).getAsString
        val quantile = json.get("quantiles").getAsString.split(",").map { _.toDouble }
        val relativeError = json.get("relativeError").getAsDouble
        ApproxQuantiles(column, quantile, relativeError)

      case "MinLength" =>
        MinLength(
          json.get(COLUMN_FIELD).getAsString,
          getOptionalWhereParam(json))

      case "MaxLength" =>
        MaxLength(
          json.get(COLUMN_FIELD).getAsString,
          getOptionalWhereParam(json))

      case analyzerName =>
        throw new IllegalArgumentException(s"Unable to deserialize analyzer $analyzerName.")
    }

    analyzer.asInstanceOf[Analyzer[State[_], Metric[_]]]
  }