Step 5: Run a SQL Query
Now that you have created an Amazon Kinesis Analytics application and configured it to use your Amazon Kinesis Firehose delivery stream as its source, you can query the email sending event data that the Firehose delivery stream receives.
This topic shows how to run a SQL query on the email sending event data.
ImportantStep 3: Send Emails
To run a SQL query in Amazon Kinesis Analytics
Assuming that you have moved on to this procedure after completing the last step, go to the Amazon Kinesis Analytics console top menu and choose your application.
Choose Go to SQL editor.
Amazon Kinesis Analytics attempts to read event data from the Firehose stream. If you encounter the No rows in source stream error, ensure that you are still sending the email stream you started at the beginning of this procedure, and then choose Retrieve rows.
In the code editor box, paste the following.Copy
CREATE OR REPLACE STREAM "DESTINATION_SQL_STREAM" ("eventType" VARCHAR(16), "ses_timestamp" timestamp, "messageId" VARCHAR(64), "ses_to" VARCHAR(64), "ses_configuration_set" VARCHAR(32)); CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM" SELECT STREAM "eventType", "ses_timestamp", "messageId", "ses_to", "ses_configuration_set" FROM "SOURCE_SQL_STREAM_001" WHERE "eventType" = 'Send'
Choose Save and run SQL.
After Amazon Kinesis Analytics retrieves and processes incoming records, you see a list of event records of type "Send".