12
12
from uuid import uuid4
13
13
14
14
import numpy as np
15
- import pyarrow
16
15
import pytz
17
16
import thrift
18
17
import pytest
35
34
pysql_supports_arrow ,
36
35
compare_dbr_versions ,
37
36
is_thrift_v5_plus ,
37
+ pysql_supports_arrow
38
38
)
39
39
from tests .e2e .common .core_tests import CoreTestMixin , SmokeTestMixin
40
40
from tests .e2e .common .large_queries_mixin import LargeQueriesMixin
48
48
49
49
from databricks .sql .exc import SessionAlreadyClosedError
50
50
51
+ try :
52
+ import pyarrow
53
+ except :
54
+ pyarrow = None
55
+
51
56
log = logging .getLogger (__name__ )
52
57
53
58
unsafe_logger = logging .getLogger ("databricks.sql.unsafe" )
@@ -591,7 +596,7 @@ def test_ssp_passthrough(self):
591
596
cursor .execute ("SET ansi_mode" )
592
597
assert list (cursor .fetchone ()) == ["ansi_mode" , str (enable_ansi )]
593
598
594
- @skipUnless ( pysql_supports_arrow (), "arrow test needs arrow support " )
599
+ @pytest . mark . skipif ( not pysql_supports_arrow (), reason = "Skipping because pyarrow is not installed " )
595
600
def test_timestamps_arrow (self ):
596
601
with self .cursor ({"session_configuration" : {"ansi_mode" : False }}) as cursor :
597
602
for timestamp , expected in self .timestamp_and_expected_results :
@@ -611,7 +616,7 @@ def test_timestamps_arrow(self):
611
616
aware_timestamp and aware_timestamp .timestamp () * 1000000
612
617
), "timestamp {} did not match {}" .format (timestamp , expected )
613
618
614
- @skipUnless ( pysql_supports_arrow (), "arrow test needs arrow support " )
619
+ @pytest . mark . skipif ( not pysql_supports_arrow (), reason = "Skipping because pyarrow is not installed " )
615
620
def test_multi_timestamps_arrow (self ):
616
621
with self .cursor ({"session_configuration" : {"ansi_mode" : False }}) as cursor :
617
622
query , expected = self .multi_query ()
@@ -627,7 +632,7 @@ def test_multi_timestamps_arrow(self):
627
632
]
628
633
assert result == expected
629
634
630
- @skipUnless ( pysql_supports_arrow (), "arrow test needs arrow support " )
635
+ @pytest . mark . skipif ( not pysql_supports_arrow (), reason = "Skipping because pyarrow is not installed " )
631
636
def test_timezone_with_timestamp (self ):
632
637
if self .should_add_timezone ():
633
638
with self .cursor () as cursor :
@@ -646,7 +651,7 @@ def test_timezone_with_timestamp(self):
646
651
assert arrow_result_table .field (0 ).type == ts_type
647
652
assert arrow_result_value == expected .timestamp () * 1000000
648
653
649
- @skipUnless ( pysql_supports_arrow (), "arrow test needs arrow support " )
654
+ @pytest . mark . skipif ( not pysql_supports_arrow (), reason = "Skipping because pyarrow is not installed " )
650
655
def test_can_flip_compression (self ):
651
656
with self .cursor () as cursor :
652
657
cursor .execute ("SELECT array(1,2,3,4)" )
@@ -663,7 +668,7 @@ def test_can_flip_compression(self):
663
668
def _should_have_native_complex_types (self ):
664
669
return pysql_has_version (">=" , 2 ) and is_thrift_v5_plus (self .arguments )
665
670
666
- @skipUnless ( pysql_supports_arrow (), "arrow test needs arrow support " )
671
+ @pytest . mark . skipif ( not pysql_supports_arrow (), reason = "Skipping because pyarrow is not installed " )
667
672
def test_arrays_are_not_returned_as_strings_arrow (self ):
668
673
if self ._should_have_native_complex_types ():
669
674
with self .cursor () as cursor :
@@ -674,7 +679,7 @@ def test_arrays_are_not_returned_as_strings_arrow(self):
674
679
assert pyarrow .types .is_list (list_type )
675
680
assert pyarrow .types .is_integer (list_type .value_type )
676
681
677
- @skipUnless ( pysql_supports_arrow (), "arrow test needs arrow support " )
682
+ @pytest . mark . skipif ( not pysql_supports_arrow (), reason = "Skipping because pyarrow is not installed " )
678
683
def test_structs_are_not_returned_as_strings_arrow (self ):
679
684
if self ._should_have_native_complex_types ():
680
685
with self .cursor () as cursor :
@@ -684,7 +689,7 @@ def test_structs_are_not_returned_as_strings_arrow(self):
684
689
struct_type = arrow_df .field (0 ).type
685
690
assert pyarrow .types .is_struct (struct_type )
686
691
687
- @skipUnless ( pysql_supports_arrow (), "arrow test needs arrow support " )
692
+ @pytest . mark . skipif ( not pysql_supports_arrow (), reason = "Skipping because pyarrow is not installed " )
688
693
def test_decimal_not_returned_as_strings_arrow (self ):
689
694
if self ._should_have_native_complex_types ():
690
695
with self .cursor () as cursor :
0 commit comments