
Answer-first summary for fast verification
Answer: ``` +-----------------------+---------------+ | max(_commit_version) | max(version) | +-----------------------+---------------+ | 4 | 6.2.0 | +-----------------------+---------------+ ```
The correct answer is B. Here's why: 1. **CREATE TABLE**: Initializes the table with `_commit_version` set to 0. 2. **INSERT INTO versions VALUES (‘IDE’, ‘6.2.0’)**: Increments `_commit_version` to 1. 3. **UPDATE versions SET version = ‘5.1.0’ WHERE software = ‘IDE’**: Increments `_commit_version` to 2. 4. **INSERT INTO versions VALUES (‘IDE-1’, ‘1.3.0’)**: Increments `_commit_version` to 3. 5. **DELETE FROM versions WHERE version = ‘1.3.0’**: Increments `_commit_version` to 4. 6. **SELECT max(_commit_version), max(version) FROM table_changes(‘versions’, 2)**: The `max(_commit_version)` is 4. The `max(version)` is '6.2.0' because the `table_changes` function includes both the original and updated values for updated records, with '6.2.0' being the original value before the update.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
What is the correct output when the following set of commands is executed in Databricks?
CREATE TABLE versions (software STRING, version STRING) TBLPROPERTIES (delta.enableChangeDataFeed = true);
INSERT INTO versions VALUES (‘IDE’, ‘6.2.0’);
UPDATE versions SET version = ‘5.1.0’ WHERE software = ‘IDE’;
INSERT INTO versions VALUES (‘IDE-1’, ‘1.3.0’);
DELETE FROM versions WHERE version = ‘1.3.0’;
SELECT max(_commit_version), max(version) FROM table_changes(‘versions’, 2);
CREATE TABLE versions (software STRING, version STRING) TBLPROPERTIES (delta.enableChangeDataFeed = true);
INSERT INTO versions VALUES (‘IDE’, ‘6.2.0’);
UPDATE versions SET version = ‘5.1.0’ WHERE software = ‘IDE’;
INSERT INTO versions VALUES (‘IDE-1’, ‘1.3.0’);
DELETE FROM versions WHERE version = ‘1.3.0’;
SELECT max(_commit_version), max(version) FROM table_changes(‘versions’, 2);
A
+-----------------------+---------------+
| max(_commit_version) | max(version) |
+-----------------------+---------------+
| 3 | 6.2.0 |
+-----------------------+---------------+
+-----------------------+---------------+
| max(_commit_version) | max(version) |
+-----------------------+---------------+
| 3 | 6.2.0 |
+-----------------------+---------------+
B
+-----------------------+---------------+
| max(_commit_version) | max(version) |
+-----------------------+---------------+
| 4 | 6.2.0 |
+-----------------------+---------------+
+-----------------------+---------------+
| max(_commit_version) | max(version) |
+-----------------------+---------------+
| 4 | 6.2.0 |
+-----------------------+---------------+
C
+-----------------------+---------------+
| max(_commit_version) | max(version) |
+-----------------------+---------------+
| 4 | 5.1.0 |
+-----------------------+---------------+
+-----------------------+---------------+
| max(_commit_version) | max(version) |
+-----------------------+---------------+
| 4 | 5.1.0 |
+-----------------------+---------------+
D
+-----------------------+---------------+
| D91873(_commit_version) | max(version) |
+-----------------------+---------------+
| 3 | 1.3.0 |
+-----------------------+---------------+
+-----------------------+---------------+
| D91873(_commit_version) | max(version) |
+-----------------------+---------------+
| 3 | 1.3.0 |
+-----------------------+---------------+
E
+-----------------------+---------------+
| max(_commit_version) | max(version) |
+-----------------------+---------------+
| 3 | 5.1.0 |
+-----------------------+---------------+
+-----------------------+---------------+
| max(_commit_version) | max(version) |
+-----------------------+---------------+
| 3 | 5.1.0 |
+-----------------------+---------------+