You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by mishadoff <mi...@gmail.com> on 2015/11/26 13:06:57 UTC

Add new field to mongo db collection

Hello All,

We encountered an issue where we can’t add new fields into MongoDB collection, using MetaModel api because of schema validation.

Initially in accounts table we have three fields [_id, name, createdDate] and MetaModel is succesfully identified them by sampling.
DataSet ds = dc.query()
        .from("accounts")
        .selectAll()
        .execute();
System.out.println(ds.toRows()); // [_id, name, createdDate]

dc.executeUpdate((c) -> {
    c.insertInto("accounts")
            //.value("_id", 123)   _id will be autogenerated
            .value("name", "default")
            .value("createdDate", new Date())
            .value("active", false)
            .execute();
});
After creating new document with the NEW active field, it complies = No such column in table: active

I understand that schema validation step is required for RDBMS sources, and therefore MetaModel API requires it. 
But is there simple way to bypass this check?


Re: Add new field to mongo db collection

Posted by mishadoff <mi...@gmail.com>.
Thanks Kasper, that is exactly the issue, let’s move discussion to JIRA.

> On Nov 26, 2015, at 17:14, Kasper Sørensen <i....@gmail.com> wrote:
> 
> Hi Misha,
> 
> Have you checked out https://issues.apache.org/jira/browse/METAMODEL-189 ?
> It seems you're not alone to think that MMs behaviour should be different
> here.
> 
> Myself I am torn. But let me explain my trail of thought on that issue, as
> a comment :-)
> 
> Kasper
> 
> 2015-11-26 13:06 GMT+01:00 mishadoff <mi...@gmail.com>:
> 
>> Hello All,
>> 
>> We encountered an issue where we can’t add new fields into MongoDB
>> collection, using MetaModel api because of schema validation.
>> 
>> Initially in accounts table we have three fields [_id, name, createdDate]
>> and MetaModel is succesfully identified them by sampling.
>> DataSet ds = dc.query()
>>        .from("accounts")
>>        .selectAll()
>>        .execute();
>> System.out.println(ds.toRows()); // [_id, name, createdDate]
>> 
>> dc.executeUpdate((c) -> {
>>    c.insertInto("accounts")
>>            //.value("_id", 123)   _id will be autogenerated
>>            .value("name", "default")
>>            .value("createdDate", new Date())
>>            .value("active", false)
>>            .execute();
>> });
>> After creating new document with the NEW active field, it complies = No
>> such column in table: active
>> 
>> I understand that schema validation step is required for RDBMS sources,
>> and therefore MetaModel API requires it.
>> But is there simple way to bypass this check?
>> 
>> 


Re: Add new field to mongo db collection

Posted by Kasper Sørensen <i....@gmail.com>.
Hi Misha,

Have you checked out https://issues.apache.org/jira/browse/METAMODEL-189 ?
It seems you're not alone to think that MMs behaviour should be different
here.

Myself I am torn. But let me explain my trail of thought on that issue, as
a comment :-)

Kasper

2015-11-26 13:06 GMT+01:00 mishadoff <mi...@gmail.com>:

> Hello All,
>
> We encountered an issue where we can’t add new fields into MongoDB
> collection, using MetaModel api because of schema validation.
>
> Initially in accounts table we have three fields [_id, name, createdDate]
> and MetaModel is succesfully identified them by sampling.
> DataSet ds = dc.query()
>         .from("accounts")
>         .selectAll()
>         .execute();
> System.out.println(ds.toRows()); // [_id, name, createdDate]
>
> dc.executeUpdate((c) -> {
>     c.insertInto("accounts")
>             //.value("_id", 123)   _id will be autogenerated
>             .value("name", "default")
>             .value("createdDate", new Date())
>             .value("active", false)
>             .execute();
> });
> After creating new document with the NEW active field, it complies = No
> such column in table: active
>
> I understand that schema validation step is required for RDBMS sources,
> and therefore MetaModel API requires it.
> But is there simple way to bypass this check?
>
>