Skip to content

Commit

Permalink
add edump() to fix issue #12
Browse files Browse the repository at this point in the history
  • Loading branch information
ncloudioj committed Mar 4, 2014
1 parent 0b38831 commit f65dd46
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
13 changes: 8 additions & 5 deletions bin/hustle
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ if __name__ == '__main__':

# modules we want in our imported namespace
from hustle import Table, h_min, h_avg, h_max, h_sum, h_count, select, \
dump, insert, star, tables, get_tables, delete, drop, schema, \
dump, edump, insert, star, tables, get_tables, delete, drop, schema, \
partitions
from hustle.core.settings import Settings, overrides

Expand All @@ -195,6 +195,7 @@ if __name__ == '__main__':
"drop": drop,
"delete": delete,
"dump": dump,
"edump": edump,
"tables": tables,
"schema": schema,
"partitions": partitions,
Expand All @@ -206,17 +207,19 @@ if __name__ == '__main__':
def commands():
print """
Type `help(<command>)` for more help:
select() - selects rows and columns from a Table
select() - select rows and columns from a Table
dump() - dump the results of a non-nested select query
edump() - dump the resutls of a nested select query
---
Table.create() - create a new Table
insert() - insert data into a Table
---
delete() - delete data based on partition/table
drop() - delete all data including table definition
---
tables() - prints currently available Hustle Tables
schema() - prints the schema for a given table
partitions()- prints all active partitions for a given table
tables() - print currently available Hustle Tables
schema() - print the schema for a given table
partitions()- print all active partitions for a given table
"""

imported_objects['commands'] = commands
Expand Down
16 changes: 15 additions & 1 deletion hustle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def star(table):

def dump(result_urls, width=80):
"""
Dump the results of a query.
Dump the results of a non-nested query.
:type result_urls: sequence of strings
:param result_urls: result of an (unnested) query
Expand All @@ -510,6 +510,20 @@ def dump(result_urls, width=80):
_print_line(columns, width=width, cols=len(alignments), alignments=alignments)


def edump(table):
"""
Dump the results of a nested query.
:type table: a :class:`Table <hustle.Table>` object
:param table: it must be a result table from a nested select query
"""
if not isinstance(table, Table):
raise ValueError("First argument must be a table.")
if not table._blobs:
raise Exception("Can not dump a empty table.")
return select(*star(table), where=table, dump=True)


def get_tables(**kwargs):
"""
return the visible Hustle tables in the currently configured DDFS server. Hustle finds tables by looking
Expand Down

0 comments on commit f65dd46

Please sign in to comment.