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

Cannot have a field with all nil values #522

Closed
hangxie opened this issue Feb 12, 2023 · 1 comment
Closed

Cannot have a field with all nil values #522

hangxie opened this issue Feb 12, 2023 · 1 comment

Comments

@hangxie
Copy link
Contributor

hangxie commented Feb 12, 2023

It does not work if a nullable field has null value in all rows, sample code:

package main

import (
	"fmt"

	"github.com/xitongsys/parquet-go-source/local"
	"github.com/xitongsys/parquet-go/writer"
)

type AllTypes struct {
	f1 string  `parquet:"name=f1, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	f2 *string `parquet:"name=f2, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
}

func main() {
	fw, err := local.NewLocalFileWriter("all-nil.parquet")
	if err != nil {
		fmt.Println("Can't create local file", err)
		return
	}

	pw, err := writer.NewParquetWriter(fw, new(AllTypes), 4)
	if err != nil {
		fmt.Println("Can't create parquet writer", err)
		return
	}

	value := AllTypes{
		f1: "f1",
		f2: nil,
	}
	if err = pw.Write(value); err != nil {
		fmt.Println("Write error", err)
	}
	if err = pw.WriteStop(); err != nil {
		fmt.Println("WriteStop error", err)
		return
	}
	fw.Close()
}

reports:

WriteStop error interface conversion: interface {} is nil, not string

I would suggest to have a consideration of #457 which will make debug a lot easier, error messages like above does not offer any helpful information.

@hangxie
Copy link
Contributor Author

hangxie commented Feb 12, 2023

It turned out to be struct definition need to be uppercased, sorry for false alarm.

@hangxie hangxie closed this as completed Feb 12, 2023
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