All Products
Search
Document Center

Dataphin:Create a real-time dataset through PostgreSQL

Last Updated:Jan 21, 2025

Dataphin supports the parsing of PostgreSQL data source table fields in SQL mode to define dataset metrics. This guide will walk you through the process of creating and configuring a real-time dataset using PostgreSQL.

Prerequisites

  • Ensure you have created the tag project to which the dataset will belong before proceeding to create a real-time dataset. For more information, see Create a Tag Project.

  • Create a PostgreSQL data source for the real-time dataset prior to its creation. For detailed instructions, see Create a PostgreSQL Data Source.

Procedure

  1. Navigate to the Dataphin home page, and from the top menu bar, click Tag -> Tag Workbench.

  2. To enter the Add Real-time Dataset dialog box, follow these steps:

    Select Tag Project -> click Real-time Dataset -> click Add Dataset.

    image

  3. In the Add Real-time Dataset dialog box, select PostgreSQL Dataset.

  4. On the Add PostgreSQL configuration page, fill in the basic information for the dataset.

    Parameter

    Description

    Dataset Name

    Enter the dataset's name, which can include Chinese and English characters, numbers, and underscores (_), and must be within 64 characters.

    Dataset Code

    Provide a unique identifier for the real-time dataset, which distinguishes it when multiple datasets have the same name. It must begin with a letter and can include lowercase English letters, numbers, and underscores (_), up to 64 characters.

    Owner

    Select the owner of the real-time dataset.

    Description

    Provide a brief description of the real-time dataset, up to 1000 characters.

  5. Set up the Processing Logic for the real-time dataset.

    Parameter

    Description

    Data Source

    Choose the necessary PostgreSQL data source for processing.

    Processing Logic (SQL)

    Upon selecting the data source, input the SQL processing logic.

    • The SELECT statement in SQL must include a field as the input parameter for the real-time tag query service.

    • Ensure SQL includes a variable as the primary key, formatted as ${parameter}.

    • Here is a configuration example:

      SELECT pk, indicatorA, indicatorB FROM source_table where pk = ${parameter}

    Metric Configuration

    First, select the data source and enter the SQL processing logic. Then, click Metric Parsing to configure the primary key/metric display name, value type, and description based on the parsed field names. Supported value types include string, long integer, double-precision floating-point number, date, Boolean, decimal.

    To configure additional metrics, click + Add.

  6. To finalize the creation of the real-time dataset, click Publish.

    Note

    Once saved successfully, click Authenticate to input parameter values according to the configured processing logic and verify the correctness of your processing logic.

What to do next

After creating and publishing the real-time dataset, proceed to create corresponding real-time tags. For detailed instructions, see Real-Time Tag Overview.