Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
loicalleyne committed Nov 5, 2024
1 parent fa513a1 commit 278bcc8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,20 @@ var jsonS1 string = `{
"timefield":"01:02:03"
}`
u, _ := bodkin.NewBodkin(jsonS1, bodkin.WithInferTimeUnits(), bodkin.WithTypeConversion())
s, err := u.OriginSchema()
fmt.Printf("original input %v\nerrors:\n%v\n", s.String(), err)
s, _ := u.OriginSchema()
fmt.Printf("original input %v\n", s.String())
for _, e := range u.Err() {
fmt.Printf("%v : [%s]\n", e.Issue, e.Dotpath)
}
// original input schema:
// fields: 5
// - results: type=list<item: struct<id: float64>, nullable>, nullable
// - datefield: type=date32, nullable
// - timefield: type=time64[ns], nullable
// - count: type=float64, nullable
// - next: type=utf8, nullable
// errors:
// could not determine type of unpopulated field : [previous]
// could not determine element type of empty array : [arrayscalar]
// could not determine type of unpopulated field : [$previous]
// could not determine element type of empty array : [$arrayscalar]
```

Provide some more structured data and print out the new merged schema and the list of changes
Expand Down Expand Up @@ -109,28 +111,24 @@ Also works with Go structs
}
e, _ := bodkin.NewBodkin(stu, bodkin.WithInferTimeUnits(), bodkin.WithTypeConversion())
sc, err := e.OriginSchema()
fmt.Printf("original input %v\nerrors:\n%v\n", sc.String(), err)
fmt.Printf("original input %v\n", sc.String())
// original input schema:
// fields: 5
// - ID: type=int64, nullable
// - Day: type=int32, nullable
// - School: type=struct<Name: utf8, Address: struct<Street: utf8, City: utf8, Region: utf8, Country: utf8>>, nullable
// - Name: type=utf8, nullable
// - Age: type=int32, nullable
// errors:
// <nil>
e.Unify(sch)
sc, err = e.OriginSchema()
fmt.Printf("unified %v\nerrors:\n%v\n", sc.String(), err)
fmt.Printf("unified %v\n", sc.String())
// unified schema:
// fields: 5
// - ID: type=int64, nullable
// - Day: type=int32, nullable
// - School: type=struct<Name: utf8, Address: struct<Street: utf8, City: utf8, Region: utf8, Country: utf8>>, nullable
// - Name: type=utf8, nullable
// - Age: type=int32, nullable
// errors:
// <nil>
```

Use the generated Arrow schema with Arrow's built-in JSON reader to decode JSON data into Arrow records
Expand Down
6 changes: 5 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ func main() {
fmt.Println(err)
}
fmt.Println(u.Paths())
fmt.Println(u.Err())
for _, e := range u.Err() {
fmt.Printf("%v : [%s]\n", e.Issue, e.Dotpath)
}
fmt.Println(u.Changes())

}

var jsonS1 string = `{
Expand Down

0 comments on commit 278bcc8

Please sign in to comment.