Advanced
Тема интерфейса

Управление глобальными переменными DLI

Эта статья полезна?
Язык статьи: Русский
Показать оригинал
Страница переведена автоматически и может содержать неточности. Рекомендуем сверяться с английской версией.

Что такое глобальная переменная?

DLI позволяет устанавливать переменные, которые часто используются при разработке заданий, в виде глобальных переменных в консоли управления DLI. Это избавляет от повторных определений при редактировании заданий и снижает затраты на разработку и обслуживание. Глобальные переменные можно использовать для замены длинных и сложных переменных, упрощая сложные параметры и повышая читаемость SQL‑запросов.

В этом разделе описывается, как создать глобальную переменную.

Создание глобальной переменной

  1. В навигационной панели консоли DLI выберите Глобальная конфигурация > Глобальные переменные.
  2. В Глобальные переменные странице, нажмите Создать в правом верхнем углу, чтобы создать глобальную переменную.
    Таблица 1 Global variable parameters

    Parameter

    Description

    Variable

    Name of the created global variable.

    Value

    Global variable value.

  3. After creating a global variable, use {{xxxx}} in the SQL statement to replace the parameter value set as the global variable. xxxx indicates the variable name. For example, if you set global variable abc to represent the table name, replace the actual table name with {{abc}} in the table creation statement.
    create table {{table_name}} (String1 String, int4 int, varchar1 varchar(10))
    partitioned by (int1 int,int2 int,int3 int)
    Note

    Do not use global variables in OPTIONS of the table creation statements.

    Related operations:

    • Modifying a global variable

      On the Global Variables page, locate a desired variable and click Modify in the Operation column.

      Note

      If there are multiple global variables with the same name in the same project under an account, delete the redundant global variables to ensure that the global variables are unique in the same project. In this case, all users who have the permission to modify the global variables can change the variable values.

    • Deleting a global variable

      On the Global Variables page, click Delete in the Operation column of a variable to delete the variable value.

      Note
      • If there are multiple global variables with the same name in the same project under an account, delete the global variables created by the user first. If there are only unique global variables, all users who have the delete permission can delete the global variables.
      • After a variable is deleted, the variable cannot be used in SQL statements.

Permissions Management for Global Variables

You can assign different users different global variables through permission settings. The administrator and owners of global variables have all permissions. You do not need to set permissions for them, and their global variable permissions cannot be modified by other users.

When setting global variables for a new user, the user's group must have the Tenant Guest permission.

  • Granting permissions on a global variable to a user
    1. In the navigation pane on the left of the DLI console, choose Global Configuration > Global Variables. On the displayed page, locate a desired global variable and click Set Permission in the Operation column. On the displayed User Permissions page, you can grant, set, and revoke permissions on the global variable to users.
    2. Click Grant Permission in the upper right corner.
      Table 2 Global variable parameters

      Parameter

      Description

      Username

      Name of the IAM user who is granted permissions

      NOTE:

      This username must be an existing IAM username.

      Permissions

      • Update: This permission allows you to update the global variable.
      • Delete: This permission allows you to delete the global variable.
      • Grant Permission: This permission allows you to grant permissions of the global variable to other users.
      • Revoke Permission: This permission allows you to revoke the global variable permissions that other users have but cannot revoke the global variable owner's permissions.
      • View Other User's Permissions: This permission allows you to view the global variable permissions of other users.
  • Granting permissions on a global variable to a user

    On the User Permissions page, locate a desired IAM user and click Set Permission in the Operation столбец. Таблица 2 перечисляет параметры разрешений.

    Если все параметры разрешений неактивны (серого цвета), это означает, что у вас нет прав изменять разрешения для этой глобальной переменной. Вы можете запросить разрешение на изменение у пользователей, имеющих авторизацию, например у администратора или владельцев группы.

  • Отзыв разрешений глобальной переменной у пользователя

    В Разрешения пользователя странице, найдите нужного пользователя IAM и нажмите Отозвать разрешение в Операция столбец. После завершения операции отзыва пользователь IAM более не будет иметь никаких разрешений на глобальную переменную.