Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Mongodb with hive : Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. com/mongodb/hadoop/io/BSONWritable

avatar
Expert Contributor

Jar -> mongo-hadoop-core-1.4.0,mongo-hadoop-hive-1.4.0,mongo-java-driver-2.10.1

hive> CREATE EXTERNAL TABLE minute_bars > ( > > id STRING, > Symbol STRING, > `Timestamp` STRING, > Day INT, > Open DOUBLE, > High DOUBLE, > Low DOUBLE, > Close DOUBLE, > Volume INT > ) > STORED BY 'com.mongodb.hadoop.hive.MongoStorageHandler' > WITH SERDEPROPERTIES('mongo.columns.mapping'='{"id":"_id", > "Symbol":"Symbol", "Timestamp":"Timestamp", "Day":"Day", "Open":"Open", "High":"High", "Low":"Low", "Close":"Close", "Volume":"Volume"}') > TBLPROPERTIES('mongo.uri'='mongodb://localhost:27017/marketdata.minbars'); FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. com/mongodb/hadoop/io/BSONWritable hive>

1 ACCEPTED SOLUTION

avatar
Master Mentor

have you seen this https://community.hortonworks.com/content/repo/4538/hdp-mongo-tutorial.html ? Also mongo driver is now at 1.4.2, it may be worth your time to use latest jar. https://github.com/mongodb/mongo-hadoop/releases

View solution in original post

5 REPLIES 5

avatar
Super Guru

You could try adding both the "mongo-hadoop-hive.jar" and "mongo-hadoop-core.jar" to the hive.aux.jars.path setting in your hive-site.xml.

Or

You can simply add those jars in your hive shell like,

hive> add "somepath/mongo-hadoop-hive.jar"

hive> add "somepath/mongo-hadoop-core.jar"

avatar
Expert Contributor

i alrady done that step

hive> add "somepath/mongo-hadoop-hive.jar"

hive> add "somepath/mongo-hadoop-core.jar"

avatar
Super Guru

Ok, can you also try using hive aux path?

avatar
Master Mentor

have you seen this https://community.hortonworks.com/content/repo/4538/hdp-mongo-tutorial.html ? Also mongo driver is now at 1.4.2, it may be worth your time to use latest jar. https://github.com/mongodb/mongo-hadoop/releases

avatar
Master Mentor

I got it to work with the following in my repo I linked earlier

hdfs dfs -put drivers/* /tmp/udfs

beeline
!connect jdbc:hive2://localhost:10000 “” ””

add jar hdfs://sandbox.hortonworks.com:8020/tmp/udfs/mongo-hadoop-hive-1.5.0-SNAPSHOT.jar;
add jar hdfs://sandbox.hortonworks.com:8020/tmp/udfs/mongo-hadoop-core-1.5.0-SNAPSHOT.jar;
add jar hdfs://sandbox.hortonworks.com:8020/tmp/udfs/mongodb-driver-3.0.4.jar;
DROP TABLE IF EXISTS bars;
CREATE EXTERNAL TABLE bars
(
objectid STRING,
    Symbol STRING,
    TS STRING,
    Day INT,
    Open DOUBLE,
    High DOUBLE,
    Low DOUBLE,
    Close DOUBLE,
    Volume INT
)
STORED BY 'com.mongodb.hadoop.hive.MongoStorageHandler'
WITH SERDEPROPERTIES('mongo.columns.mapping'='{"objectid":"_id",
 "Symbol":"Symbol", "TS":"Timestamp", "Day":"Day", "Open":"Open", "High":"High", "Low":"Low", "Close":"Close", "Volume":"Volume"}')
TBLPROPERTIES('mongo.uri'='mongodb://localhost:27017/marketdata.minibars');