Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Snowflake ARA-R01 Exam - Topic 4 Question 21 Discussion

Posted by Von on Sep 13, 2024 at 12:53 PM

A new table and streams are created with the following commands:

CREATE OR REPLACE TABLE LETTERS (ID INT, LETTER STRING) ;

CREATE OR REPLACE STREAM STREAM_1 ON TABLE LETTERS;

CREATE OR REPLACE STREAM STREAM_2 ON TABLE LETTERS APPEND_ONLY = TRUE;

The following operations are processed on the newly created table:

INSERT INTO LETTERS VALUES (1, 'A');

INSERT INTO LETTERS VALUES (2, 'B');

INSERT INTO LETTERS VALUES (3, 'C');

TRUNCATE TABLE LETTERS;

INSERT INTO LETTERS VALUES (4, 'D');

INSERT INTO LETTERS VALUES (5, 'E');

INSERT INTO LETTERS VALUES (6, 'F');

DELETE FROM LETTERS WHERE ID = 6;

What would be the output of the following SQL commands, in order?

SELECT COUNT (*) FROM STREAM_1;

SELECT COUNT (*) FROM STREAM_2;

Suggested Answer: C

In Snowflake, a stream records data manipulation language (DML) changes to its base table since the stream was created or last consumed. STREAM_1 will show all changes including the TRUNCATE operation, while STREAM_2, being APPEND_ONLY, will not show deletions like TRUNCATE. Therefore, STREAM_1 will count the three inserts, the TRUNCATE (counted as a single operation), and the subsequent two inserts before the delete, totaling 4. STREAM_2 will only count the three initial inserts and the two after the TRUNCATE, totaling 3, as it does not count the TRUNCATE or the delete operation.


Get Premium ARA-R01 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
32 comments · newest first
NO
Novella 10 months ago
Not sure about that, seems off to me.
FL
Florinda 11 months ago
Totally agree, STREAM_1 is 2 for sure!
KA
Katy 11 months ago
Wait, how does TRUNCATE affect the streams?
TO
Toshia 11 months ago
I think STREAM_2 will show 6.
FR
Francesco 11 months ago
STREAM_1 should have 2 records.
WI
Wilburn 11 months ago
I'm a bit confused about the delete operation. Does it affect the count in STREAM_2? I thought it would still be 3 for that one.
LA
Lashunda 12 months ago
I practiced a similar question, and I think the truncate affects STREAM_1 but not STREAM_2. So, could it be 2 and 6?
YO
Yoko 12 months ago
I remember that STREAM_2 is append-only, so it should keep all the inserts even after the truncate. That might mean it counts 6?
DO
Dorathy 12 months ago
I think STREAM_1 should count the inserts before the truncate, so maybe 2? But I'm not sure about STREAM_2.
VI
Vivan 12 months ago
This seems straightforward enough. The key is understanding how the APPEND_ONLY flag affects STREAM_2. I'm pretty confident I can work this out and select the right answer.
AM
Amber 12 months ago
I'm a bit confused by the APPEND_ONLY flag on STREAM_2. Does that mean it only captures new rows, and not updates or deletes? I'll need to double-check the documentation on that.
AN
Annice 1 year ago
Okay, let me think this through step-by-step. The first three INSERTs should be captured by both streams, then the TRUNCATE would clear both streams, and the final three INSERTs and DELETE would only be captured by STREAM_2. I think I've got it!
KI
Kimbery 1 year ago
Hmm, this looks like a tricky one. I'll need to carefully trace the sequence of operations on the table and streams to figure out the correct output.
AM
Amie 2 years ago
Wait, wait, wait... Did they just casually mention 'APPEND_ONLY' like it's no big deal? That's the key to this whole question, I can feel it. Time to put on my thinking cap and work this out!
HI
Hillary 2 years ago
↳ replying to Amie
So, the correct answer would be B) 2 & 3.
HA
Harris 2 years ago
↳ replying to Amie
For the second SELECT COUNT (*) FROM STREAM_2, I believe the output would be 3.
NO
Nobuko 2 years ago
↳ replying to Amie
I think the output for the first SELECT COUNT (*) FROM STREAM_1 would be 2.
JE
Jerry 2 years ago
Oh boy, this one's got me stumped. I'll just go with my gut and hope for the best. Maybe I'll get lucky and the answer will be 'C' - that's always a safe bet, right?
AN
Anglea 2 years ago
↳ replying to Jerry
I'm not sure about the answer, but let's see if 'C' is correct.
KA
Kati 2 years ago
↳ replying to Jerry
I believe the output for the second SELECT statement would be 3.
NA
Nathan 2 years ago
↳ replying to Jerry
I think the output for the first SELECT statement would be 2.
TI
Timmy 2 years ago
Hmm, I see your point. Let's think about the operations and try to figure it out.
WI
Willis 2 years ago
Hey, did you hear about the SQL developer who left his job? Apparently, he just couldn't handle all the table-turning situations anymore. Haha, get it? Table-turning? Oh, nevermind...
SO
Sommer 2 years ago
↳ replying to Willis
Let's see if the streams capture the changes correctly.
MA
Mariko 2 years ago
↳ replying to Willis
I believe the output will be D) 4 & 6.
BU
Buck 2 years ago
↳ replying to Willis
I think the output would be A) 2 & 6.
MI
Miesha 2 years ago
↳ replying to Willis
Haha, that's a good one!
MY
Myrtie 2 years ago
I disagree, I believe it would be 4 & 3.
TI
Timmy 2 years ago
I think the output would be 2 & 6.
AN
Annabelle 2 years ago
Hmm, looks like we're dealing with some data streaming here. I'm thinking the APPEND_ONLY stream should have more records than the regular stream, but let's see what the experts say.
IR
Ira 2 years ago
↳ replying to Annabelle
No, I believe it would be 4 for STREAM_1 and 3 for STREAM_2.
ME
Meaghan 2 years ago
↳ replying to Annabelle
I think the output would be 2 for STREAM_1 and 6 for STREAM_2.
0/2000 characters

Save Cancel