|
@ -7,9 +7,9 @@ import ( |
|
|
|
|
|
|
|
|
type ParquetLevels struct { |
|
|
type ParquetLevels struct { |
|
|
startColumnIndex int |
|
|
startColumnIndex int |
|
|
endColumnIndex int |
|
|
endColumnIndex int |
|
|
definitionDepth int |
|
|
definitionDepth int |
|
|
levels map[string]*ParquetLevels |
|
|
levels map[string]*ParquetLevels |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func ToParquetLevels(recordType *schema_pb.RecordType) (*ParquetLevels, error) { |
|
|
func ToParquetLevels(recordType *schema_pb.RecordType) (*ParquetLevels, error) { |
|
@ -19,7 +19,7 @@ func ToParquetLevels(recordType *schema_pb.RecordType) (*ParquetLevels, error) { |
|
|
func toFieldTypeLevels(fieldType *schema_pb.Type, startColumnIndex, definitionDepth int) (*ParquetLevels, error) { |
|
|
func toFieldTypeLevels(fieldType *schema_pb.Type, startColumnIndex, definitionDepth int) (*ParquetLevels, error) { |
|
|
switch fieldType.Kind.(type) { |
|
|
switch fieldType.Kind.(type) { |
|
|
case *schema_pb.Type_ScalarType: |
|
|
case *schema_pb.Type_ScalarType: |
|
|
return toFieldTypeScalarLevels(fieldType.GetScalarType(), startColumnIndex, definitionDepth) |
|
|
return toFieldTypeScalarLevels(fieldType.GetScalarType(), startColumnIndex, definitionDepth) |
|
|
case *schema_pb.Type_RecordType: |
|
|
case *schema_pb.Type_RecordType: |
|
|
return toRecordTypeLevels(fieldType.GetRecordType(), startColumnIndex, definitionDepth) |
|
|
return toRecordTypeLevels(fieldType.GetRecordType(), startColumnIndex, definitionDepth) |
|
|
case *schema_pb.Type_ListType: |
|
|
case *schema_pb.Type_ListType: |
|
@ -35,15 +35,15 @@ func toFieldTypeListLevels(listType *schema_pb.ListType, startColumnIndex, defin |
|
|
func toFieldTypeScalarLevels(scalarType schema_pb.ScalarType, startColumnIndex, definitionDepth int) (*ParquetLevels, error) { |
|
|
func toFieldTypeScalarLevels(scalarType schema_pb.ScalarType, startColumnIndex, definitionDepth int) (*ParquetLevels, error) { |
|
|
return &ParquetLevels{ |
|
|
return &ParquetLevels{ |
|
|
startColumnIndex: startColumnIndex, |
|
|
startColumnIndex: startColumnIndex, |
|
|
endColumnIndex: startColumnIndex + 1, |
|
|
endColumnIndex: startColumnIndex + 1, |
|
|
definitionDepth: definitionDepth, |
|
|
definitionDepth: definitionDepth, |
|
|
}, nil |
|
|
}, nil |
|
|
} |
|
|
} |
|
|
func toRecordTypeLevels(recordType *schema_pb.RecordType, startColumnIndex, definitionDepth int) (*ParquetLevels, error) { |
|
|
func toRecordTypeLevels(recordType *schema_pb.RecordType, startColumnIndex, definitionDepth int) (*ParquetLevels, error) { |
|
|
recordTypeLevels := &ParquetLevels{ |
|
|
recordTypeLevels := &ParquetLevels{ |
|
|
startColumnIndex: startColumnIndex, |
|
|
startColumnIndex: startColumnIndex, |
|
|
definitionDepth: definitionDepth, |
|
|
definitionDepth: definitionDepth, |
|
|
levels: make(map[string]*ParquetLevels), |
|
|
levels: make(map[string]*ParquetLevels), |
|
|
} |
|
|
} |
|
|
for _, field := range recordType.Fields { |
|
|
for _, field := range recordType.Fields { |
|
|
fieldTypeLevels, err := toFieldTypeLevels(field.Type, startColumnIndex, definitionDepth+1) |
|
|
fieldTypeLevels, err := toFieldTypeLevels(field.Type, startColumnIndex, definitionDepth+1) |
|
|
xxxxxxxxxx