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

[JS] Field Metadata Not Read

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.13.0
    • 0.14.0
    • JavaScript
    • Mac OSX 10.14, Chrome 74

    Description

      Field metadata is not read when using @apache-arrow/ts@0.13.0. Example below also uses pyarrow==0.13.0

      Steps to reproduce:

      Adding metadata:

      toarrow.py
      import pyarrow as pa
      import pandas as pd
      
      source = "sample.csv"
      output = "sample.arrow"
      df = pd.read_csv(source)
      table = pa.Table.from_pandas(df)
      schema = pa.schema([
       column.field.add_metadata({"foo": "bar"}))
       for column
       in table.columns
      ])
      writer = pa.RecordBatchFileWriter(output, schema)
      writer.write(table)
      writer.close()
      

      Reading field metadata using pyarrow:

      readarrow.py
      source = "sample.arrow"
      field = "foo"
      reader = pa.RecordBatchFileReader(source)
      reader.schema.field_by_name(field).metadata # Correctly shows `{"foo": "bar"}`
      

      Reading field metadata using @apache-arrow/ts:

      toarrow.ts
      import { Table, Field, Type } from "@apache-arrow/ts";
      
      const url = "https://example.com/sample.arrow";
      const buf = await fetch(url).then(res => res.arrayBuffer());
      const table = Table.from([new Uint8Array(buf)]);
      for (let field of table.schema.fields) {
       field.metadata; // Incorrectly shows an empty map
      }
      

      Attachments

        Activity

          People

            paul.e.taylor Paul Taylor
            treyhakanson Trey Hakanson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: