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

Unable to write array data type #12

Closed
fritzb opened this issue Jun 4, 2020 · 2 comments
Closed

Unable to write array data type #12

fritzb opened this issue Jun 4, 2020 · 2 comments

Comments

@fritzb
Copy link

fritzb commented Jun 4, 2020

I tried writing an array of string, and getting exception below:

    with open("/tmp/data.orc", "wb") as data:
        with pyorc.Writer(data, "struct<col0:array<string>>") as writer:
            writer.write((["a:b", "c:d"]))

Here is the trace back:

Traceback (most recent call last):
  File "/Users/fritzbudiyanto/vagrant/ubuntu/workflows/tasks/mapid_enrichment/app.py", line 120, in <module>
    main()
  File "/Users/fritzbudiyanto/vagrant/ubuntu/workflows/tasks/mapid_enrichment/app.py", line 114, in main
    writer.write((["a:b", "c:d"]))
TypeError: Item ['a:b', 'c:d'] is not an instance of tuple

@noirello
Copy link
Owner

noirello commented Jun 4, 2020

You're just missing a comma:

    with open("/tmp/data.orc", "wb") as data:
        with pyorc.Writer(data, "struct<col0:array<string>>") as writer:
            writer.write((["a:b", "c:d"] , ))

Tuples with single element require an extra comma. ( (6) vs (6,))

@fritzb
Copy link
Author

fritzb commented Jun 4, 2020

Thanks, it worked. I'm closing the issue.

@fritzb fritzb closed this as completed Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants