Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Run a Python script that contains a function on each row of the parent table.
...
Code Block |
---|
from lhub_integ import action # Functions annotated with @action can be called in runScript automation # Try using the actions defined below by mapping columns to the parameters and hit Run @action def sum_and_product(column1, column2): # Return a dictionary to create multiple columns in the output table with explode set true # If explode is set to false, you will get the dictionary as json in `result` column return { "sum" : column1 + column2, "product" : column1 * column2 }; @action def double(column1): # Return a non-dictionary type to get the value in an `other_field` column return column1 * 2; |
input
val1 | val2 |
---|---|
3 | 5 |
Example 1
command
LQL Command
Code Block |
---|
runScript(inputTable, 'operationScript.py', 'sum_and_product(val1, val2)', 'true') |
output
sum | product | other_field | exit_code |
---|---|---|---|
8 | 15 | 0 |
Example 2
command
LQL Command
Code Block |
---|
runScript(inputTable, 'operationScript.py', 'sum_and_product(val1, val2)', 'false') |
output
result | exit_code |
---|---|
{"sum": 8, "product": 15} | 0 |
Example 3
command
LQL Command
Code Block |
---|
runScript(inputTable, 'operationScript.py', 'double(val1)', 'true') |
output
other_field | exit_code |
---|---|
6 | 0 |
Example 4
command
LQL Command
Code Block |
---|
runScript(inputTable, 'operationScript.py', 'double(val1)', 'false') |
output
result | exit_code |
---|---|
6 | 0 |