Unit 4: Introduction to Apache Hive - Practice Quiz

INT312 — Big Data Fundamentals 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 Which software framework is commonly required for installing and running Apache Hive?

Hive installation Easy
A. Apache Spark
B. Apache Kafka
C. Apache Flink
D. Apache Hadoop

2 Which environment variable usually points to the Apache Hive installation directory?

Hive installation Easy
A. HADOOP_HOME
B. SPARK_HOME
C. HIVE_HOME
D. JAVA_HOME

3 Which file is commonly used to configure Apache Hive settings?

Hive installation Easy
A. kafka-site.xml
B. core-site.xml
C. spark-site.xml
D. hive-site.xml

4 Which Hive data type is used to store whole numbers?

Hive data types Easy
A. STRING
B. INT
C. BOOLEAN
D. DATE

5 Which Hive data type is used to store text?

Hive data types Easy
A. STRING
B. FLOAT
C. TIMESTAMP
D. BOOLEAN

6 Which of the following is a complex data type in Hive?

Hive data types Easy
A. DOUBLE
B. INT
C. BOOLEAN
D. ARRAY

7 What does Hive bucketing primarily do?

Hive bucketing Easy
A. Encrypts table columns
B. Renames table fields
C. Deletes duplicate rows
D. Distributes rows into files

8 Which clause is used to define bucket columns in a Hive table?

Hive bucketing Easy
A. CLUSTERED BY
B. ORDERED BY
C. GROUPED BY
D. PARTITIONED BY

9 Which phrase specifies the number of buckets in a Hive table definition?

Hive bucketing Easy
A. INTO 4 BUCKETS
B. WITH 4 PARTITIONS
C. USING 4 GROUPS
D. HAVING 4 FILES

10 What is the main purpose of partitioning a Hive table?

Hive partitioning Easy
A. To combine all table columns
B. To encrypt each table row
C. To divide data by column values
D. To convert data into JSON

11 Which clause is used to define partition columns in Hive?

Hive partitioning Easy
A. DISTRIBUTED BY
B. PARTITIONED BY
C. SORTED BY
D. CLUSTERED BY

12 What is partition pruning in Hive?

Hive partitioning Easy
A. Deleting all empty partitions
B. Sorting every table partition
C. Merging partitions into one
D. Reading only relevant partitions

13 Which HiveQL statement creates a new table?

HiveQL operations Easy
A. MAKE TABLE
B. GENERATE TABLE
C. CREATE TABLE
D. BUILD TABLE

14 Which HiveQL statement retrieves data from a table?

HiveQL operations Easy
A. UPDATE
B. ALTER
C. INSERT
D. SELECT

15 Which HiveQL statement adds query results to an existing table?

HiveQL operations Easy
A. DESCRIBE TABLE
B. INSERT INTO
C. ALTER TABLE
D. TRUNCATE TABLE

16 Which HiveQL statement removes both a table definition and its managed data?

HiveQL operations Easy
A. DELETE TABLE
B. DROP TABLE
C. TRUNCATE TABLE
D. CLEAR TABLE

17 Which operator tests whether two values are equal in HiveQL?

Hive operators Easy
A. <=
B. <>
C. =
D. >=

18 Which logical operator requires both conditions to be true?

Hive operators Easy
A. OR
B. NOT
C. XOR
D. AND

19 Which arithmetic operator is used for addition in HiveQL?

Hive operators Easy
A. -
B. *
C. +
D. /

20 In a HiveQL LIKE pattern, which symbol represents any sequence of characters?

Hive operators Easy
A. %
B. _
C. #
D. &

21 After installing Hive with an external MySQL metastore, Hive fails because the metastore tables do not exist. Which command should be run before starting Hive?

Hive installation Medium
A. beeline -dbType mysql -createSchema
B. hive --service mysql -initSchema
C. schematool -dbType mysql -initSchema
D. hdfs dfs -mkdir mysql -initSchema

22 A team uses Hive's default embedded Derby metastore. Why might two developers be unable to run separate Hive sessions simultaneously from the same installation directory?

Hive installation Medium
A. HDFS permits only one client per directory
B. Beeline requires a separate Hadoop cluster per user
C. HiveServer2 supports only one authenticated user
D. Embedded Derby generally permits only one active process

23 Hive is installed successfully, but creating a managed table fails because Hive cannot write to its warehouse directory in HDFS. Which action most directly addresses the problem?

Hive installation Medium
A. Disable HDFS checksums for the warehouse directory
B. Move the metastore database into the warehouse directory
C. Increase the replication factor of the warehouse directory
D. Grant Hive write permission on the warehouse directory

