Open buzzware opened 23 hours ago
yes
0.16.0
MacOS 14.7.1
18.19.1
Fails to read javascript object columns
using jest
import pl from 'nodejs-polars'; const eventData = [ {id: 1, name: 'one', attributes: {x: 700, colour: 'black'}}, {id: 2, name: 'two', attributes: {x: 800, colour: 'blue'}}, {id: 3, name: 'three', attributes: {x: 100, colour: 'red'}} ] const eventDf = pl.DataFrame(eventData); test('get nested object column', async () => { expect(eventDf.getColumn('name').toArray()).toEqual(eventData.map(e=>e['name'])); expect(eventDf.getColumn('attributes').toArray()).toMatchObject(eventData.map(e=>e['attributes'])); });
Error: expect(received).toMatchObject(expected) - Expected - 6 + Received + 3 Array [ Object { - "colour": "black", - "x": 700, + "": null, }, Object { - "colour": "blue", - "x": 800, + "": null, }, Object { - "colour": "red", - "x": 100, + "": null, }, ]
polars has no trouble extracting the name column as an array, but fails on the attributes column, returning a strange array like [{"": null},{"": null},{"": null}]
[{"": null},{"": null},{"": null}]
This line is the issue, but not sure how to fix it ATM. Sorry.
Have you tried latest version of polars?
yes
What version of polars are you using?
0.16.0
What operating system are you using polars on?
MacOS 14.7.1
What node version are you using
18.19.1
Describe your bug.
Fails to read javascript object columns
What are the steps to reproduce the behavior?
using jest
What is the actual behavior?
What is the expected behavior?
polars has no trouble extracting the name column as an array, but fails on the attributes column, returning a strange array like
[{"": null},{"": null},{"": null}]