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

[Go] Incorrect Printing for String Arrays with Offsets

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • None
    • 0.14.0
    • Go

    Description

      If an additional string field is added to the Table Example (https://github.com/apache/arrow/blob/master/go/arrow/example_test.go#L495-L546) the Table Reader outputs unexpected results.

      Modified Table example:

      pool := memory.NewGoAllocator()
      
      schema := arrow.NewSchema(
      []arrow.Field{
      arrow.Field{Name: "f1-i32", Type: arrow.PrimitiveTypes.Int32},
      arrow.Field{Name: "f2-f64", Type: arrow.PrimitiveTypes.Float64},
      arrow.Field{Name: "string", Type: arrow.BinaryTypes.String},
      },
      nil,
      )
      
      b := array.NewRecordBuilder(pool, schema)
      defer b.Release()
      
      b.Field(0).(*array.Int32Builder).AppendValues([]int32{1, 2, 3, 4, 5, 6}, nil)
      b.Field(0).(*array.Int32Builder).AppendValues([]int32{7, 8, 9, 10}, []bool{true, true, false, true})
      b.Field(1).(*array.Float64Builder).AppendValues([]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, nil)
      b.Field(2).(*array.StringBuilder).AppendValues([]string{
      "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
      }, nil)
      
      rec1 := b.NewRecord()
      defer rec1.Release()
      
      b.Field(0).(*array.Int32Builder).AppendValues([]int32{11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, nil)
      b.Field(1).(*array.Float64Builder).AppendValues([]float64{11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, nil)
      b.Field(2).(*array.StringBuilder).AppendValues([]string{
      "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty",
      }, nil)
      
      rec2 := b.NewRecord()
      defer rec2.Release()
      
      tbl := array.NewTableFromRecords(schema, []array.Record{rec1, rec2})
      defer tbl.Release()
      
      tr := array.NewTableReader(tbl, 2)
      defer tr.Release()
      
      n := 0
      for tr.Next() {
      rec := tr.Record()
      for i, col := range rec.Columns() {
      fmt.Printf("rec[%d][%q]: %v\n", n, rec.ColumnName(i), col)
      }
      n++
      }
      

       

      output:

      rec[0]["f1-i32"]: [1 2]
      rec[0]["f2-f64"]: [1 2]
      rec[0]["string"]: ["one" "two"]
      rec[1]["f1-i32"]: [3 4]
      rec[1]["f2-f64"]: [3 4]
      rec[1]["string"]: ["one" "two"]
      rec[2]["f1-i32"]: [5 6]
      rec[2]["f2-f64"]: [5 6]
      rec[2]["string"]: ["one" "two"]
      rec[3]["f1-i32"]: [7 8]
      rec[3]["f2-f64"]: [7 8]
      rec[3]["string"]: ["one" "two"]
      rec[4]["f1-i32"]: [(null) 10]
      rec[4]["f2-f64"]: [9 10]
      rec[4]["string"]: ["one" "two"]
      rec[5]["f1-i32"]: [11 12]
      rec[5]["f2-f64"]: [11 12]
      rec[5]["string"]: ["eleven" "twelve"]
      rec[6]["f1-i32"]: [13 14]
      rec[6]["f2-f64"]: [13 14]
      rec[6]["string"]: ["eleven" "twelve"]
      rec[7]["f1-i32"]: [15 16]
      rec[7]["f2-f64"]: [15 16]
      rec[7]["string"]: ["eleven" "twelve"]
      rec[8]["f1-i32"]: [17 18]
      rec[8]["f2-f64"]: [17 18]
      rec[8]["string"]: ["eleven" "twelve"]
      rec[9]["f1-i32"]: [19 20]
      rec[9]["f2-f64"]: [19 20]
      rec[9]["string"]: ["eleven" "twelve"]
       
      

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            poopoothegorilla James Walker
            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
                2h