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.
|
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 schema