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 Hadoop
C. Apache Kafka
D. Apache Flink

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

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

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

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

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

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

5 Which Hive data type is used to store text?

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

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

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

7 What does Hive bucketing primarily do?

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

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

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

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

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

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

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

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

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

12 What is partition pruning in Hive?

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

13 Which HiveQL statement creates a new table?

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

14 Which HiveQL statement retrieves data from a table?

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

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

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

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

HiveQL operations Easy
A. DELETE TABLE
B. TRUNCATE TABLE
C. CLEAR TABLE
D. DROP 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. XOR
C. NOT
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. hive --service mysql -initSchema
B. schematool -dbType mysql -initSchema
C. hdfs dfs -mkdir mysql -initSchema
D. beeline -dbType mysql -createSchema

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. HiveServer2 supports only one authenticated user
B. HDFS permits only one client per directory
C. Embedded Derby generally permits only one active process
D. Beeline requires a separate Hadoop cluster per user

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. Increase the replication factor of the warehouse directory
B. Disable HDFS checksums for the warehouse directory
C. Grant Hive write permission on the warehouse directory
D. Move the metastore database into 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. UNIONTYPE<STRING>
B. ARRAY<STRING>
C. MAP<STRING,STRING>
D. STRUCT<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. STRUCT<name:STRING,email:STRING,age:INT>
C. MAP<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. BIGINT
B. FLOAT
C. DECIMAL(10,2)
D. DOUBLE

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 the row number modulo 16
B. Using a hash of customer_id 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 filter on an unrelated timestamp column
B. A sort by an unrelated description column
C. A scan that selects every row and column
D. A join between the tables on customer_id

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. SAMPLE 1 PERCENT ON customer_id
B. PARTITION(BUCKETS = 8, customer_id)
C. TABLESAMPLE(BUCKET 1 OUT OF 8 ON 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. The metastore rejects all queries against the table
B. The table is automatically converted into eight partitions
C. Bucket-based optimizations may produce unreliable behavior
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 amount > 500
C. SELECT * FROM sales WHERE product_name LIKE 'A%'
D. SELECT * FROM sales WHERE customer_id = 100

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 BUCKET(year=2025, month=3)
B. LOAD PARTITION(year=2025, month=3) DATA INPATH '/data/march' INTO sales
C. LOAD DATA INPATH '/data/march' INTO TABLE sales PARTITION(year=2025, month=3)
D. LOAD DATA INPATH '/data/march' INTO PARTITION sales(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 file name and derive timestamps during each query
C. Remove the timestamp column and partition by row number
D. Partition by derived date and retain the timestamp as a column

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. ALTER TABLE sales REBUILD
B. DESCRIBE FORMATTED sales
C. MSCK REPAIR TABLE sales
D. ANALYZE TABLE sales REPAIR

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. WHERE AVG(salary) > 60000
B. ORDER BY AVG(salary) > 60000
C. HAVING 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. ORDER BY total_sales
C. CLUSTER 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. INSERT INTO TABLE target SELECT * FROM source
B. REPLACE TABLE target USING SELECT * FROM source
C. UPDATE OVERWRITE TABLE target SELECT * FROM source
D. INSERT OVERWRITE 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 BETWEEN 40000 AND 60000
B. salary LIKE '40000-60000'
C. salary > 40000 AND salary < 60000
D. salary IN (40000, 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 = NULL
B. middle_name LIKE NULL
C. middle_name IS NULL
D. middle_name == NULL

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

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

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. Configure a standalone relational database and run the Hive metastore as a service
B. Run each Hive process with a different HDFS replication factor and execution engine
C. Create a separate warehouse directory for every concurrent Hive process
D. Increase the Derby transaction timeout in the Hadoop configuration files

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.server2.thrift.bind.host to meta1:9083
B. Set hive.metastore.uris to thrift://meta1:9083
C. Set javax.jdo.option.ConnectionURL to thrift://meta1:9083
D. Set hive.metastore.warehouse.dir to thrift://meta1:9083 and restart HDFS

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. Delete the warehouse directory and recreate the database
B. Run hdfs namenode -format before restarting the metastore service
C. Run schematool -dbType postgres -upgradeSchema
D. Run schematool -dbType postgres -initSchema

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 metastore JDBC user lacks permission to create HDFS directories
B. The Hive CLI history file has an incompatible local filesystem owner
C. The NameNode must be configured to store Hive table schemas inside each data file
D. The Hive service identity lacks suitable HDFS permissions on the warehouse path

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(5,2)
B. DECIMAL(6,3)
C. DECIMAL(7,3), because rounding always requires one additional integer and fractional digit
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. VARCHAR comparisons ignore trailing spaces, while CHAR trailing spaces remain significant
D. CHAR comparisons ignore trailing spaces, while VARCHAR 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. 7 and NULL
C. 8 and 0
D. 7 and an exception, because absent map keys cannot be evaluated in a projection

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

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

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

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. The larger table has more buckets, so Hive can join corresponding files without inspecting the bucket columns
B. Both bucket counts must be powers of two with identical exponents
C. One bucket count is an integer multiple of the other
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 2
B. Bucket 3, because ordinary signed remainder preserves the negative key's magnitude
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. The dt and region values must be the final columns in that partition-key order
B. Dynamic values must be omitted from the projection because Hive derives both from the input file path
C. Partition values may appear anywhere because Hive matches them by source column name
D. The region and dt values must be the first columns in reverse 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='2025-01-01', country) with country selected dynamically
C. PARTITION (dt, country) with both values 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. dt >= '2025-01-01' AND dt < '2026-01-01'
B. cast(substr(dt,1,4) AS INT) = 2025
C. year(to_date(dt)) BETWEEN 2025 AND 2025
D. date_format(to_date(dt), 'yyyy') = '2025', which normalizes every partition value before scanning

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

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 both ON and WHERE so Hive can eliminate duplicate null-extended rows
B. Place it in the WHERE clause after the LEFT OUTER JOIN
C. Place it in the ON clause of the LEFT OUTER JOIN
D. Place it in a HAVING clause without grouping the order 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 appends data to the specified partition
B. It drops the partition metadata permanently and writes the selected rows into the table root
C. It replaces every partition in the table
D. It replaces only the specified partition's data

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 <=> b
B. a IS NULL OR b IS NULL
C. a = b
D. coalesce(a, b) IS NULL, combined with ordinary equality for every non-null case

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. FALSE, because every set containing NULL matches all values
B. NULL, but a WHERE clause automatically converts it to TRUE for non-null x
C. UNKNOWN, so a WHERE clause filters the row out
D. TRUE, because 1 differs from 2

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. NULL, because mixed logical operators require explicit parentheses
B. FALSE, because Hive evaluates all Boolean operators strictly from left to right regardless of precedence
C. FALSE, because OR is evaluated before AND
D. TRUE, because AND is evaluated before OR