Package cern.nxcals.api.extraction.data
Class ExtractionUtils
java.lang.Object
cern.nxcals.api.extraction.data.ExtractionUtils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> createEmptyDataFrame(org.apache.spark.sql.SparkSession session, Collection<cern.nxcals.common.domain.ColumnMapping> mappings) static List<org.apache.avro.Schema.Field> extractSchemaFields(String schemaContent) static org.apache.spark.sql.types.DataTypegetDataTypeFor(org.apache.avro.Schema schema) static StringgetHbaseTypeNameFor(org.apache.avro.Schema schema) static org.apache.spark.sql.types.StructTypegetStructSchemaFor(Collection<cern.nxcals.common.domain.ColumnMapping> fields) static StringgetTimestampFieldName(@NonNull SystemSpec systemData) groupVariablesByType(org.apache.spark.sql.SparkSession spark, Set<Variable> variables, TimeWindow timeWindow) Groups variables by the single SparkDataTypethat covers all their schemas over the time window.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.
-
Field Details
-
STRING_SCHEMA
public static final org.apache.avro.Schema STRING_SCHEMA
-
-
Method Details
-
getTimestampFieldName
-
extractSchemaFields
-
getDataTypeFor
public static org.apache.spark.sql.types.DataType getDataTypeFor(org.apache.avro.Schema schema) -
getHbaseTypeNameFor
-
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, groupVariablesByTypeAndTimeWindowSet<Variable>>> (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 grouptimeWindow- 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 SparkDataTypethat 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.
-