- Reading & Writing Hive Tables
- Reading From Hive
- Writing To Hive
- Limitations
- Limitations
Reading & Writing Hive Tables
Using the HiveCatalog and Flink’s connector to Hive, Flink can read and write from Hive data as an alternative to Hive’s batch engine. Be sure to follow the instructions to include the correct dependencies in your application.
- Reading From Hive
- Writing To Hive
- Limitations
Reading From Hive
Assume Hive contains a single table in its default database, named people that contains several rows.
hive> show databases;OKdefaultTime taken: 0.841 seconds, Fetched: 1 row(s)hive> show tables;OKTime taken: 0.087 secondshive> CREATE TABLE mytable(name string, value double);OKTime taken: 0.127 secondshive> SELECT * FROM mytable;OKTom 4.72John 8.0Tom 24.2Bob 3.14Bob 4.72Tom 34.9Mary 4.79Tiff 2.72Bill 4.33Mary 77.7Time taken: 0.097 seconds, Fetched: 10 row(s)
With the data ready your can connect to Hive connect to an existing Hive installation and begin querying.
Flink SQL> show catalogs;myhivedefault_catalog# ------ Set the current catalog to be 'myhive' catalog if you haven't set it in the yaml file ------Flink SQL> use catalog myhive;# ------ See all registered database in catalog 'mytable' ------Flink SQL> show databases;default# ------ See the previously registered table 'mytable' ------Flink SQL> show tables;mytable# ------ The table schema that Flink sees is the same that we created in Hive, two columns - name as string and value as double ------Flink SQL> describe mytable;root|-- name: name|-- type: STRING|-- name: value|-- type: DOUBLEFlink SQL> SELECT * FROM mytable;name value__________ __________Tom 4.72John 8.0Tom 24.2Bob 3.14Bob 4.72Tom 34.9Mary 4.79Tiff 2.72Bill 4.33Mary 77.7
Writing To Hive
Similarly, data can be written into hive using an INSERT INTO clause.
Flink SQL> INSERT INTO mytable (name, value) VALUES ('Tom', 4.72);
Limitations
The following is a list of major limitations of the Hive connector. And we’re actively working to close these gaps.
- INSERT OVERWRITE is not supported.
- Inserting into partitioned tables is not supported.
- ACID tables are not supported.
- Bucketed tables are not supported.
- Some data types are not supported. See the limitations for details.
- Only a limited number of table storage formats have been tested, namely text, SequenceFile, ORC, and Parquet.
- Views are not supported.
