Skip to content

Commit

Permalink
avoid complicated JQ query if pargo-prefix is not specified in cat co…
Browse files Browse the repository at this point in the history
…mmand
  • Loading branch information
hangxie committed Dec 26, 2024
1 parent 409ff06 commit 3ab395f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ func (c CatCmd) outputRows(fileReader *reader.ParquetReader) error {
}

// handle PARGO_PREFIX_ with jq jq
queryString := fmt.Sprintf(`walk(if type == "object" then with_entries(.key = (.key | sub("%s"; ""))) else . end)`, c.PargoPrefix)
queryString := "."
if c.PargoPrefix != "" {
queryString = fmt.Sprintf(`walk(if type == "object" then with_entries(.key = (.key | sub("%s"; ""))) else . end)`, c.PargoPrefix)
}
jq, err := gojq.Parse(queryString)
if err != nil {
return fmt.Errorf("unable to use [%s] as prefix: %w", c.PargoPrefix, err)
Expand Down

0 comments on commit 3ab395f

Please sign in to comment.