Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

export data from mongodb to hive,export from mongo to hive

Highlighted

export data from mongodb to hive,export from mongo to hive

New Contributor

=>my input: a collection("demo1") in mongo db (version 3.4.4 )

=>my output : my data imported in a database in hive("demo2") (version 1.2.1.2.3.4.7-4)

=>purpose : create a connector between mongo and hive

Error that i got:

Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. com/mongodb/util/JSON

---------------explanation----------------

i tried 2 solutions following those steps (but the error remain ):

1/i create a local collection in mongo(via robomongo) connected to docker

2/i upload those version of jars and add it in hive

ADD JAR /home/.../mongo-hadoop-hive-2.0.2.jar;

ADD JAR /home/.../mongo-hadoop-core-2.0.2.jar;

ADD JAR /home/.../mongo-java-driver-3.4.2.jar;

unfortunately the error does'nt change ; so i upload those version , i hesitate in choosing right version for my export , so i try this

ADD JAR /home/.../mongo-hadoop-hive-1.3.0.jar;

ADD JAR /home/.../mongo-hadoop-core-1.3.0.jar;

ADD JAR /home/.../mongo-java-driver-2.13.2.jar;

3/i create an external table

CREATE EXTERNAL TABLE demo2

(

id INT,

name STRING,

password STRING,

email STRING

)

STORED BY 'com.mongodb.hadoop.hive.MongoStorageHandler'

WITH

SERDEPROPERTIES('mongo.columns.mapping'='{"id":"_id","name":"name","password":"password","email":"email"}')

TBLPROPERTIES('mongo.uri'='mongodb://localhost:27017/local.demo1');

=> Error returned in hive :

Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. com/mongodb/util/JSON

---------------- how could i resolve the problem ? ---------------------------

2 REPLIES 2
Highlighted

Re: export data from mongodb to hive,export from mongo to hive

New Contributor

the answer is : TBLPROPERTIES('mongo.uri'='mongodb://localhost:27017/local.demo1'); i replaced the 'localhost' by my ip adress , it works !

Highlighted

Re: export data from mongodb to hive,export from mongo to hive

The answer is : TBLPROPERTIES('mongo.uri'='mongodb://localhost:27017/local.demo1'); i replaced the 'localhost' by my ip adress , it works !

Don't have an account?
Coming from Hortonworks? Activate your account here