public class SchemaUtils
extends Object
Constructor and Description |
---|
SchemaUtils() |
Modifier and Type | Method and Description |
---|---|
static StructType |
appendColumn(StructType schema,
String colName,
DataType dataType,
boolean nullable)
Appends a new column to the input schema.
|
static StructType |
appendColumn(StructType schema,
StructField col)
Appends a new column to the input schema.
|
static void |
checkColumnType(StructType schema,
String colName,
DataType dataType,
String msg)
Check whether the given schema contains a column of the required data type.
|
static void |
checkColumnTypes(StructType schema,
String colName,
scala.collection.Seq<DataType> dataTypes,
String msg)
Check whether the given schema contains a column of one of the require data types.
|
static void |
checkNumericType(StructType schema,
String colName,
String msg)
Check whether the given schema contains a column of the numeric data type.
|
static StructType |
updateAttributeGroupSize(StructType schema,
String colName,
int size)
Update the size of a ML Vector column.
|
static StructType |
updateField(StructType schema,
StructField field,
boolean overwriteMetadata)
Update the metadata of an existing column.
|
static StructType |
updateNumeric(StructType schema,
String colName)
Update the numeric meta of an existing column.
|
static StructType |
updateNumValues(StructType schema,
String colName,
int numValues)
Update the number of values of an existing column.
|
static void |
validateVectorCompatibleColumn(StructType schema,
String colName)
Check whether the given column in the schema is one of the supporting vector type: Vector,
Array[Float].
|
public static void checkColumnType(StructType schema, String colName, DataType dataType, String msg)
colName
- column namedataType
- required column data typeschema
- (undocumented)msg
- (undocumented)public static void checkColumnTypes(StructType schema, String colName, scala.collection.Seq<DataType> dataTypes, String msg)
colName
- column namedataTypes
- required column data typesschema
- (undocumented)msg
- (undocumented)public static void checkNumericType(StructType schema, String colName, String msg)
colName
- column nameschema
- (undocumented)msg
- (undocumented)public static StructType appendColumn(StructType schema, String colName, DataType dataType, boolean nullable)
schema
- input schemacolName
- new column name. If this column name is an empty string "", this method returns
the input schema unchanged. This allows users to disable output columns.dataType
- new column data typenullable
- (undocumented)public static StructType appendColumn(StructType schema, StructField col)
schema
- input schemacol
- New column schemapublic static StructType updateAttributeGroupSize(StructType schema, String colName, int size)
schema
- input schemacolName
- column namesize
- number of featurespublic static StructType updateNumValues(StructType schema, String colName, int numValues)
schema
- input schemacolName
- column namenumValues
- number of values.public static StructType updateNumeric(StructType schema, String colName)
schema
- input schemacolName
- column namepublic static StructType updateField(StructType schema, StructField field, boolean overwriteMetadata)
schema
- input schemafield
- struct fieldoverwriteMetadata
- whether to overwrite the metadata. If true, the metadata in the
schema will be overwritten. If false, the metadata in field
and schema
will be merged to generate output metadata.public static void validateVectorCompatibleColumn(StructType schema, String colName)
schema
- input schemacolName
- column name