public class SchemaUtils
extends Object
| Modifier and Type | Method and Description |
|---|---|
static java.util.Map<String,Literal> |
casePreservingPartitionColNames(java.util.List<String> partitionColNames,
java.util.Map<String,Literal> partitionValues)
Convert the partition column names in
partitionValues map into the same case as the
column in the table metadata. |
static java.util.List<String> |
casePreservingPartitionColNames(StructType tableSchema,
java.util.List<String> partitionColumns)
Delta expects partition column names to be same case preserving as the name in the schema.
|
static int |
findColIndex(StructType schema,
String colName)
Search (case-insensitive) for the given
colName in the schema and return its
position in the schema. |
static void |
validatePartitionColumns(StructType schema,
java.util.List<String> partitionCols)
Verify the partition columns exists in the table schema and a supported data type for a
partition column.
|
static void |
validateSchema(StructType schema,
boolean isColumnMappingEnabled)
Validate the schema.
|
public static void validateSchema(StructType schema, boolean isColumnMappingEnabled)
schema - the schema to validateisColumnMappingEnabled - whether column mapping is enabled. When column mapping is
enabled, the column names in the schema can contain special characters that are allowed as
column names in the Parquet fileIllegalArgumentException - if the schema is invalidpublic static void validatePartitionColumns(StructType schema, java.util.List<String> partitionCols)
schema - partitionCols - public static java.util.List<String> casePreservingPartitionColNames(StructType tableSchema, java.util.List<String> partitionColumns)
This method expects the inputs are already validated (i.e. schema contains all the partition columns).
public static java.util.Map<String,Literal> casePreservingPartitionColNames(java.util.List<String> partitionColNames, java.util.Map<String,Literal> partitionValues)
partitionValues map into the same case as the
column in the table metadata. Delta expects the partition column names to preserve the case
same as the table schema.partitionColNames - List of partition columns in the table metadata. The names preserve
the case as given by the connector when the table is created.partitionValues - Map of partition column name to partition value. Convert the partition
column name to be same case preserving name as its equivalent column in the partitionColName. Column name comparison is case-insensitive.partitionValues map with names case preserved.public static int findColIndex(StructType schema, String colName)
colName in the schema and return its
position in the schema.schema - StructTypecolName - Name of the column whose index is needed.