Create a server object and foreign stream to connect with a log file

<< Click to Display Table of Contents >>

Navigation:  Building Streaming Applications > Tutorial 2: Introduction to Coding with Streaming SQL > Tutorial 2A: Creating a Stream and View in SQLstream s-Studio >

Create a server object and foreign stream to connect with a log file

Previous pageReturn to chapter overviewNext page

A data source is a server object. Server objects are objects in s-Server that contain all the information needed to connect to a data source, such as a log file on a server. s-Server uses server objects to configure connections to data sources, such as external database tables, log files, and Kafka topics.

To create the data source:

If it is not expanded already, click First SQLstream Server to expand it.

1.Right-click Data Sources & Sinks and select New.
2.In the dialog box that opens, enter Buses_Server for the data source's name.

sbur_st_name_server_object

3.A tab opens called Buses_Server (Data Source).

sbur_st_server_data_source_tab

4.To the right of the Options dialog box, click the Add button. One by one, enter the following properties for the server, without quotation marks. These need to be entered exactly in order to work.

sbur_studio_add_option



format_type

CSV

character_encoding

UTF-8

separator

,

skip_header

false

directory

/tmp

filename_pattern

buses\.log

 

Once you define a server object, you can use it for multiple streams. This is one of the advantages of storing connection information in a separate SQL object.

5.Note that the Buses_Server (Data Source) tab has an asterisk next to it. This indicates that the data source has not been saved.
6.Choose File > Save (or Ctrl-S) to save the server.

A message, "Changes to this data server will not affect already-running streams..." appears.

7.Dismiss this message by clicking OK.

Observe that Buses_Server now appears under Data Sources & Sinks in the Development tree. The data source is now available to be associated with a stream.

sbur_studio_buses_server_added

Create a Foreign Stream

Next, you create a foreign stream that will store the data from the log file. All streams are created in schemas.

To create a new schema:

1.Right-click Schemas and select New.
2.In the dialog box that opens, enter Buses_Schema for the data source's name.

sbur_studio_new_schema

3.Click on Buses_Schema to expand it.
4.Right-click Foreign Streams and select New.
5.In the dialog box that opens, enter Buses_Foreign_Stream for the data source's name.
6.A tab opens called Buses_Foreign_Stream (Foreign Stream).
7.To the right of Server, select Buses_Server from the dropdown menu.
8.Note that the Buses_Foreign_Stream (Foreign Stream) tab has an asterisk next to it. This indicates that the data source has not been saved.
9.Choose File > Save (or Ctrl-S) to save the foreign stream.