Skip to content

Instantly share code, notes, and snippets.

@izhar
Created May 10, 2018 08:50
Show Gist options
  • Save izhar/fc08282197d317d25b7b761a08bf2119 to your computer and use it in GitHub Desktop.
Save izhar/fc08282197d317d25b7b761a08bf2119 to your computer and use it in GitHub Desktop.
def _hello_world_aggr(request, context):
"""
Aggregates the parameters to a single comma separated string.
:param request: iterable sequence of bundled rows
:return: string
"""
params = []
logging.info('hello_world_aggr called')
# Iterate over bundled rows
for request_rows in request:
# Iterate over rows
for row in request_rows.rows:
# Retrieve string value of parameter and append to the params variable
# Length of param is 1 since one column is received, the [0] collects the first value in the list
param = [d.strData for d in row.duals][0]
params.append(param)
# Aggregate parameters to a single string
result = ', '.join(params)
logging.info('writing members to file')
file = open("members.txt","w")
file.write(result)
file.close()
logging.info('done')
result = 'ok'
# Create an iterable of dual with the result
duals = iter([SSE.Dual(strData=result)])
# Yield the row data as bundled rows
yield SSE.BundledRows(rows=[SSE.Row(duals=duals)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment