With this example, you can understand how to use EL expressions in the following applications:
Use the job orchestration and job scheduling functions to generate daily transaction statistics reports according to transaction details tables.
The tables involved in this example are as follows:
If this data connection is not created, create one. For details, see Configuring DataArts Studio Data Connection Parameters.
If this database is not created, create one. For details, see Creating a Database.
If the tables are not created, create them. For details, see Creating a Table.
INSERT OVERWRITE TABLE trade_report
SELECT
sum(trade_count),
'${yesterday}'
FROM
trade_log
where
date_format(trade_time, 'yyyy-MM-dd') = '${yesterday}'
and set the script name to generate_trade_report.Description of key properties:
#{Job.getYesterday("yyyy-MM-dd")}
Expression Description: The job object uses the getYesterday method to obtain the time of the day before the job plan execution time. The time format is yyyy-MM-dd.
If the job plan time is 2018/9/26 01:00:00, the calculation result of this expression is 2018-09-25. The calculation result will replace the value of parameter ${yesterday} in the SQL script. The SQL statements after the replacement are as follows:
INSERT OVERWRITE TABLE trade_report SELECT sum(trade_count), '2018-09-25' FROM trade_log where date_format(trade_time, 'yyyy-MM-dd') = '2018-09-25'
to test the running job.
to save the job configuration.