Create a real-time dataset through PostgreSQL
You can parse PostgreSQL data source table fields in SQL mode to define dataset metrics. This topic describes how to create and configure a real-time dataset by using PostgreSQL.
Prerequisites
-
Before you create a real-time dataset, make sure that the tag project to which the dataset belongs is created. For more information, see .
-
A PostgreSQL data source is created for the real-time dataset. For more information, see .
Procedure
-
On the Dataphin home page, in the top menu bar, click Tag -> Tag Workbench.
-
Open the Add Real-time Dataset dialog box:
Select Tag Project -> click Real-time Dataset -> click Add Dataset.

-
In the Add Real-time Dataset dialog box, select PostgreSQL Dataset.
-
On the Add PostgreSQL page, configure the basic information for the dataset.
Parameter
Description
Dataset Name
The name of the dataset. The name can contain Chinese characters, English letters, digits, and underscores (_), and can be up to 64 characters in length.
Dataset Code
A unique identifier for the real-time dataset, used to distinguish datasets that have the same name. The code must start with a letter and can contain lowercase letters, digits, and underscores (_), up to 64 characters in length.
Owner
The owner of the real-time dataset.
Description
A brief description of the real-time dataset, up to 1,000 characters in length.
-
Set up the Processing Logic for the real-time dataset.
Parameter
Description
Data Source
The PostgreSQL data source to use for processing.
Processing Logic (SQL)
After you select the data source, enter the SQL processing logic.
-
The SQL SELECT statement must include a field that serves as the input parameter for the real-time tag query service.
-
The SQL statement must include a variable as the primary key, in the format of
${parameter}. -
Example:
SELECT pk, indicatorA, indicatorB FROM source_table where pk = ${parameter}
Metric Configuration
After you select the data source and enter the SQL processing logic, click Metric Parsing to configure the primary key or metric display name, value type, and description based on the parsed field names. Supported value types: string, long integer, double-precision floating-point number, date, Boolean, decimal.
To add more metrics, click + Add.
-
-
Click Publish.
NoteAfter the dataset is saved, click Authenticate to enter parameter values based on your processing logic and verify that the logic works as expected.
What to do next
After you create and publish the real-time dataset, you can create corresponding real-time tags. For more information, see .