Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nested object columns #298

Open
buzzware opened this issue Nov 28, 2024 · 0 comments · May be fixed by #306
Open

Support nested object columns #298

buzzware opened this issue Nov 28, 2024 · 0 comments · May be fixed by #306
Assignees
Labels
bug Something isn't working

Comments

@buzzware
Copy link

buzzware commented Nov 28, 2024

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

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']));
});

What is the actual behavior?

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,
    },
  ]

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

@buzzware buzzware added the bug Something isn't working label Nov 28, 2024
@Bidek56 Bidek56 self-assigned this Dec 28, 2024
@Bidek56 Bidek56 linked a pull request Dec 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants