Skip to content

Commit 580dba8

Browse files
authored
Allow parquet import to be None (#36202)
1 parent 4dc472a commit 580dba8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

sdks/python/apache_beam/io/parquetio.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@
5252

5353
try:
5454
import pyarrow as pa
55+
paTable = pa.Table
5556
import pyarrow.parquet as pq
5657
# pylint: disable=ungrouped-imports
5758
from apache_beam.typehints import arrow_type_compatibility
5859
except ImportError:
5960
pa = None
61+
paTable = None
6062
pq = None
6163
ARROW_MAJOR_VERSION = None
6264
arrow_type_compatibility = None
@@ -176,7 +178,7 @@ def __init__(self, beam_type):
176178
self._beam_type = beam_type
177179

178180
@DoFn.yields_batches
179-
def process(self, element) -> Iterator[pa.Table]:
181+
def process(self, element) -> Iterator[paTable]:
180182
yield element
181183

182184
def infer_output_type(self, input_type):
@@ -185,7 +187,7 @@ def infer_output_type(self, input_type):
185187

186188
class _BeamRowsToArrowTable(DoFn):
187189
@DoFn.yields_elements
188-
def process_batch(self, element: pa.Table) -> Iterator[pa.Table]:
190+
def process_batch(self, element: paTable) -> Iterator[paTable]:
189191
yield element
190192

191193

@@ -845,7 +847,7 @@ def open(self, temp_path):
845847
use_deprecated_int96_timestamps=self._use_deprecated_int96_timestamps,
846848
use_compliant_nested_type=self._use_compliant_nested_type)
847849

848-
def write_record(self, writer, table: pa.Table):
850+
def write_record(self, writer, table: paTable):
849851
writer.write_table(table)
850852

851853
def close(self, writer):

0 commit comments

Comments
 (0)