@@ -11,63 +11,48 @@ class AdvancedPlanRun extends PlanRun {
1111 val accountIdField = field.name(" account_id" ).regex(" ACC[0-9]{8}" )
1212 val nameField = field.name(" name" ).expression(" #{Name.name}" )
1313
14- val postgresTask = task.name(" customer_postgres" )
15- .steps(
16- step
17- .name(" transaction" )
18- .jdbcTable(" account.transaction" )
19- .fields(
20- accountIdField,
21- field.name(" txn_id" ).regex(" txn_[0-9]{5}" ),
22- field.name(" year" ).`type`(IntegerType ).sql(" YEAR(date)" ),
23- nameField,
24- field.name(" date" ).`type`(DateType ).min(startDate),
25- field.name(" amount" ).`type`(DoubleType ).max(10000 ),
26- field.name(" credit_debit" ).sql(" CASE WHEN amount < 0 THEN 'C' ELSE 'D' END" ),
27- )
28- .count(
29- count
30- .recordsPerFieldGenerator(generator.min(1 ).max(10 ), " account_id" )
31- )
32- ,
33- step
34- .name(" account" )
35- .jdbcTable(" account.account" )
36- .fields(
37- accountIdField,
38- nameField,
39- field.name(" open_date" ).`type`(DateType ).min(startDate),
40- field.name(" status" ).oneOf(" open" , " closed" , " pending" )
41- )
42- .count(10 )
14+ val postgresTxn = postgres(" customer_postgres_txn" )
15+ .table(" account.transactions" )
16+ .fields(
17+ accountIdField,
18+ field.name(" txn_id" ).regex(" txn_[0-9]{5}" ),
19+ field.name(" year" ).`type`(IntegerType ).sql(" YEAR(date)" ),
20+ nameField,
21+ field.name(" date" ).`type`(DateType ).min(startDate),
22+ field.name(" amount" ).`type`(DoubleType ).max(10000 ),
23+ field.name(" credit_debit" ).sql(" CASE WHEN amount < 0 THEN 'C' ELSE 'D' END" ),
24+ )
25+ .count(
26+ count
27+ .recordsPerFieldGenerator(generator.min(1 ).max(10 ), " account_id" )
4328 )
29+ val postgresAccount = postgres(" customer_postgres_account" )
30+ .table(" account.account" )
31+ .fields(
32+ accountIdField,
33+ nameField,
34+ field.name(" open_date" ).`type`(DateType ).min(startDate),
35+ field.name(" status" ).oneOf(" open" , " closed" , " pending" )
36+ )
37+ .count(count.records(10 ))
4438
45- val jsonTask = task.name(" account_json" )
46- .steps(
47- step
48- .name(" account_info" )
49- .path(" src/main/resources/sample/json" )
39+ val jsonTask = json(" account_json" , " src/main/resources/sample/json" )
40+ .fields(
41+ accountIdField,
42+ nameField,
43+ field.name(" txn_list" )
44+ .`type`(ArrayType )
5045 .fields(
51- accountIdField,
52- nameField,
53- field.name(" txn_list" )
54- .`type`(ArrayType )
55- .fields(
56- field.name(" id" ).sql(" _holding_txn_id" ),
57- field.name(" date" ).`type`(DateType ).min(startDate),
58- field.name(" amount" ).`type`(DoubleType ),
59- ),
60- field.name(" _holding_txn_id" ).omit(true )
61- )
46+ field.name(" id" ).sql(" _holding_txn_id" ),
47+ field.name(" date" ).`type`(DateType ).min(startDate),
48+ field.name(" amount" ).`type`(DoubleType ),
49+ ),
50+ field.name(" _holding_txn_id" ).omit(true )
6251 )
6352
6453 val conf = configuration.postgres(" my_postgres" )
6554
6655 val accountPlan = plan.name(" Create accounts and transactions across Postgres and JSON file" )
67- .taskSummaries(
68- taskSummary.dataSource(" my_postgres" ).task(postgresTask),
69- taskSummary.dataSource(" my_json" ).task(jsonTask)
70- )
7156 .addForeignKeyRelationship(
7257 foreignField(" my_postgres" , " transaction" , " txn_id" ),
7358 foreignField(" my_json" , " account_info" , " _holding_txn_id" )
@@ -83,5 +68,5 @@ class AdvancedPlanRun extends PlanRun {
8368 foreignField(" my_json" , " account_info" , " name" ),
8469 )
8570
86- execute(accountPlan, conf)
71+ execute(accountPlan, conf, postgresAccount, postgresTxn, jsonTask )
8772}
0 commit comments