Skip to content

Commit

Permalink
REF: Consolidate related API code to flatten and denest _rpc and dbap…
Browse files Browse the repository at this point in the history
…i submodules. flake8 cleaning
  • Loading branch information
wesm authored and laserson committed Aug 26, 2015
1 parent 76b95b7 commit ee3c006
Show file tree
Hide file tree
Showing 9 changed files with 774 additions and 819 deletions.
15 changes: 0 additions & 15 deletions impala/_rpc/__init__.py

This file was deleted.

37 changes: 23 additions & 14 deletions impala/bdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ def one_hot_categoricals(self, categoricals, prefix=None, dummy_na=False):
# unique_values[col] = self._cursor.fetchall()

def _store(self, path=None, table_name=None, file_format='TEXTFILE',
field_terminator='\t', line_terminator='\n', escape_char='\\',
overwrite=False):
field_terminator='\t', line_terminator='\n', escape_char='\\',
overwrite=False):
if overwrite:
self._cursor.execute(
"DROP TABLE IF EXISTS %s" % table_name.to_sql())
Expand All @@ -291,7 +291,9 @@ def _store(self, path=None, table_name=None, file_format='TEXTFILE',
def store(self, path=None, table=None, file_format='TEXTFILE',
field_terminator='\t', line_terminator='\n', escape_char='\\',
overwrite=False):
"""Materialize the results and stores them in HFDS. Functions as an EXTERNAL table.
"""
Materialize the results and stores them in HFDS. Functions as an
EXTERNAL table.
Implemented through a `CREATE TABLE AS SELECT`.
"""
Expand All @@ -301,21 +303,28 @@ def store(self, path=None, table=None, file_format='TEXTFILE',
if path is None:
path = os.path.join(self._temp_dir, temp_table)
table_name = _to_TableName(table)
return self._store(path=path, table_name=table_name, file_format=file_format, field_terminator=field_terminator,
line_terminator=line_terminator, escape_char=escape_char, overwrite=overwrite)



def store_managed(self, table, file_format='PARQUET', field_terminator='\t', line_terminator='\n', escape_char='\\',
overwrite=False):
"""Materialize the results and stores them in HDFS as an impala managed table.
return self._store(path=path, table_name=table_name,
file_format=file_format,
field_terminator=field_terminator,
line_terminator=line_terminator,
escape_char=escape_char, overwrite=overwrite)

def store_managed(self, table, file_format='PARQUET',
field_terminator='\t', line_terminator='\n',
escape_char='\\',
overwrite=False):
"""
Materialize the results and stores them in HDFS as an impala managed
table.
Implemented through a `CREATE TABLE AS SELECT`.
"""
table_name = _to_TableName(table)
return self._store(path=None, table_name=table_name, file_format=file_format, field_terminator=field_terminator,
line_terminator=line_terminator, escape_char=escape_char, overwrite=overwrite)

return self._store(path=None, table_name=table_name,
file_format=file_format,
field_terminator=field_terminator,
line_terminator=line_terminator,
escape_char=escape_char, overwrite=overwrite)

def save_view(self, name, overwrite=False):
"""Create a named view representing this BDF for later reference"""
Expand Down
Loading

0 comments on commit ee3c006

Please sign in to comment.