ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 46 - ADA-C01 discussion

Report
Export

A Snowflake Administrator needs to persist all virtual warehouse configurations for auditing and backups. Given a table already exists with the following schema:

Table Name : VWH_META

Column 1 : SNAPSHOT_TIME TIMESTAMP_NTZ

Column 2 : CONFIG VARIANT

Which commands should be executed to persist the warehouse data at the time of execution in JSON format in the table VWH META?

A.
1. SHOW WAREHOUSES; 2. INSERT INTO VWH META SELECT CURRENT TIMESTAMP (), FROM TABLE (RESULT_SCAN (LAST_QUERY_ID(1) ) ) ;
Answers
A.
1. SHOW WAREHOUSES; 2. INSERT INTO VWH META SELECT CURRENT TIMESTAMP (), FROM TABLE (RESULT_SCAN (LAST_QUERY_ID(1) ) ) ;
B.
1. SHOW WAREHOUSES; 2. INSERT INTO VWH META SELECT CURRENT TIMESTAMP (), * FROM TABLE (RESULT_SCAN (LAST_QUERY_ID ())) ;
Answers
B.
1. SHOW WAREHOUSES; 2. INSERT INTO VWH META SELECT CURRENT TIMESTAMP (), * FROM TABLE (RESULT_SCAN (LAST_QUERY_ID ())) ;
C.
1. SHOW WAREHOUSES; 2. INSERT INTO VWH_META SELECT CURRENT_TIMESTAMP (), OBJECT CONSTRUCT (*) FROM TABLE (RESULT_SCAN (LAST_QUERY_ID ()));
Answers
C.
1. SHOW WAREHOUSES; 2. INSERT INTO VWH_META SELECT CURRENT_TIMESTAMP (), OBJECT CONSTRUCT (*) FROM TABLE (RESULT_SCAN (LAST_QUERY_ID ()));
D.
1. SHOW WAREHOUSES; 2. INSERT INTO VWH META SELECT CURRENT TIMESTAMP (), * FROM TABLE (RESULT_SCAN (SELECT LAST QUERY ID(-1)));
Answers
D.
1. SHOW WAREHOUSES; 2. INSERT INTO VWH META SELECT CURRENT TIMESTAMP (), * FROM TABLE (RESULT_SCAN (SELECT LAST QUERY ID(-1)));
Suggested answer: C

Explanation:

According to the Using Persisted Query Results documentation, the RESULT_SCAN function allows you to query the result set of a previous command as if it were a table. The LAST_QUERY_ID function returns the query ID of the most recent statement executed in the current session. Therefore, the combination of these two functions can be used to access the output of the SHOW WAREHOUSES command, which returns the configurations of all the virtual warehouses in the account. However, to persist the warehouse data in JSON format in the table VWH_META, the OBJECT_CONSTRUCT function is needed to convert the output of the SHOW WAREHOUSES command into a VARIANT column. The OBJECT_CONSTRUCT function takes a list of key-value pairs and returns a single JSON object. Therefore, the correct commands to execute are:

1. SHOW WAREHOUSES;

2. INSERT INTO VWH_META SELECT CURRENT_TIMESTAMP (), OBJECT_CONSTRUCT (*) FROM TABLE (RESULT_SCAN (LAST_QUERY_ID ()));

The other options are incorrect because:

*

A) This option does not use the OBJECT_CONSTRUCT function, so it will not persist the warehouse data in JSON format. Also, it is missing the * symbol in the SELECT clause, so it will not select any columns from the result set of the SHOW WAREHOUSES command.

* B) This option does not use the OBJECT_CONSTRUCT function, so it will not persist the warehouse data in JSON format. It will also try to insert multiple columns into a single VARIANT column, which will cause a type mismatch error.

* D) This option does not use the OBJECT_CONSTRUCT function, so it will not persist the warehouse data in JSON format. It will also try to use the RESULT_SCAN function on a subquery, which is not supported. The RESULT_SCAN function can only be used on a query ID or a table name.

asked 23/09/2024
Yan Nguyen
32 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first