1
votes

I'm trying to retrieve all(*) columns from a MongoDB object with Apache Drill expression SQL:

`_id`.`$oid`

Background: I'm using Apache Drill to query MongoDB collections. By default, Drill retrieves the ObjectId values in a different format than the stored in the database. For example:

Mongo: ObjectId(“59f2c3eba83a576fe07c735c”)

Drill query result: [B@3149a…]

In order to get the data in String format (59f2c3eba83a576fe07c735c) from the object, I changed the Drill config "store.mongo.bson.record.reader" to "false".

ALTER SESSION SET store.mongo.bson.record.reader = false

Drill query result after config set to false:

select * from calc;
+--------------------------------------+---------+
|                 _id                  |  name   |
+--------------------------------------+---------+
| {"$oid":"5cb0e161f0849231dfe16d99"}  | thiago  |
+--------------------------------------+---------+

Running a query by _id:

 select `o`.`_id`.`$oid` , `o`.`name` from mongo.od_teste.calc o where `o`.`_id`.`$oid`='5cb0e161f0849231dfe16d99';

Result:

+---------------------------+---------+
|          EXPR$0           |  name   |
+---------------------------+---------+
| 5cb0e161f0849231dfe16d99  | thiago  |
+---------------------------+---------+

For an object with a few columns like the one above (_id, name) it's ok to specify all the columns in the select query by id. However, in my production database, the objects have a "hundred" of columns.

If I try to query all (*) columns from the collection, this is the result:

select `o`.* from mongo.od_teste.calc o where `o`.`_id`.`$oid`='5cb0e161f0849231dfe16d99';

or

select * from mongo.od_teste.calc o where `o`.`_id`.`$oid`='5cb0e161f0849231dfe16d99';
+-----+
| **  |
+-----+
+-----+
No rows selected (6.112 seconds)

Expected result: Retrieve all columns from a MongoDB collection instead of declaring all of them on the SQL query.

1

1 Answers

0
votes

I have no suggestions here, because it is a bug in Mongo Storage Plugin.
I have created Jira ticket for it, please take a look and feel free to add any related info there: DRILL-7176