Reading over HTTP
You can read data over HTTP using the Extensible Common Data Adapter (ECDA) or ECD Agent.
All adapter or agent implementations involve configuring options. For adapters, you configure and launch the adapter in SQL, using either server or foreign stream/table options. For agents, you configure such options using a properties file and launch the agent at the command line. Many of the options for the ECD adapter and agent are common to all I/O systems. The CREATE FOREIGN STREAM topic in the Streaming SQL Reference Guide has a complete list of options for the ECD adapter.
To read from the file system, you need to create a server object which references the data wrapper ECDA and is of type 'HTTP'.
CREATE OR REPLACE SERVER "FileReaderServer" TYPE 'HTTP'
FOREIGN DATA WRAPPER ECDA;
Note: ECD Adapter server definitions need to reference the ECD foreign data wrapper. You can do so with the syntax FOREIGN DATA WRAPPER ECDA.
Unlike server objects, all foreign streams need to be created in a schema. The following code first creates a schema in which to run the rest of the sample code below, then creates a foreign stream named "FileReaderStream."
CREATE OR REPLACE SCHEMA "HTTP_Source";
SET SCHEMA '"HTTP_Source"';
CREATE OR REPLACE FOREIGN STREAM "HTTP_ReaderStream"
--Columns for the new stream
The ECD agent takes similar options, but these options need to be formatted in a properties file along the lines of the following. These properties correspond to those defined for the adapter above.
ROWTYPE=RECORDTYPE(VARCHAR(2040) id, VARCHAR(2040) reported_at, VARCHAR(2040) shift_no, VARCHAR(2040) trip_no, VARCHAR(2040) route_variant_id)
The code sample above uses CSV as a format. To use other file options, see the File Formats for Reading topic in this guide.