0
0
Hadoopdata~10 mins

Partitioning for query performance in Hadoop - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a partitioned table by the column 'year'.

Hadoop
CREATE TABLE sales_data (id INT, amount FLOAT) PARTITIONED BY ([1] STRING);
Drag options to blanks, or click blank then click option'
Amonth
Bregion
Cyear
Dcategory
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a non-time column like 'region' or 'category' for partitioning.
Forgetting to specify the partition column in the table definition.
2fill in blank
medium

Complete the code to insert data into the partition for year 2023.

Hadoop
INSERT INTO sales_data PARTITION (year=[1]) SELECT id, amount FROM raw_sales WHERE year = 2023;
Drag options to blanks, or click blank then click option'
A'2023'
B2023
C'2022'
Dyear
Attempts:
3 left
💡 Hint
Common Mistakes
Using the number 2023 without quotes.
Using a column name instead of a literal value.
3fill in blank
hard

Fix the error in the query to select data only from the 2022 partition.

Hadoop
SELECT * FROM sales_data WHERE year [1] '2022';
Drag options to blanks, or click blank then click option'
A==
B=
CLIKE
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '=' causes syntax errors.
Using 'LIKE' without wildcards is incorrect here.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length if the length is greater than 3.

Hadoop
{word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Blen(word) > 3
Cword
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'word' instead of 'len(word)' for the value.
Using 'word > 3' which compares string to number incorrectly.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase keys to values only if the value is greater than 0.

Hadoop
result = [1]: [2] for [3], [2] in data.items() if [2] > 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
Ck
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'value' instead of 'v' as the loop variable.
Not converting keys to uppercase.