After you configure a variable, you can reference the variable in the SQL editor of a job, in the Additional Configuration section of the Advanced tab for the job, or in the Additional Configuration section of the Deployment Defaults page for the job in the console of fully managed Flink. This topic describes how to configure and reference a variable.

Background information

The variable configuration provides the following benefits:
  • You can use variables to avoid security risks that are caused by plaintext AccessKey pairs in DDL statements.
  • You can dynamically change variable values instead of directly modifying SQL statements. This improves the efficiency of variable replacement.

Limits

  • You can only add and delete variables. You cannot change or view the values of variables.
  • You can reference variables only in the WITH parameter of the CREATE TEMPORARY TABLE statement. If you reference variables in the WITH parameter of the CREATE TABLE statement, the table that you create cannot be used.

Usage notes

If you delete an existing variable, the SOL job that you develop may not be published or you need to resubmit the published job. Proceed with caution. A published job is not affected if you delete an existing variable.

Configure a variable

  1. Log on to the Realtime Compute for Apache Flink console.
  2. On the Fully Managed Flink tab, find the workspace that you want to manage and click Console in the Actions column.
  3. In the left-side navigation pane, choose Administration > Secret Values.
  4. On the Secret Values page, click Add Secret Value.
  5. In the Add Secret Value dialog box, configure the Secret Name and Secret Value parameters.
    Notice The value of the Secret Value parameter is case-sensitive.
    Variable information
  6. Click OK.

Reference a variable

After you configure a variable, you can reference the variable in the SQL editor of a job.

  1. In the left-side navigation pane of the console of fully managed Flink, click Draft Editor.
  2. Reference the variable in the SQL editor of your job.
    When you reference the variable, specify the variable in the ${secret_values.Variable name} format. The following sample code shows how to reference a variable.
    CREATE TEMPORARY table datahub_source(
      name VARCHAR
    ) WITH (
      'connector' = 'datagen'
    );
    
    CREATE TEMPORARY table datahub_sink(
      name  VARCHAR  
    ) WITH (
      'connector'='datahub',
      'endpoint'='<yourEndpoint>',
      'project'='<yourProject>',
      'topic'='<yourTopic>',
      'accessId'='<yourAccessId>',
      'accessKey'='${secret_values.test_ak}'
    );
    
    INSERT INTO datahub_sink
    SELECT 
      LOWER(name)
    from datahub_source;