SOL-C01 · Question #177
You have a Snowflake table named 'employees' with columns 'employee_id', 'name', 'department', and 'salary'. You need to load data from a fixed-width file located in an internal stage named…
The correct answer is B. Option B. The actual code for options A–E wasn't included in the question, so a specific per-option analysis isn't possible. That said, here's what makes an answer correct for this scenario and what traps the distractors likely set: Why B is correct: Loading a fixed-width file in…
Question
You have a Snowflake table named 'employees' with columns 'employee_id', 'name', 'department', and 'salary'. You need to load data from a fixed-width file located in an internal stage named 'employee_stage'. The file format is as follows: 'employee_id' (5 characters), name' (20 characters), 'department' (15 characters), and 'salary' (10 characters). Which of the following demonstrates the correct way to create the file format and then load the data into the 'employees' table, assuming all columns are of type STRING in the target table?
Exhibit
Options
- AOption A
- BOption B
- COption C
- DOption D
- EOption E
How the community answered
(51 responses)- A2% (1)
- B73% (37)
- C6% (3)
- D4% (2)
- E16% (8)
Explanation
The actual code for options A–E wasn't included in the question, so a specific per-option analysis isn't possible. That said, here's what makes an answer correct for this scenario and what traps the distractors likely set:
Why B is correct: Loading a fixed-width file in Snowflake requires creating a FILE FORMAT with TYPE = 'CSV', FIELD_DELIMITER = NONE, and RECORD_DELIMITER = '\n' (so the entire row is read as one field), then using a COPY INTO ... FROM (SELECT SUBSTR($1, pos, len) ... FROM @stage) transformation to slice each column out by character position. The character offsets would be: employee_id → SUBSTR($1,1,5), name → SUBSTR($1,6,20), department → SUBSTR($1,26,15), salary → SUBSTR($1,41,10).
Why distractors are wrong: Common wrong patterns include using TYPE = 'FIXED_WIDTH' (not a valid Snowflake type), using a character delimiter like a comma (corrupts fixed-width boundaries), omitting the SELECT SUBSTR(...) transformation and loading directly (Snowflake can't auto-split fixed-width), or using incorrect SUBSTR offsets (off-by-one errors from miscounting cumulative character positions).
Memory tip: Think "no delimiter + SUBSTR slicing" - fixed-width in Snowflake means you act as the delimiter by manually cutting the string. Write out the cumulative offsets (5, 5+20=25, 25+15=40, 40+10=50) before writing the query to avoid position errors.
Topics
Community Discussion
No community discussion yet for this question.
