-
Notifications
You must be signed in to change notification settings - Fork 2
/
call_lambda.py
57 lines (47 loc) · 1.49 KB
/
call_lambda.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import boto3
import json
client = boto3.client('lambda', region_name='eu-west-3')
#SQL="SELECT source_legal_entities,client_name,parent_company,product_name,fund_currency FROM mytable where source_legal_entities='1' and parent_company='3'"
BUCKET="mydemobucket"
FOLDER="output/"
CATALOG="myglue"
SCHEMA="myschema"
TABLE="mytable"
COLUMNS="source_legal_entities,client_name,parent_company,product_name,fund_currency"
FILTER="source_legal_entities='1' and parent_company='3'"
payload={
"catalog": CATALOG,
"schema": SCHEMA,
"table": TABLE,
"filter": FILTER,
"columns": COLUMNS,
"output_file": "file_output_CTAS",
"output_folder":FOLDER,
"bucket": BUCKET
}
print("\nCTAS test ...")
response = client.invoke(
FunctionName="Lambda-CTAS",
InvocationType='RequestResponse',
Payload=bytes(json.dumps(payload).encode('utf-8'))
)
print("CTAS result : "+json.dumps(json.loads(response['Payload'].read()),indent=2))
#print("CTAS result : "+str(response['Payload'].read()))
payload={
"catalog": CATALOG,
"schema": SCHEMA,
"table": TABLE,
"filter": FILTER,
"columns": COLUMNS,
"output_file": "file_output_Pandas",
"output_folder":FOLDER,
"bucket": BUCKET
}
print("\nPandas test ...")
client = boto3.client('lambda', region_name='eu-west-3')
response = client.invoke(
FunctionName="Lambda-Pandas",
InvocationType='RequestResponse',
Payload=bytes(json.dumps(payload).encode('utf-8'))
)
print("Pandas result : "+json.dumps(json.loads(response['Payload'].read()),indent=2))