public class SchemaEvolutionUtil extends Object
Constructor and Description |
---|
SchemaEvolutionUtil() |
Modifier and Type | Method and Description |
---|---|
static List<Predicate> |
createDataFilters(List<DataField> tableFields,
List<DataField> dataFields,
List<Predicate> filters)
Create predicate list from data fields.
|
static int[][] |
createDataProjection(List<DataField> tableFields,
List<DataField> dataFields,
int[][] tableProjection)
Create data projection from table projection.
|
static IndexCastMapping |
createIndexCastMapping(int[] tableProjection,
List<DataField> tableFields,
int[] dataProjection,
List<DataField> dataFields)
Create index mapping from table projection to underlying data projection.
|
static IndexCastMapping |
createIndexCastMapping(int[] tableProjection,
List<DataField> tableKeyFields,
List<DataField> tableValueFields,
int[] dataProjection,
List<DataField> dataKeyFields,
List<DataField> dataValueFields)
Create index mapping from table projection to data with key and value fields.
|
static IndexCastMapping |
createIndexCastMapping(List<DataField> tableFields,
List<DataField> dataFields)
Create index mapping from table fields to underlying data fields.
|
static int[] |
createIndexMapping(List<DataField> tableFields,
List<DataField> dataFields)
Create index mapping from table fields to underlying data fields.
|
@Nullable public static int[] createIndexMapping(List<DataField> tableFields, List<DataField> dataFields)
We can get the index mapping [0, -1, 1], in which 0 is the index of table field 1->c in data fields, -1 is the index of 6->b in data fields and 1 is the index of 3->a in data fields.
tableFields
- the fields of tabledataFields
- the fields of underlying datapublic static IndexCastMapping createIndexCastMapping(int[] tableProjection, List<DataField> tableFields, int[] dataProjection, List<DataField> dataFields)
The table and data top projections are as follows
We can first get fields list for table and data projections from their fields as follows
Then create index mapping based on the fields list and create cast mapping based on index mapping.
/// TODO should support nest index mapping when nest schema evolution is supported.
tableProjection
- the table projectiontableFields
- the fields in tabledataProjection
- the underlying data projectiondataFields
- the fields in underlying datapublic static IndexCastMapping createIndexCastMapping(List<DataField> tableFields, List<DataField> dataFields)
public static IndexCastMapping createIndexCastMapping(int[] tableProjection, List<DataField> tableKeyFields, List<DataField> tableValueFields, int[] dataProjection, List<DataField> dataKeyFields, List<DataField> dataValueFields)
First we will get max key id from table and data fields which is 6, then create table and data fields on it
Finally we can create index mapping with table/data projections and fields, and create cast mapping based on index mapping.
/// TODO should support nest index mapping when nest schema evolution is supported.
tableProjection
- the table projectiontableKeyFields
- the table key fieldstableValueFields
- the table value fieldsdataProjection
- the data projectiondataKeyFields
- the data key fieldsdataValueFields
- the data value fieldspublic static int[][] createDataProjection(List<DataField> tableFields, List<DataField> dataFields, int[][] tableProjection)
When we project 1->c, 6->b, 3->a from table fields, the table projection is [[0], [4], [1]], in which 0 is the index of field 1->c, 4 is the index of field 6->b, 1 is the index of field 3->a in table fields. We need to create data projection from [[0], [4], [1]] as follows:
The we can create table projection as follows: [[0], [-1], [2]], in which 0, -1 and 2 are the index of fields [1->c, 6->b, 3->a] in data fields. When we project column from underlying data, we need to specify the field index and name. It is difficult to assign a proper field id and name for 6->b in data projection and add it to data fields, and we can't use 6->b directly because the field index of b in underlying is 2. We can remove the -1 field index in data projection, then the result data projection is: [[0], [2]].
We create InternalRow
for 1->a, 3->c after projecting them from underlying data,
then create ProjectedRow
with a index mapping and return null for 6->b in table
fields.
tableFields
- the fields of tabledataFields
- the fields of underlying datatableProjection
- the projection of table@Nullable public static List<Predicate> createDataFilters(List<DataField> tableFields, List<DataField> dataFields, List<Predicate> filters)
tableFields
- the table fieldsdataFields
- the underlying data fieldsfilters
- the filtersCopyright © 2023–2024 The Apache Software Foundation. All rights reserved.