Git Product home page Git Product logo

Comments (7)

noirello avatar noirello commented on August 11, 2024

Never checked on CentOS, but I failed to reproduce manually on a Mac with Python 3.7.6 (Clang 11.0.0) using the 0.2.0 release.
The CI runs the tests on Ubuntu and Mac (with 3.6, 37, 3.8).

platform darwin-- Python 3.7.6, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 -- /usr/local/opt/bin/python3.7
cachedir: .pytest_cache
rootdir: /Users/noirello/pyorc
collected 11 items

tests/test_writer.py::test_write_primitive_type[string-values0] PASSED
tests/test_writer.py::test_write_primitive_type[binary-values1] PASSED
tests/test_writer.py::test_write_primitive_type[int-values2] PASSED
tests/test_writer.py::test_write_primitive_type[bigint-values3] PASSED
tests/test_writer.py::test_write_primitive_type[float-values4] PASSED
tests/test_writer.py::test_write_primitive_type[double-values5] PASSED
tests/test_writer.py::test_write_primitive_type[boolean-values6] PASSED
tests/test_writer.py::test_write_primitive_type[timestamp-values7] PASSED
tests/test_writer.py::test_write_primitive_type[date-values8] PASSED
tests/test_writer.py::test_write_primitive_type[decimal(10,7)-values9] PASSED
tests/test_writer.py::test_write_primitive_type[decimal(38,6)-values10] PASSED

You can create an own Date converters and change the default one. A converter that prints the input params before converting them to the Writer/Reader can give us more insights what goes wrong.

from pyorc.

ghunt-cp avatar ghunt-cp commented on August 11, 2024

I added print statements to the date converter. I believe that the issue is a timezone issue. The input was correct, however, the return is causing an issue. Here's a simple python script that illustrates the issue:

from datetime import datetime, date, timezone

print(datetime.fromtimestamp(0))
print(datetime.fromtimestamp(0, timezone.utc))
print(date.fromtimestamp(0))

with the output from my machine:
1969-12-31 19:00:00
1970-01-01 00:00:00+00:00
1969-12-31

In converters.py, in the timestamp converter, the from_orc function is passing timezone.utc to the fromtimestamp function. Ideally, we would do the same in the date converter, however, date's fromtimestamp function does not support passing in a timezone. I changed the from_orc function in the date converter to:
return datetime.fromtimestamp(days * 24 * 60 * 60, timezone.utc).date()
and then the tests started passing for me.

from pyorc.

ghunt-cp avatar ghunt-cp commented on August 11, 2024

Note that if the machine that you run the tests on is on utc, then you wouldn't see this problem because the local time and utc would be the same thing.

from pyorc.

noirello avatar noirello commented on August 11, 2024

Thank you for looking into it.

All of my test runs were in timezones with non-negative UTC offsets. I should fix that.

For solution, I'm planning to leave out the fromtimestamp method entirely, and add timedelta days to the epoch date. Thus the from_orc will be similar to its to_orc counterpart.

from pyorc.

ghunt-cp avatar ghunt-cp commented on August 11, 2024

Awesome! Thanks!

from pyorc.

ghunt-cp avatar ghunt-cp commented on August 11, 2024

Can you create a new release with this fix?

from pyorc.

noirello avatar noirello commented on August 11, 2024

Done. Sorry for taking so long.

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.