Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-16749

[Go] Bug when converting from Arrow to Parquet from null array

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 9.0.0
    • 9.0.0
    • Go

    Description

      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:

       

      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)
      	}
      } 

      Attachments

        Issue Links

          Activity

            People

              alexandreyc Alexandre Crayssac
              alexandreyc Alexandre Crayssac
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h 20m
                  2h 20m