11import os
22import re
33from time import time
4- from typing import List , Optional
4+ from typing import Any , Callable , List , Optional
55import logging
66from pathlib import Path
77from datetime import datetime , timedelta , timezone
@@ -130,8 +130,7 @@ def read(self, table_name: str, data_format: str,
130130 continue
131131 if need_sqvers :
132132 vers = float (str (elem ).split ('=' )[- 1 ])
133- if vers > max_vers :
134- max_vers = vers
133+ max_vers = max (vers , max_vers )
135134
136135 dataset = ds .dataset (elem , format = 'parquet' ,
137136 partitioning = 'hive' )
@@ -226,6 +225,9 @@ def write(self, table_name: str, data_format: str,
226225 df = pd .DataFrame .from_dict (data ["records" ])
227226 table = pa .Table .from_pandas (df , schema = schema ,
228227 preserve_index = False )
228+ else :
229+ raise ValueError ('Unknown format of data provided:'
230+ f'{ type (data )} ' )
229231
230232 pq .write_to_dataset (table ,
231233 root_path = folder ,
@@ -539,8 +541,7 @@ def _get_cp_dataset(self, table_name: str, need_sqvers: bool,
539541 continue
540542 if need_sqvers :
541543 vers = float (str (elem ).split ('=' )[- 1 ])
542- if vers > max_vers :
543- max_vers = vers
544+ max_vers = max (vers , max_vers )
544545
545546 dataset = ds .dataset (elem , format = 'parquet' , partitioning = 'hive' )
546547
@@ -618,7 +619,7 @@ def _get_filtered_fileset(self, dataset: ds, namespaces: list) -> ds:
618619 ds: pyarrow dataset of only the files that match filter
619620 """
620621 def check_ns_conds (ns_to_test : str , filter_list : List [str ],
621- op : operator . or_ ) -> bool :
622+ op : Callable [[ Any , Any ], Any ] ) -> bool :
622623 """Concat the expressions with the provided (AND or OR) operator
623624 and return the result of the resulting expression tested on the
624625 provided namespace.
@@ -631,11 +632,10 @@ def check_ns_conds(ns_to_test: str, filter_list: List[str],
631632 Returns:
632633 bool: the result of the expression
633634 """
634- # pylint: disable=comparison-with-callable
635635 # We would like to init the result to False if we concat the
636636 # expressions with OR, while with True if we use AND.
637637 res = False
638- if operator .and_ == op :
638+ if operator .and_ is op :
639639 res = True
640640 for filter_val in filter_list :
641641 ns_to_test = ns_to_test .split ('namespace=' )[- 1 ]
0 commit comments