|
|
@ -85,7 +85,7 @@ class Writer (Iceberg):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
def __init__(self,**_args):
|
|
|
|
def __init__(self,**_args):
|
|
|
|
super().__init__(**_args)
|
|
|
|
super().__init__(**_args)
|
|
|
|
self._mode = 'append'
|
|
|
|
self._mode = 'append' if 'mode' not in _args else _args['mode']
|
|
|
|
self._table = None if 'table' not in _args else _args['table']
|
|
|
|
self._table = None if 'table' not in _args else _args['table']
|
|
|
|
def write(self,_data,**_args):
|
|
|
|
def write(self,_data,**_args):
|
|
|
|
_prefix = self._getPrefix(**_args)
|
|
|
|
_prefix = self._getPrefix(**_args)
|
|
|
@ -94,5 +94,10 @@ class Writer (Iceberg):
|
|
|
|
rdd = self._session.createDataFrame(_data)
|
|
|
|
rdd = self._session.createDataFrame(_data)
|
|
|
|
_mode = self._mode if 'mode' not in _args else _args['mode']
|
|
|
|
_mode = self._mode if 'mode' not in _args else _args['mode']
|
|
|
|
_table = self._table if 'table' not in _args else _args['table']
|
|
|
|
_table = self._table if 'table' not in _args else _args['table']
|
|
|
|
_table = f'{_prefix}.{_table}'
|
|
|
|
|
|
|
|
rdd.write.format('iceberg').mode(self._mode).save(_table)
|
|
|
|
if not self.has(table=_table) :
|
|
|
|
|
|
|
|
_mode = 'overwrite'
|
|
|
|
|
|
|
|
rdd.write.format('iceberg').mode(_mode).saveAsTable(_table)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
_table = f'{_prefix}.{_table}'
|
|
|
|
|
|
|
|
rdd.write.format('iceberg').mode(_mode).save(_table)
|
|
|
|