24 A table stores a variable-length list of product identifiers for each order. Which Hive data type is most appropriate for the product_ids column?

Hive data types Medium
A. STRUCT<STRING>
B. MAP<STRING,STRING>
C. ARRAY<STRING>
D. UNIONTYPE<STRING>

25 A customer column must contain name, email, and age as named fields within a single value. Which declaration best represents this requirement?

Hive data types Medium
A. UNIONTYPE<name:STRING,email:STRING,age:INT>
B. MAP<name:STRING,email:STRING,age:INT>
C. STRUCT<name:STRING,email:STRING,age:INT>
D. ARRAY<name:STRING,email:STRING,age:INT>

26 A financial table must store monetary amounts with exactly two fractional digits and up to ten total digits. Which Hive type is the best choice?

Hive data types Medium
A. FLOAT
B. DOUBLE
C. BIGINT
D. DECIMAL(10,2)

27 A table is declared with CLUSTERED BY (customer_id) INTO 16 BUCKETS. How is a row normally assigned to a bucket?

Hive bucketing Medium
A. Using a hash of customer_id modulo 16
B. Using the row number modulo 16
C. Using the file size divided by 16
D. Using the partition number modulo 16

28 Two large tables are bucketed on customer_id using compatible bucket counts and bucketing rules. Which workload is most likely to benefit?

Hive bucketing Medium
A. A scan that selects every row and column
B. A join between the tables on customer_id
C. A sort by an unrelated description column
D. A filter on an unrelated timestamp column

29 A bucketed table contains 32 buckets. An analyst needs a repeatable sample based on the bucketing column. Which clause is designed for this purpose?

Hive bucketing Medium
A. TABLESAMPLE(BUCKET 1 OUT OF 8 ON customer_id)
B. SAMPLE 1 PERCENT ON customer_id
C. PARTITION(BUCKETS = 8, customer_id)
D. LIMIT 8 BY customer_id

30 A table is declared as bucketed into eight buckets, but data files are copied directly into its directory without applying the bucketing logic. What is the main consequence?

Hive bucketing Medium
A. Bucket-based optimizations may produce unreliable behavior
B. The table is automatically converted into eight partitions
C. The metastore rejects all queries against the table
D. Hive automatically redistributes the files during every query

31 A sales table is partitioned by sale_date. Which query is most likely to benefit from partition pruning?

Hive partitioning Medium
A. SELECT * FROM sales WHERE sale_date = '2025-01-15'
B. SELECT * FROM sales WHERE customer_id = 100
C. SELECT * FROM sales WHERE amount > 500
D. SELECT * FROM sales WHERE product_name LIKE 'A%'

32 Data for a new static partition must be loaded into a table partitioned by year and month. Which statement correctly targets March 2025?

Hive partitioning Medium
A. LOAD DATA INPATH '/data/march' INTO TABLE sales PARTITION(year=2025, month=3)
B. LOAD PARTITION(year=2025, month=3) DATA INPATH '/data/march' INTO sales
C. LOAD DATA INPATH '/data/march' INTO PARTITION sales(year=2025, month=3)
D. LOAD DATA INPATH '/data/march' INTO TABLE sales BUCKET(year=2025, month=3)

33 A table is partitioned by the exact event_timestamp, producing thousands of tiny partitions each day. Which redesign is generally more practical?

Hive partitioning Medium
A. Partition by every distinct timestamp and increase replication
B. Partition by derived date and retain the timestamp as a column
C. Remove the timestamp column and partition by row number
D. Partition by file name and derive timestamps during each query

34 Partition directories already exist in HDFS, but their metadata was not added to the Hive metastore. Which command can discover and register them?

Hive partitioning Medium
A. ANALYZE TABLE sales REPAIR
B. MSCK REPAIR TABLE sales
C. ALTER TABLE sales REBUILD
D. DESCRIBE FORMATTED sales

35 A query must return each department and its average salary, but only for departments whose average exceeds 60000. Which clause should contain the aggregate condition?

HiveQL operations Medium
A. HAVING AVG(salary) > 60000
B. ORDER BY AVG(salary) > 60000
C. WHERE AVG(salary) > 60000
D. DISTRIBUTE BY AVG(salary) > 60000

36 A query needs a globally ordered result by total_sales across all output rows. Which HiveQL clause should be used?

HiveQL operations Medium
A. DISTRIBUTE BY total_sales
B. CLUSTER BY total_sales
C. ORDER BY total_sales
D. SORT BY total_sales

37 A developer wants to replace the existing data in a target table with the result of a query. Which HiveQL form is appropriate?

