Git Product home page Git Product logo

Comments (2)

noirello avatar noirello commented on September 15, 2024

Hi,

It affects both Reader and Writer.
When the struct_repr parameter is set to pyorc.StructRepr.DICT, then the Reader returns the rows as dicts and the Writer's write method expects a dict with all the keys of the column names. (It can have other keys that are not represented in the schema, but they will be ignored.)

import pyorc
input = open('./deps/examples/TestOrcFile.test1.orc', 'rb')
r = pyorc.Reader(input, struct_repr=pyorc.StructRepr.DICT)
print(next(r))
{'boolean1': False, 'byte1': 1, 'short1': 1024, 'int1': 65536, 'long1': 9223372036854775807, 'float1': 1.0, 'double1': -15.0, 'bytes1': b'\x00\x01\x02\x03\x04', 'string1': 'hi', 'middle': {'list': [{'int1': 1, 'string1': 'bye'}, {'int1': 2, 'string1': 'sigh'}]}, 'list': [{'int1': 3, 'string1': 'good'}, {'int1': 4, 'string1': 'bad'}], 'map': {}}
r = pyorc.Reader(input, struct_repr=pyorc.StructRepr.TUPLE)
print(next(r))
(False, 1, 1024, 65536, 9223372036854775807, 1.0, -15.0, b'\x00\x01\x02\x03\x04', 'hi', ([(1, 'bye'), (2, 'sigh')],), [(3, 'good'), (4, 'bad')], {})
output = open('test.orc', 'wb')
w = pyorc.Writer(output, 'struct<a:int,b:float,c:string>', struct_repr=pyorc.StructRepr.DICT)
w.write({'a': 1, 'b': 2.0, 'c': 'test'})
w.write({'a': 1, 'b': 2.0})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'c'

from pyorc.

jornfranke avatar jornfranke commented on September 15, 2024

great thanks a lot for the detailed and fast answer.

from pyorc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.