Skip to content

Commit

Permalink
remove dup handler
Browse files Browse the repository at this point in the history
  • Loading branch information
scottlepp committed Feb 26, 2024
1 parent 0b42330 commit 5cf94b5
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions duck/data/parquet.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ func ToParquet(frames []*data.Frame, chunk int) (map[string]string, error) {
// }
// }
// }
handleDuplicateFields(frames)
labelsToFields(frames)

for _, frameList := range frameIndex {

labelsToFields(frameList)

dir, err := os.MkdirTemp("", "duck")
if err != nil {
return nil, err
Expand Down Expand Up @@ -255,27 +255,3 @@ func newField(name string, val string, size int) *data.Field {
}
return newField
}

// wide frames - duplicate fields with different labels
// use the labels in the field name to avoid create table error with duplicate field
func handleDuplicateFields(frames []*data.Frame) {
for _, f := range frames {
dups := map[string]bool{}
fieldIndex := map[string]*data.Field{}
for _, fld := range f.Fields {
if fieldIndex[fld.Name] != nil {
dups[fld.Name] = true
}
fieldIndex[fld.Name] = fld
}
for _, fld := range f.Fields {
if dups[fld.Name] {
if len(fld.Labels) > 0 {
lbls := fld.Labels.String()
fld.Name = fmt.Sprintf("%s %s", fld.Name, lbls)
fld.Labels = nil
}
}
}
}
}

0 comments on commit 5cf94b5

Please sign in to comment.