Skip to content

Commit dd65b93

Browse files
authored
remove sio/parquetio.TopLevelFieldNames in favor of Type (#6290)
The Type function in the same package returns a super.Type containing the same information.
1 parent 6d4d27a commit dd65b93

File tree

2 files changed

+8
-25
lines changed

2 files changed

+8
-25
lines changed

compiler/semantic/op.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,15 @@ func (t *translator) fileScanColumns(op *sem.FileScan) ([]string, bool) {
161161
return nil, false
162162
}
163163
defer sr.Close()
164-
cols, err := parquetio.TopLevelFieldNames(sr)
165164
op.Type = parquetio.Type(t.sctx, sr)
166-
return cols, err == nil
165+
if op.Type == nil {
166+
return nil, false
167+
}
168+
var cols []string
169+
for _, f := range op.Type.(*super.TypeRecord).Fields {
170+
cols = append(cols, f.Name)
171+
}
172+
return cols, true
167173
}
168174

169175
func (t *translator) semFromExpr(entity *ast.ExprEntity, args []ast.OpArg, seq sem.Seq) (sem.Seq, string) {

sio/parquetio/reader.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,3 @@ func Type(sctx *super.Context, r io.Reader) super.Type {
6565
}
6666
return nil
6767
}
68-
69-
func TopLevelFieldNames(r io.Reader) ([]string, error) {
70-
ras, ok := r.(parquet.ReaderAtSeeker)
71-
if !ok {
72-
return nil, errors.New("reader cannot seek")
73-
}
74-
pr, err := file.NewParquetReader(ras)
75-
if err != nil {
76-
return nil, err
77-
}
78-
var cols []string
79-
var last string
80-
schema := pr.MetaData().Schema
81-
for i := range schema.NumColumns() {
82-
name := schema.Column(i).ColumnPath()[0]
83-
if name == last {
84-
continue
85-
}
86-
cols = append(cols, name)
87-
last = name
88-
}
89-
return cols, nil
90-
}

0 commit comments

Comments
 (0)