Hive: Map

(Last Updated On: )

This tutorial will show you how to use map. If you have no installed Hive yet please follow this tutorial.

Create Table with Map:

  1. CREATE TABLE test_map (
  2. columnA STRING,
  3. columnB VARCHAR(15),
  4. columnC INT,
  5. columnD TIMESTAMP,
  6. columnE DATE,
  7. columnF MAP<STRING, INT>
  8. )
  9. STORED AS ORC;

Insert Data:

  1. INSERT INTO test_map
  2. SELECT '1', '2', 1, '2019-02-07 20:58:27', '2019-02-07', MAP('Val', 1);

Select Data:
This will give back the value of “Val” in columnF.

  1. SELECT columnF['Val']
  2. FROM test_map;