HiveQL operations Medium
A. REPLACE TABLE target USING SELECT * FROM source
B. INSERT OVERWRITE TABLE target SELECT * FROM source
C. UPDATE OVERWRITE TABLE target SELECT * FROM source
D. INSERT INTO TABLE target SELECT * FROM source

38 Which condition selects employees whose salary is between 40000 and 60000, including both boundary values?

Hive operators Medium
A. salary IN (40000, 60000)
B. salary LIKE '40000-60000'
C. salary BETWEEN 40000 AND 60000
D. salary > 40000 AND salary < 60000

39 A query must find rows where middle_name has no value. Which predicate correctly handles Hive's null semantics?

Hive operators Medium
A. middle_name IS NULL
B. middle_name == NULL
C. middle_name = NULL
D. middle_name LIKE NULL

40 A tags column has type ARRAY<STRING>. Which expression accesses the first tag in the array?

Hive operators Medium
A. tags[1]
B. tags.first
C. tags('0')
D. tags[0]

41 A development team starts HiveServer2 with the default embedded Derby metastore. The first session works, but a second concurrent Hive process fails to access metadata. What is the most appropriate production fix?

Hive installation Hard
A. Run each Hive process with a different HDFS replication factor and execution engine
B. Configure a standalone relational database and run the Hive metastore as a service
C. Increase the Derby transaction timeout in the Hadoop configuration files
D. Create a separate warehouse directory for every concurrent Hive process

42 HiveServer2 must use a remote metastore available at thrift://meta1:9083. Which client-side setting establishes this connection?

Hive installation Hard
A. Set hive.metastore.warehouse.dir to thrift://meta1:9083 and restart HDFS
B. Set hive.server2.thrift.bind.host to meta1:9083
C. Set javax.jdo.option.ConnectionURL to thrift://meta1:9083
D. Set hive.metastore.uris to thrift://meta1:9083

43 After upgrading Hive binaries, startup reports that the PostgreSQL metastore schema version is older than the Hive software version. Assuming the database is backed up, which action directly addresses the mismatch?

Hive installation Hard
A. Run schematool -dbType postgres -upgradeSchema
B. Run schematool -dbType postgres -initSchema
C. Run hdfs namenode -format before restarting the metastore service
D. Delete the warehouse directory and recreate the database

44 HiveServer2 can connect to the metastore, but queries fail with permission errors while creating managed tables under /user/hive/warehouse. Which installation issue is most directly implicated?

Hive installation Hard
A. The Hive CLI history file has an incompatible local filesystem owner
B. The Hive service identity lacks suitable HDFS permissions on the warehouse path
C. The metastore JDBC user lacks permission to create HDFS directories
D. The NameNode must be configured to store Hive table schemas inside each data file

45 A value stored as DECIMAL(5,2) is rounded from 999.995 to two fractional digits. What is the smallest decimal type that can represent the rounded result without overflow?

Hive data types Hard
A. DECIMAL(7,3), because rounding always requires one additional integer and fractional digit
B. DECIMAL(6,3)
C. DECIMAL(5,2)
D. DECIMAL(6,2)

46 Two columns contain CHAR(5) value ab and VARCHAR(5) value ab , respectively. Which statement correctly describes Hive's trailing-space semantics?

Hive data types Hard
A. Both types preserve padding identically, but Hive converts them to BINARY during equality tests
B. Both types always remove trailing spaces before storage and comparison
C. CHAR comparisons ignore trailing spaces, while VARCHAR trailing spaces remain significant
D. VARCHAR comparisons ignore trailing spaces, while CHAR trailing spaces remain significant

47 Given a ARRAY<INT> and m MAP<STRING,INT>, what does Hive return for a[0] and m['missing'] when a = array(7,8) and the map has no missing key?

Hive data types Hard
A. NULL and NULL
B. 8 and 0
C. 7 and an exception, because absent map keys cannot be evaluated in a projection
D. 7 and NULL

48 For a column declared UNIONTYPE<INT,STRING,DOUBLE>, which expression constructs the string alternative containing high?

Hive data types Hard
A. create_union('STRING', 'high'), using the member type name instead of a numeric tag
B. create_union(2, 'high')
C. create_union(1, 'high')
D. create_union(0, 'high')

49 A table is declared CLUSTERED BY (customer_id) INTO 32 BUCKETS, but existing files were copied into its directory without being written by a bucketing-aware Hive operation. Which conclusion is valid?

Hive bucketing Hard
A. The table becomes partitioned by customer_id, allowing pruning to replace bucket validation
B. Hive automatically rehashes copied files when the table is queried for the first time
C. The metadata alone does not guarantee that rows are physically assigned to correct buckets
D. Every file is valid if the directory contains exactly 32 files, regardless of row placement

