Thread: Nested fields with Mongo FDW

Nested fields with Mongo FDW

From
Michael Contraveos
Date:
Hello,

I recently installed a PostgreSQL server to this spec:

server v9.3.6
EnterpriseDB mongo_fdw vREL-4_0_0
libbson v1.1.5
mongo C driver v1.1.5

and Mongo is at 2.7.1. Mapping fields in Mongo documents, including _id, has been successful, with the exception of nested fields. Assuming my Mongo document looks like this:

{
    "_id" : ObjectId("5550ebf18cf0280b5fec373a"),
    "message": {
        "order_id": 15
    }
}

I would think this table should do:

CREATE FOREIGN TABLE ats.messages (
    _id NAME,
    "message.order_id" INT
)
SERVER mongo_server OPTIONS (database 'db', collection 'test_collection')

While that doesn't raise any errors, any SELECT against the table shows "message.order_id" as empty. Are nested fields supported in this version of mongo_fdw? If so, what's the proper way to map nested fields to table columns?

thank you,
MC