Data Factory Use Cases
Search items by option across all partitions
Quick links
The job is available for download here.
The JSON representation of the job is available here.
The purpose of this Data Factory job is to find every item of a table whose option field matches a chosen value, wherever that item lives, and to display access links to the partitions holding matches.
This job is made to be triggered by a user from app.product-live.com. The user picks one option of the LIFE_CYCLE field, and the job searches the whole PRODUCTS table in a single data-item-find call, then displays one clickable link per partition where items were found.
Tasks used
| Task | Purpose in this job |
|---|---|
data-table-find | Find the PRODUCTS table by key |
data-partition-find | List the partitions of the table, to resolve partition ids into partition keys |
data-item-find | Search the whole table in one call, using findOptions.partitionSelection |
code-execute-javascript | Group the items by partition and generate the HTML results |
notification-display-message | Display the results with clickable access links in the Actions panel |
Parameters
This job takes two input parameters:
| Parameter | Type | Description |
|---|---|---|
The LIFE_CYCLE option to search for: NEW, RENEWED or ENDED | ||
| Optional. Screen to open the items with |
Searching a whole table in one call
data-item-find searches one partition by default, the one designated by request.json.context. Setting findOptions.partitionSelection widens that scope without any loop on your side:
json
{
"findMode": "REQUEST",
"findOptions": {
"partitionSelection": "TABLE",
"tableKey": "PRODUCTS"
},
"request": {
"method": "INLINE",
"contentType": "application/json",
"model": "default",
"json": {
"criteria": {
"type": "eq",
"field": {
"target": "item.fields",
"key": "LIFE_CYCLE"
},
"value": "NEW"
}
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
The task resolves the table key into its id, lists that table's partitions, runs the same criteria against each one and merges the results.
WARNING
In TABLE mode the partition scope lives entirely in findOptions: request.json.context must not designate a partition, and the table key goes in findOptions.tableKey, never in the request context.
Why the partitions are listed separately
The merge performed by TABLE mode is not free: result.json holds the matching items from every partition, with nothing indicating which partition each item came from.
Each item still carries its itemMetadata.partitionId, but an access link needs a partition key, not an id. That is why the job calls data-partition-find once, purely to build an id to key lookup table. Omitting partitionKey from the link would not be a shortcut: the application would then open the table's first partition, which is wrong for every item stored anywhere else.
Searching on an option
LIFE_CYCLE is a SINGLE-SELECT field, so its value is the key of the selected option, never its displayed title. Searching for the New label would return nothing; the criteria must carry NEW.
WARNING
Only SINGLE-SELECT option fields are searchable this way. MULTIPLE-SELECT, MULTIPLE-SELECT-QUANTIFIED and MULTIPLE-SELECT-QUANTIFIED-WITH-COMMENT fields cannot be used in an item.fields criteria yet.
How it works
- Find table (
data-table-find): Locates thePRODUCTStable by key, and stops the job with an explicit message if it does not exist - Find partitions (
data-partition-find): Retrieves the partitions of the table, used only to map partition ids to partition keys - Find items (
data-item-find): Searches every partition of the table in one call, with aneqcriteria on theLIFE_CYCLEfield - Build results (
code-execute-javascript): Groups the items by partition and generates an HTML page with one access link per partition, each carrying the same option filter - Write HTML file (
code-execute-javascript): Writes the HTML to a file for the display message task - Display message (
notification-display-message): Shows the results in the Actions panel
Example output
The job displays one clickable link per partition holding matches. Each link opens that partition with the searched option already applied as a filter.
Example with LIFE_CYCLE set to NEW:
7 item(s) found with LIFE_CYCLE = NEW
One link per partition rather than one per item is deliberate: every match shares the same option value, so an item-level filter would return the whole partition anyway.
Data Factory Job details
mermaid
flowchart TD
_start(("Start"))
_end(("End"))
find_table["<b><a href='/data-factory/references/tasks/data-table-find/'>data-table-find</a></b><br />Find the PRODUCTS table"]
check_table_found{{"<b><a href='/data-factory/references/tasks/switch/'>switch</a></b><br />Stop if table not found"}}
terminate_no_table(["<b><a href='/data-factory/references/tasks/terminate/'>terminate</a></b> (FAILED)<br />Table not found"])
find_partitions["<b><a href='/data-factory/references/tasks/data-partition-find/'>data-partition-find</a></b><br />List the partitions of the table, to resolve partition ids into partition keys"]
find_items["<b><a href='/data-factory/references/tasks/data-item-find/'>data-item-find</a></b><br />Find the items matching the selected option, across every partition of the table"]
build_message_metadata["<b><a href='/data-factory/references/tasks/code-execute-javascript/'>code-execute-javascript</a></b><br />Group the items by partition and build the HTML message with access links"]
build_message_file["<b><a href='/data-factory/references/tasks/code-execute-javascript/'>code-execute-javascript</a></b><br />Write the HTML message to a file"]
display_results["<b><a href='/data-factory/references/tasks/notification-display-message/'>notification-display-message</a></b><br />Display the search results with access links"]
_start --> find_table
find_table --> check_table_found
check_table_found -->|"NOT_FOUND"| terminate_no_table
check_table_found -->|"default"| find_partitions
find_partitions --> find_items
find_items --> build_message_metadata
build_message_metadata --> build_message_file
build_message_file --> display_results
display_results --> _end