SAP HANA

Updated at:

Explore the SAP HANA Connector, including its syntax structure, WITH parameters, and usage examples within Dataphin.

Background information

SAP HANA is a multi-model database that leverages in-memory storage to enhance data processing speeds, enabling both advanced analytics and high-speed transactions on a unified platform.For more information, visit theofficial SAP HANA website.

Supported versions

Flink version

SAP HANA version

SAP HANA Driver version

1.15.3

Unlimited

2.19.16

Note

The SAP HANA Connector is not dependent on specific JDBC Driver attributes. As long as the Driver can establish a connection to the SAP HANA database, it is generally compatible.

Limits

  • Concurrent reads are limited to one at a time. For large datasets, full reads may encounter performance bottlenecks. Alternative solutions, such as offline processing, are recommended.

  • The Connector supports data collection from a single table only; multi-table and entire database collections are not supported.

  • The system performs queries at a predetermined frequency. It is necessary to manually configure the scheduled request time. A longer configuration interval may reduce real-time responsiveness, while a shorter interval can lead to increased database query load.

  • The system collects data of the INSERT type. To capture data changes similar to CDC, alternative technical solutions are required, such as generating CDC data based on a primary key GROUP BY clause.

  • The source table must include an update_time field to record the update time, and each record update must modify this field's value (the system uses this field to determine if the record has been updated).

  • The system retrieves updated data based on the update_time offset. If the update_time is earlier than the actual database write time, the system may miss this data. (The system includes a default 5-second wait time).

  • The update_time in the data must be sequential. If data A's update_time is earlier than data B's, then data A must be visible to the query before data B to prevent data loss.

  • Tables with large data volumes (over 10,000 rows) may experience significant performance issues. For such tables, creating an index on the update_time column is recommended.

  • By default, data read by Flink SQL tasks is of the INSERT type. To convert it into ChangeLog data, you must handle the transformation yourself (e.g., by aggregating by primary key or sorting by update time to obtain the latest data). Note that if the primary key is updated, the data may become inconsistent, so proceed with caution.

  • The Connector does not support data collection for DELETE operations. If downstream deletion and collection are required, consider configuring a deletion field for soft deletion (marking the data as deleted without physically removing it).

Performance reference

In a test environment, utilizing 1CU of Yarn resources (1 CPU, 4GB memory, single concurrent), a consumption rate of 3000RPS was achieved.

Important

The actual task consumption rate may vary based on specific task logic, input and output network bandwidth, field size, and other factors. This parameter value is for reference only.

Connector related instructions

The Connector supports the following categories:

Category

Details

Supported type

Source table

Native DDL access

Supported

Data source codec access

Unsupported

Meta table

Supported

Running mode

Stream mode

Data format

Not applicable

Unique monitoring metrics

None

API type

SQL

Syntax structure

CREATE TABLE input_table (
  id BIGINT
  name STRING,
  update_time TIMESTAMP(3)
) WITH (
    'connector' = 'scan-jdbc',
    'driver' = 'com.sap.db.jdbc.Driver’,
    'url' = '<JDBC URL>',
    'table-name' = '<yourTableName>',
    'username' = '<yourUsername>',
    'password' = '<yourPassword>',
    'scan-period.seconds' = '<PeriodSeconds>',
    'scan.start.time' = '<StartTime>',
    'scan.table.time.column' = '<UpdateTime>'
);

WITH parameters

  • General

    ```html

    Parameter

    Description

    Data type

    Required

    Default value

    Remarks

    connector

    Specifies the table type.

    String

    Yes

    None

    The static field is scan-jdbc.

    driver

    Specifies the JDBC driver.

    String

    Yes

    None

    The static field is com.sap.db.jdbc.Driver.

    url

    The JDBC URL for the database connection.

    String

    Yes

    None

    The format is jdbc:sap://host:port/database.

    table-name

    The name of the table to be read.

    String

    Yes

    None

    Specify the table from which to read data.

    username

    The username for database access.

    String

    Yes

    None

    Enter the username for SAP HANA access.

    password

    The password for database access.

    String

    Yes

    None

    Enter the password for SAP HANA access.

  • Source table

    Parameter

    Description

    Data type

    Required

    Default value

    Remarks

    scan.period.seconds

    Defines the scan period.

    Integer

    No

    10

    Unit: seconds.

    scan.start.time

    Determines the start time for reading updates.

    Date

    No

    Current Time

    The format is yyyy-MM-dd hh-mm-ss; or with time zone yyyy-MM-dd hh-mm-ss Z.

    Note

    Can be set to 'earliest' for a full read followed by incremental reads.

    Example parameters:

    • earliest

    • 2024-03-01 23:55:55

    • 2024-03-01 23:55:55 +0800

    scan.table.time.column

    Specifies the column used to determine the update time for rows.

    Timestamp

    Yes

    None

    Indicate the column that reflects the update time to track row changes. Must be of timestamp type.

    scan.delay.seconds

    Specifies the delay before querying the database.

    Integer

    No

    5

    Specifies the delay in seconds before querying the database. For instance, if you set the query for update_time<'2024-03-08 12:00:00', it will execute at 2024-03-08 12:00:05 to compensate for any time discrepancies and reduce data latency.

Type mapping

SAP HANA type

Flink SQL type

DATE

DATE

TIME

TIME

SECONDDTE

TIMESTAMP

TIMESTAMP

TIMESTAMP

TINYINT

TINYINT

SMALLINT

SMALLINT

INTEGER

INTEGER

BIGINT

BIGINT

SMALLDECIMAL

Not Supported

DECIMAL

DECIMAL

REAL

FLOAT

DOUBLE

DOUBLE

FLOAT(n)

Corresponds to DOUBLE

BOOLEAN

BOOLEAN

VARCHAR

STRING

NVARCHAR

STRING

ALPHANUM

STRING

Short Text

String

VARBINARY

VARBINARY

BLOB

Not Supported

CLOB

Not Supported

NCLOB

Not supported

Text

String

ARRAY

Not Supported

ST_GEOMETRY

Not supported

ST_POINT

Not supported

Usage example

  • Source table

    CREATE TABLE input_table (
      id BIGINT
      name STRING,
      update_time TIMESTAMP(3)
    ) WITH (
        'connector' = 'scan-jdbc',
        'driver' = 'com.sap.db.jdbc.Driver’,
        'url' = jdbc:sap://127.***.***.1:39041?databaseName=HXE',
        'table-name' = 'table_id_name_time',
        'username' = 'root',
        'password' = 'root',
        'scan-period.seconds' = '20',
        'scan.start.time' = '2024-02-20 18:30:00',
        'scan.table.time.column' = 'update_time'
    );

Time zone settings

If the time zone of the SAP HANA database differs from that of the Flink task, you must adjust the time zone settings accordingly. Otherwise, this discrepancy may lead to issues such as failure to read change data or duplicate data reads. Since the SAP HANA JDBC driver does not support setting the time zone parameter, the default time zone of the JVM (user.timezone) is used. To override this, you can add the following parameters to the Flink Config of the Flink SQL task:

Important

Be aware that setting the JVM time zone will affect all time-related processing in the Flink task, so exercise caution when making this change.

env.java.opts: -Duser.timezone=xxx

-- If setting UTC time: note UTC must be uppercase
env.java. opts: -Duser.timezone=UTC

-- If setting Beijing time:
env.java.opts: -Duser.timezone=GMT+8