50 Table L has 8 buckets on id, and table R has 24 buckets on id. Ignoring other optimizer constraints, which property supports a bucket map join on L.id = R.id?

Hive bucketing Hard
A. One bucket count is an integer multiple of the other
B. Both bucket counts must be powers of two with identical exponents
C. The larger table has more buckets, so Hive can join corresponding files without inspecting the bucket columns
D. The bucket counts are equal after taking their arithmetic mean

51 Assume an integer bucket key uses bucket number (hash(key) & 0x7fffffff) % 4, with hash(key) = key. Into which bucket is key -3 placed?

Hive bucketing Hard
A. Bucket 3, because ordinary signed remainder preserves the negative key's magnitude
B. Bucket 2
C. Bucket 0
D. Bucket 1

52 A table is partitioned by (dt STRING, region STRING). For INSERT ... PARTITION (dt, region) with both partitions dynamic, how must the source projection be arranged?

Hive partitioning Hard
A. Partition values may appear anywhere because Hive matches them by source column name
B. The region and dt values must be the first columns in reverse partition-key order
C. Dynamic values must be omitted from the projection because Hive derives both from the input file path
D. The dt and region values must be the final columns in that partition-key order

53 With hive.exec.dynamic.partition.mode=strict, which insertion into a table partitioned by (dt, country) is permitted?

Hive partitioning Hard
A. PARTITION (dt, country) with DISTRIBUTE BY dt, country added to make every partition dynamic
B. PARTITION (dt, country) with both values selected dynamically
C. PARTITION (dt='2025-01-01', country) with country selected dynamically
D. PARTITION (dt, country) with both values generated by deterministic functions

54 A table is partitioned by string column dt in ISO format. A query filters with year(to_date(dt)) = 2025, but the optimizer cannot infer a direct partition constraint from that function. Which rewrite most directly enables partition pruning for 2025?

Hive partitioning Hard
A. date_format(to_date(dt), 'yyyy') = '2025', which normalizes every partition value before scanning
B. dt >= '2025-01-01' AND dt < '2026-01-01'
C. cast(substr(dt,1,4) AS INT) = 2025
D. year(to_date(dt)) BETWEEN 2025 AND 2025

55 A source table feeds three aggregate tables with different filters. Which HiveQL structure is designed to express the work while sharing a single source scan?

HiveQL operations Hard
A. Three independent INSERT statements enclosed in one transaction
B. A UNION ALL query whose branches each overwrite a different target table
C. A multi-table insert using one FROM clause and three INSERT branches
D. A chained MERGE statement that updates all target tables through one matched source condition

56 A query must retain every row from customers, including customers with no qualifying order. Which placement of o.status = 'PAID' preserves that requirement?

HiveQL operations Hard
A. Place it in the WHERE clause after the LEFT OUTER JOIN
B. Place it in a HAVING clause without grouping the order rows
C. Place it in the ON clause of the LEFT OUTER JOIN
D. Place it in both ON and WHERE so Hive can eliminate duplicate null-extended rows

57 A partitioned table contains data for many dates. What is the effect of INSERT OVERWRITE TABLE sales PARTITION (dt='2025-03-01') SELECT ...?

HiveQL operations Hard
A. It replaces only the specified partition's data
B. It replaces every partition in the table
C. It drops the partition metadata permanently and writes the selected rows into the table root
D. It appends data to the specified partition

58 For nullable columns a and b, which predicate evaluates to TRUE when both values are NULL and to FALSE when exactly one is NULL?

Hive operators Hard
A. a IS NULL OR b IS NULL
B. coalesce(a, b) IS NULL, combined with ordinary equality for every non-null case
C. a <=> b
D. a = b

59 For a non-null value x = 1, a subquery used by x NOT IN (...) returns the set {2, NULL}. Under SQL three-valued logic, what is the predicate's result?

Hive operators Hard
A. TRUE, because 1 differs from 2
B. FALSE, because every set containing NULL matches all values
C. UNKNOWN, so a WHERE clause filters the row out
D. NULL, but a WHERE clause automatically converts it to TRUE for non-null x

60 Given Boolean values a = TRUE, b = FALSE, and c = FALSE, what is the result of a OR b AND c under Hive operator precedence?

Hive operators Hard
A. TRUE, because AND is evaluated before OR
B. NULL, because mixed logical operators require explicit parentheses
C. FALSE, because Hive evaluates all Boolean operators strictly from left to right regardless of precedence
D. FALSE, because OR is evaluated before AND