- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
how to use puthiveql in NIFI
- Labels:
-
Apache Hive
-
Apache NiFi
Created ‎06-09-2017 07:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have to first read a file from local directory using Getfile and then will be loading it into HDFS. Once the file is in HDFS, then I have copy it from hive based table and insert it into another hive table. For insert/select , I came to know that I need to use puthiveql through NIFI documentation. But I could not find any option in PutHiveQL where I can write my Insert-select query. Can anybody tell me that where is option in PutHiveQL to write the Hive query?
Thanks in advance.
Created on ‎06-09-2017 07:40 PM - edited ‎08-17-2019 09:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PutHiveQL is the correct processor to use. However, the SQL/HiveQL has to be formatted and passed to it by the previous processor.
For example, you can use the ReplaceText processor to build a HiveQL statement (e.g. INSERT INTO nifitest ...), and then pass the output to the PutHiveQL processor.
The above is the correct way to do it. However, there is also a workaround; by using the SelectHiveQL processor, you can write an insert statement as below.
Take a look at the below two links that will clarify everything with examples:
https://community.hortonworks.com/questions/52328/how-to-insert-data-into-hive-using-nifi.html
Created ‎06-09-2017 09:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using PutHiveql along with ReplaceText.
Data flow is running succesfully but my insert-select did not execute because final table is empty in which I am performing insert-select.
In replace text properties, I have left the search value as default and in Replacement Value I have written my insert-select query.
When I checked the log, I found below error:
Could not open client transport with JDBC Uri: jdbc:hive2://sandbox.hortonworks.com:2181/testdb: null
Created ‎06-11-2017 08:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It looks like you are trying to connect via the Zookeeper port, but there are some issues with this:
- You'll likely have trouble because of the issue described in NIFI-2575. Even if that were not the issue, the following two things would have to be done.
- I believe you'd have to set some variables in the URL (such as serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2)
- The Zookeeper port is not exposed via the sandbox by default, you would have to forward that port if using NAT.
For these reasons, I recommend you connect via the standard HiveServer2 port (10000), which is exposed by default for the sandbox's NAT configuration.
