This topic provides a guide for operating and maintaining the FLINK_SQL real-time task in this tutorial, which includes initiating the real-time instance and inserting test data.
Step 1: Start the real-time task
On the Dataphin home page, single click Development in the top menu bar.
Refer to the operation guide in the figure below to start the flink_dataphin real-time task.
In the dialog box for starting the real-time instance, set the startup parameters as follows:
Parameter
Description
Startup Mode
Choose Stateless startup.
Specify The Data Read Point Of The Source Table
Select Current date and time.
Time Parameter Configuration
Choose Current date.
Single click OK to proceed.
Step 2: Insert data
Access the MySQL instance for the flink_dataphin data source and execute the following commands to insert data and verify the real-time task's computational results.
//Create a function to generate product types
CREATE FUNCTION getSkuId() RETURNS VARCHAR(20)
BEGIN
DECLARE sku_id VARCHAR(20);
SET sku_id = CASE FLOOR(RAND() * 3)
WHEN 0 THEN 'Green Tea'
WHEN 1 THEN 'Black Tea'
WHEN 2 THEN 'Herbal Tea'
ELSE 'Data generation error'
END;
RETURN sku_id;
END;
//Execute data insertion every 3 seconds
DELIMITER $$
CREATE PROCEDURE executeStatement3000Times()
BEGIN
DECLARE i INT DEFAULT 0;
WHILE i < 1000 DO
INSERT INTO oms_orders(id, buyer_id,sku_type,sku_quantity, gmt_create) VALUES (default,FLOOR(RAND() * 10),getSkuId(),FLOOR(RAND() * 10),current_timestamp());
SET i = i + 1;
SELECT SLEEP(3);
END WHILE;
END $$
DELIMITER ;
//Execute the PROCEDURE to generate and insert data
CALL executeStatement3000Times();