Kategorien:

Systemfunktionen (Systeminformationen)

SYSTEM$GET_TASK_GRAPH_CONFIG

Gibt Informationen aus einer Task-Graph-Konfiguration zurück.

Informationen zum Speichern von Konfigurationswerten in einem Task-Graphen finden Sie unter CREATE TASK … CONFIG.

Syntax

SYSTEM$GET_TASK_GRAPH_CONFIG( [<configuration_path>] )
Copy

Argumente

configuration_path

Optional path of the configuration value to return.

Uses the same syntax as Snowflake queries for semi-structured data. See GET_PATH for more information.

Beispiele

Im folgenden Beispiel wird eine Aufgabe erstellt, die eine Konfiguration definiert und dann die Funktion SYSTEM$GET_TASK_GRAPH_CONFIG zum Abrufen von Werten aus der Konfiguration verwendet.

CREATE OR REPLACE TASK root_task_with_config
  WAREHOUSE = mywarehouse
  SCHEDULE = '10 m'
  CONFIG = $${"output_dir": "/temp/test_directory/", "learning_rate": 0.1}$$
  AS
  BEGIN
    LET OUTPUT_DIR STRING := SYSTEM$GET_TASK_GRAPH_CONFIG('output_dir')::string;
    LET LEARNING_RATE DECIMAL := SYSTEM$GET_TASK_GRAPH_CONFIG('learning_rate')::DECIMAL;
    ...
  END;
Copy

Beispiel: Übergeben von Konfigurationsinformationen an eine andere Aufgabe in einem Task-Graphen

Sie können Konfigurationsinformationen übergeben, indem Sie ein JSON-Objekt verwenden, das von anderen Aufgaben in einem Task-Graphen gelesen werden kann.

Verwenden Sie die Syntax CREATE/ALTER TASK … CONFIG, um die Konfigurationsinformationen in der Stammaufgabe festzulegen, zu löschen oder zu ändern. Verwenden Sie dann die Funktion SYSTEM$GET_TASK_GRAPH_CONFIG, um sie abzurufen.

Im folgenden Beispiel wird die Verwendung eines JSON-Objekts gezeigt, um Konfigurationsinformationen zu übergeben und in einer Tabelle zu speichern:

CREATE OR REPLACE TASK my_task_root
  SCHEDULE = '1 MINUTE'
  USER_TASK_TIMEOUT_MS = 60000
  CONFIG = $${"environment":"production", "dir":"/my_prod_directory/"}$$
  AS SELECT 1;

CREATE OR REPLACE TASK my_child_task
  USER_TASK_TIMEOUT_MS = 600000
  AFTER my_task_root
  AS
    BEGIN
      LET value := (SELECT SYSTEM$GET_TASK_GRAPH_CONFIG('dir'));
      CREATE TABLE IF NOT EXISTS my_table(name VARCHAR, value VARCHAR);
      INSERT INTO my_table VALUES('my_task_root dir',:value);
    END;
Copy