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

GH-40633: [C++][Python] Fix ORC crash when file contains unknown timezone #45051

Merged
merged 5 commits into from
Dec 18, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion python/pyarrow/tests/test_orc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
# specific language governing permissions and limitations
# under the License.

import pytest
import decimal
import datetime
import subprocess
import sys

import pytest

import pyarrow as pa
from pyarrow import fs
Expand Down Expand Up @@ -140,6 +143,33 @@ def test_example_using_json(filename, datadir):
check_example_file(path, table, need_fix=True)


def test_unknown_timezone(datadir):
# Example file relies on the timezone "US/Pacific". It should gracefully
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this test checks an unrelated issue.

# fail, not crash, if the timezone is not found.
path = datadir / 'TestOrcFile.testDate1900.orc'
code = f"""if 1:
import os
import re
os.environ['TZDIR'] = '/tmp/non_existent'

from pyarrow import orc
orc_file = orc.ORCFile({str(path)!r})
try:
orc_file.read()
except Exception as e:
assert "time zone" in e.lower(), e
else:
assert False, "Should have raised exception"
try:
orc_file.read_stripe(0)
except Exception as e:
assert "time zone" in e.lower(), e
else:
assert False, "Should have raised exception"
"""
subprocess.run([sys.executable, "-c", code], check=True)


def test_orcfile_empty(datadir):
from pyarrow import orc

Expand Down
Loading