Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Can't write OCR when schema have union type #284

Open
florentsorel opened this issue Apr 17, 2024 · 0 comments
Open

[Bug] Can't write OCR when schema have union type #284

florentsorel opened this issue Apr 17, 2024 · 0 comments

Comments

@florentsorel
Copy link

There is an issue when writing OCR with a schema containing union type.

I've changed your example like this:

avroSchema := `
{
  "type": "record",
  "name": "test_schema",
  "fields": [
    {
      "name": "time",
      "type": "long"
    },
    {
      "name": "customer",
      "type": ["null", "string"],
      "default": null
    }
  ]
}`

// Writing OCF data
var ocfFileContents bytes.Buffer
writer, err := goavro.NewOCFWriter(goavro.OCFConfig{
	W:      &ocfFileContents,
	Schema: avroSchema,
})
if err != nil {
	fmt.Println(err)
}
err = writer.Append([]map[string]interface{}{
	{
		"time":     1617104831727,
		"customer": "customer1",
	},
	{
		"time":     1717104831727,
		"customer": "customer2",
	},
})
fmt.Println("ocfFileContents", ocfFileContents.String())

The output doesn't contains data.
image

But if I set nil for customer the data are written.

err = writer.Append([]map[string]interface{}{
	{
		"time":     1617104831727,
		"customer": nil,
	},
	{
		"time":     1717104831727,
		"customer": nil,
	},
})

image

@florentsorel florentsorel changed the title Can't write OCR when schema have union type [Bug] Can't write OCR when schema have union type Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant