You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Alexandre Crayssac (Jira)" <ji...@apache.org> on 2022/06/03 12:58:00 UTC

[jira] [Created] (ARROW-16749) [Go] Bug when converting from Arrow to Parquet from null array

Alexandre Crayssac created ARROW-16749:
------------------------------------------

             Summary: [Go] Bug when converting from Arrow to Parquet from null array
                 Key: ARROW-16749
                 URL: https://issues.apache.org/jira/browse/ARROW-16749
             Project: Apache Arrow
          Issue Type: Bug
          Components: Go
    Affects Versions: 9.0.0
            Reporter: Alexandre Crayssac
            Assignee: Alexandre Crayssac


Hello world,

When converting from Arrow to Parquet it looks like there is a bug with arrays of type {{{}arrow.NULL{}}}. Here is a snippet of code to reproduce the bug:

 
{code:java}
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/apache/arrow/go/v9/arrow"
	"github.com/apache/arrow/go/v9/arrow/array"
	"github.com/apache/arrow/go/v9/arrow/memory"
	"github.com/apache/arrow/go/v9/parquet/pqarrow"
)

const n = 10

func run() error {
	schema := arrow.NewSchema(
		[]arrow.Field{
			{Name: "f1", Type: arrow.Null, Nullable: true},
		},
		nil,
	)

	rb := array.NewRecordBuilder(memory.DefaultAllocator, schema)
	defer rb.Release()

	for i := 0; i < n; i++ {
		rb.Field(0).(*array.NullBuilder).AppendNull()
	}

	rec := rb.NewRecord()
	defer rec.Release()

	for i, col := range rec.Columns() {
		fmt.Printf("column[%d] %q: %v\n", i, rec.ColumnName(i), col)
	}

	f, err := os.Create("output.parquet")
	if err != nil {
		return err
	}
	defer f.Close()

	w, err := pqarrow.NewFileWriter(rec.Schema(), f, nil, pqarrow.DefaultWriterProps())
	if err != nil {
		return err
	}
	defer w.Close()

	err = w.Write(rec)
	if err != nil {
		return err
	}

	return nil
}

func main() {
	if err := run(); err != nil {
		log.Fatal(err)
	}
} {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)