Class ExtractionUtils

java.lang.Object
cern.nxcals.api.extraction.data.ExtractionUtils

public final class ExtractionUtils extends Object
  • Field Details

    • STRING_SCHEMA

      public static final org.apache.avro.Schema STRING_SCHEMA
  • Method Details

    • getTimestampFieldName

      public static String getTimestampFieldName(@NonNull @NonNull SystemSpec systemData)
    • extractSchemaFields

      public static List<org.apache.avro.Schema.Field> extractSchemaFields(String schemaContent)
    • getDataTypeFor

      public static org.apache.spark.sql.types.DataType getDataTypeFor(org.apache.avro.Schema schema)
    • getHbaseTypeNameFor

      public static String getHbaseTypeNameFor(org.apache.avro.Schema schema)
    • getStructSchemaFor

      public static org.apache.spark.sql.types.StructType getStructSchemaFor(Collection<cern.nxcals.common.domain.ColumnMapping> fields)
    • createEmptyDataFrame

      public static org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> createEmptyDataFrame(org.apache.spark.sql.SparkSession session, Collection<cern.nxcals.common.domain.ColumnMapping> mappings)
    • groupVariablesByTypeAndTimeWindow

      public static Map<org.apache.spark.sql.types.DataType,Map<TimeWindow,Set<Variable>>> groupVariablesByTypeAndTimeWindow(Set<Variable> variables, TimeWindow timeWindow)
      Groups variables by their Spark DataType and the TimeWindow during which that type is active. Variables with schema evolution (e.g. BOOLEAN in the first half of a year, DOUBLE in the second half) are correctly split across multiple (DataType, TimeWindow) groups rather than being dropped or crashing the call. The caller should iterate over the outer map and submit one DataQuery per (DataType, TimeWindow) entry, using the time window from the inner map as the query range.
      Parameters:
      variables - variables to group
      timeWindow - time window for which schemas are resolved
      Returns:
      map of DataType to a map of TimeWindow to the set of variables that have that type during that window.
    • groupVariablesByType

      public static Map<org.apache.spark.sql.types.DataType,Set<Variable>> groupVariablesByType(org.apache.spark.sql.SparkSession spark, Set<Variable> variables, TimeWindow timeWindow)
      Groups variables by the single Spark DataType that covers all their schemas over the time window. Variables with incompatible schema evolution (e.g. BOOLEAN to DOUBLE) are skipped with a warning. This method is used in pivot. It will throw an exception if the types within one Variable and multi VariableConfigs are not compatible.