@@ -69,7 +69,7 @@ def read(
69
69
70
70
return df_reader .format (format ).load (path = path , ** options ) # type: ignore
71
71
72
- def read_table (self , table : str , database : str = None ) -> DataFrame :
72
+ def read_table (self , table : str , database : Optional [ str ] = None ) -> DataFrame :
73
73
"""Use the SparkSession.read interface to read a metastore table.
74
74
75
75
Args:
@@ -179,9 +179,9 @@ def write_table(
179
179
database : Optional [str ],
180
180
table_name : str ,
181
181
path : str ,
182
- format_ : str = None ,
183
- mode : str = None ,
184
- partition_by : List [str ] = None ,
182
+ format_ : Optional [ str ] = None ,
183
+ mode : Optional [ str ] = None ,
184
+ partition_by : Optional [ List [str ] ] = None ,
185
185
** options : Any ,
186
186
) -> None :
187
187
"""Receive a spark DataFrame and write it as a table in metastore.
@@ -231,7 +231,10 @@ def create_temporary_view(dataframe: DataFrame, name: str) -> Any:
231
231
return dataframe .writeStream .format ("memory" ).queryName (name ).start ()
232
232
233
233
def add_table_partitions (
234
- self , partitions : List [Dict [str , Any ]], table : str , database : str = None
234
+ self ,
235
+ partitions : List [Dict [str , Any ]],
236
+ table : str ,
237
+ database : Optional [str ] = None ,
235
238
) -> None :
236
239
"""Add partitions to an existing table.
237
240
@@ -259,9 +262,11 @@ def add_table_partitions(
259
262
key_values_expr = [
260
263
", " .join (
261
264
[
262
- "{} = {}" .format (k , v )
263
- if not isinstance (v , str )
264
- else "{} = '{}'" .format (k , v )
265
+ (
266
+ "{} = {}" .format (k , v )
267
+ if not isinstance (v , str )
268
+ else "{} = '{}'" .format (k , v )
269
+ )
265
270
for k , v in partition .items ()
266
271
]
267
272
)
@@ -314,7 +319,9 @@ def _convert_schema(self, schema: DataFrame) -> List[Dict[str, str]]:
314
319
315
320
return converted_schema
316
321
317
- def get_schema (self , table : str , database : str = None ) -> List [Dict [str , str ]]:
322
+ def get_schema (
323
+ self , table : str , database : Optional [str ] = None
324
+ ) -> List [Dict [str , str ]]:
318
325
"""Returns desired table schema.
319
326
320
327
Attributes:
0 commit comments