@PublicEvolving public class SchemaUtils extends Object
Schema to perform the ability of evolution.| 构造器和说明 |
|---|
SchemaUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Schema |
applySchemaChangeEvent(Schema schema,
SchemaChangeEvent event)
apply SchemaChangeEvent to the old schema and return the schema after changing.
|
static List<RecordData.FieldGetter> |
createFieldGetters(List<Column> columns)
create a list of
RecordData.FieldGetter from given Column to get Object from
RecordData. |
static List<RecordData.FieldGetter> |
createFieldGetters(Schema schema)
create a list of
RecordData.FieldGetter from given Schema to get Object from
RecordData. |
static int |
getNumericPrecision(DataType dataType)
已过时。
|
static Column |
inferWiderColumn(Column lColumn,
Column rColumn)
已过时。
Use
getLeastCommonType in SchemaMergingUtils instead. |
static Schema |
inferWiderSchema(List<Schema> schemas)
已过时。
Use
getCommonSchema in SchemaMergingUtils instead. |
static Schema |
inferWiderSchema(Schema lSchema,
Schema rSchema)
已过时。
Use
getLeastCommonSchema in SchemaMergingUtils instead. |
static DataType |
inferWiderType(DataType lType,
DataType rType)
已过时。
Use
getLeastCommonType in SchemaMergingUtils instead. |
static boolean |
isSchemaChangeEventRedundant(Schema currentSchema,
SchemaChangeEvent event)
This function checks if the given schema change event has been applied already.
|
static List<Object> |
restoreOriginalData(RecordData recordData,
List<RecordData.FieldGetter> fieldGetters)
Restore original data fields from RecordData structure.
|
static Optional<SchemaChangeEvent> |
transformSchemaChangeEvent(boolean hasAsterisk,
List<String> referencedColumns,
SchemaChangeEvent event)
This function determines if the given schema change event
event should be sent to
downstream based on if the given transform rule has asterisk, and what columns are
referenced. |
@CheckReturnValue public static List<RecordData.FieldGetter> createFieldGetters(Schema schema)
RecordData.FieldGetter from given Schema to get Object from
RecordData.@CheckReturnValue public static List<RecordData.FieldGetter> createFieldGetters(List<Column> columns)
RecordData.FieldGetter from given Column to get Object from
RecordData.@CheckReturnValue public static List<Object> restoreOriginalData(@Nullable RecordData recordData, List<RecordData.FieldGetter> fieldGetters)
@CheckReturnValue public static Schema applySchemaChangeEvent(Schema schema, SchemaChangeEvent event)
@CheckReturnValue public static Optional<SchemaChangeEvent> transformSchemaChangeEvent(boolean hasAsterisk, List<String> referencedColumns, SchemaChangeEvent event)
event should be sent to
downstream based on if the given transform rule has asterisk, and what columns are
referenced.
For example, if hasAsterisk is false, then all AddColumnEvent and DropColumnEvent should be ignored since asterisk-less transform should not emit schema
change events that change number of downstream columns.
Also, referencedColumns will be used to determine if the schema change event
affects any referenced columns, since if a column has been projected out of downstream, its
corresponding schema change events should not be emitted, either.
For the case when hasAsterisk is true, things will be cleaner since we don't have
to filter out any schema change events. All we need to do is to change AddColumnEvent's inserting position, and replacing `FIRST` / `LAST` with column-relative
position indicators. This is necessary since extra calculated columns might be added, and
`FIRST` / `LAST` position might differ.
public static boolean isSchemaChangeEventRedundant(@Nullable Schema currentSchema, SchemaChangeEvent event)
@Deprecated public static Schema inferWiderSchema(List<Schema> schemas)
getCommonSchema in SchemaMergingUtils instead.@Deprecated @VisibleForTesting public static Schema inferWiderSchema(@Nullable Schema lSchema, Schema rSchema)
getLeastCommonSchema in SchemaMergingUtils instead.@Deprecated @VisibleForTesting public static Column inferWiderColumn(Column lColumn, Column rColumn)
getLeastCommonType in SchemaMergingUtils instead.@Deprecated @VisibleForTesting public static DataType inferWiderType(DataType lType, DataType rType)
getLeastCommonType in SchemaMergingUtils instead.@Deprecated @VisibleForTesting public static int getNumericPrecision(DataType dataType)
Copyright © 2025 The Apache Software Foundation. All rights reserved.