Support Questions
Find answers, ask questions, and share your expertise

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

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

Accepted Solutions

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

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"

Contributor

i alrady done that step

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

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

Ok, can you also try using hive aux path?

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

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');