1
1
""" test orc compat """
2
2
import datetime
3
- from decimal import Decimal
3
+ import distutils
4
4
import os
5
5
6
6
import numpy as np
7
7
import pytest
8
8
9
+ from pandas .compat import is_platform_windows
10
+
9
11
import pandas as pd
10
12
import pandas .util .testing as tm
11
13
12
14
from pandas .io .orc import PyArrowImpl , get_engine , read_orc
13
15
14
- pyarrow = pytest .importorskip ("pyarrow" )
16
+ try :
17
+ import pyarrow # noqa
18
+
19
+ if distutils .version .LooseVersion (pyarrow .__version__ ) < "0.13.0" :
20
+ raise ImportError ("pyarrow must be >= 0.13.0 for read_orc" )
21
+
22
+ _HAVE_PYARROW = True
23
+ except ImportError :
24
+ _HAVE_PYARROW = False
15
25
16
26
pytestmark = pytest .mark .filterwarnings (
17
27
"ignore:RangeIndex.* is deprecated:DeprecationWarning"
@@ -23,7 +33,16 @@ def dirpath(datapath):
23
33
return datapath ("io" , "data" , "orc" )
24
34
25
35
26
- def test_options_get_engine ():
36
+ @pytest .fixture
37
+ def pa ():
38
+ if not _HAVE_PYARROW :
39
+ pytest .skip ("pyarrow is not installed" )
40
+ if is_platform_windows ():
41
+ pytest .skip ("pyarrow orc not available by default on windows" )
42
+ return "pyarrow"
43
+
44
+
45
+ def test_options_get_engine (pa ):
27
46
assert isinstance (get_engine ("pyarrow" ), PyArrowImpl )
28
47
29
48
with pd .option_context ("io.orc.engine" , "pyarrow" ):
@@ -42,7 +61,7 @@ def test_invalid_engine(dirpath):
42
61
read_orc (inputfile , engine = engine , columns = ["boolean1" ])
43
62
44
63
45
- def test_orc_reader_empty (dirpath ):
64
+ def test_orc_reader_empty (dirpath , pa ):
46
65
columns = [
47
66
"boolean1" ,
48
67
"byte1" ,
@@ -75,7 +94,7 @@ def test_orc_reader_empty(dirpath):
75
94
tm .assert_equal (expected , got )
76
95
77
96
78
- def test_orc_reader_basic (dirpath ):
97
+ def test_orc_reader_basic (dirpath , pa ):
79
98
data = {
80
99
"boolean1" : np .array ([False , True ], dtype = "bool" ),
81
100
"byte1" : np .array ([1 , 100 ], dtype = "int8" ),
@@ -95,7 +114,8 @@ def test_orc_reader_basic(dirpath):
95
114
tm .assert_equal (expected , got )
96
115
97
116
98
- def test_orc_reader_decimal (dirpath ):
117
+ def test_orc_reader_decimal (dirpath , pa ):
118
+ from decimal import Decimal
99
119
100
120
# Only testing the first 10 rows of data
101
121
data = {
@@ -123,7 +143,7 @@ def test_orc_reader_decimal(dirpath):
123
143
tm .assert_equal (expected , got )
124
144
125
145
126
- def test_orc_reader_date_low (dirpath ):
146
+ def test_orc_reader_date_low (dirpath , pa ):
127
147
data = {
128
148
"time" : np .array (
129
149
[
@@ -164,7 +184,7 @@ def test_orc_reader_date_low(dirpath):
164
184
tm .assert_equal (expected , got )
165
185
166
186
167
- def test_orc_reader_date_high (dirpath ):
187
+ def test_orc_reader_date_high (dirpath , pa ):
168
188
data = {
169
189
"time" : np .array (
170
190
[
@@ -205,7 +225,7 @@ def test_orc_reader_date_high(dirpath):
205
225
tm .assert_equal (expected , got )
206
226
207
227
208
- def test_orc_reader_snappy_compressed (dirpath ):
228
+ def test_orc_reader_snappy_compressed (dirpath , pa ):
209
229
data = {
210
230
"int1" : np .array (
211
231
[
0 commit comments