9 Replies Latest reply on Feb 21, 2014 2:58 PM by ichanjasper

    Parsing Error for MongoDB schema

    ichanjasper

      I am using Teiid 8.6 and I followed the instruction to create one-2-one mapping, MongoDB Translator - Teiid 8.7 (draft) - Project Documentation Editor.  And I ran into parsing exception.

       

      Here is my simple JSON object:

       

      "addresst" { "_id": 0,

      "name": "Duke Grant",

      "age": 38,

      "gender": "male",

       

      "address": { "_id": 0,

      "street": "345 Burnett Street",

      "city": "Nash",

      "state": "Rhode Island",

      "zip": 7384 }

      }

       

      and I created a schema like the following:

       

      CREATE FOREIGN TABLE addresst (custid integer PRIMARY KEY, name varchar(25), age integer, gender varchar(25)) OPTIONS(UPDATABLE 'TRUE');

      CREATE FOREIGN TABLE address  (custid integer PRIMARY KEY, street varchar(50), city varchar(25), state varchar(25), zipcode varchar(6), FOREIGN KEY (custId) REFERENCES addresst (custid),) OPTIONS(UPDATABLE 'TRUE', teiid_mongo:MERGE 'addresst');

       

      And I kept getting the following exception:


      Caused by: org.teiid.api.exception.query.QueryParserException: TEIID31100 Parsing error: Encountered "custid),[*])[*] OPTIONS(" at line 1, column 324.  Was expecting: "constraint" | "foreign" | "primary" | "unique" | "index" | "accesspattern"
              at org.teiid.query.parser.QueryParser.convertParserException(QueryParser.java:214)
              ... 162 more

       

      Did I do something wrong?

       

      Thanks,

       

      - Ivan C.

        • 1. Re: Parsing Error for MongoDB schema
          shawkins

          It looks to be complaining about the trailing comma "(custid),)".  Generally our parser does not like having an extra comma at the end of a list of items.

          • 2. Re: Parsing Error for MongoDB schema
            rareddy

            Ivan,

             

            I also fixed few issues with MongoDB translator in 8.7, so I recommend using the 8.7 Beta 1 version or later.

             

            Ramesh..

            • 3. Re: Parsing Error for MongoDB schema
              ichanjasper

              After I removed the extra comma, it still doesn't work.  Now I get the following exception:

               

              Caused by: org.teiid.api.exception.query.QueryParserException: TEIID31100 Parsing error: Encountered "'TRUE', teiid_mongo[*]:[*]MERGE 'addresst'" at line 1, column 362.

              Was expecting: "false" | "null" | "true" | "unknown" | <ESCAPEDTYPE> | <DECIMALVAL> | <FLOATVAL> | <STRINGVAL> | <UNSIGNEDINTEGER> | <BINARYSTRINGVAL> ...

                      at org.teiid.query.parser.QueryParser.convertParserException(QueryParser.java:214)

                      ... 162 more

               

               

              Here is my schema:

               

              CREATE FOREIGN TABLE addresst (custid integer PRIMARY KEY, name varchar(25), age integer, gender varchar(25)) OPTIONS(UPDATABLE 'TRUE'); CREATE FOREIGN TABLE address  (custid integer PRIMARY KEY, street varchar(50), city varchar(25), state varchar(25), zipcode varchar(6), FOREIGN KEY (custId) REFERENCES addresst (custid)) OPTIONS(UPDATABLE 'TRUE', teiid_mongo:MERGE 'addresst');

               

              Btw, maybe you guys should remove the "extra comma" in your document, too.

               

              MongoDB Translator - Teiid 8.7 (draft) - Project Documentation Editor

              • 4. Re: Parsing Error for MongoDB schema
                shawkins

                > After I removed the extra comma, it still doesn't work

                 

                Namespacing is not quite a first class citizen, so the key needs to be quoted when it contains a : - "teiid_mongo:MERGE"

                 

                > Btw, maybe you guys should remove the "extra comma" in your document, too

                 

                Absolutely.  I'll go through the doc and see what additional corrections need to be made.

                • 5. Re: Re: Parsing Error for MongoDB schema
                  rareddy

                  Ivan,

                   

                  You should define the namespace qualifier in quotes. For ex:

                   

                  OPTIONS(UPDATABLE 'TRUE', "teiid_mongo:MERGE" 'addresst');

                   

                  I updated the examples in this page MongoDB Translator - Teiid 8.7

                   

                  Ramesh..

                  • 6. Re: Re: Parsing Error for MongoDB schema
                    ichanjasper

                    I got the schema to work and it is able to query back the result.  However, I found a few bugs.  For example, I can't query "street" and "city", or "gender and state" in 1 query.  It gives me exception.  I will file bug later.   Thanks for your help.

                    • 7. Re: Re: Parsing Error for MongoDB schema
                      rareddy

                      Ivan,

                       

                      I have seen some issues with JOIN processing in the 8.6 version, I fixed TEIID-2845, TEIID-2843, TEIID-2841, TEIID-2839, TEIID-2838, TEIID-2830, in 8.7 so check with that version first if that solves your issues.

                       

                      Ramesh..

                      • 8. Re: Re: Parsing Error for MongoDB schema
                        ichanjasper

                        Sure.  I will try with Teiid 8.7 Beta tomorrow.  Thanks.

                        • 9. Re: Re: Parsing Error for MongoDB schema
                          ichanjasper

                          I just tried it with Teiid 8.7 Beta.  And the problems are gone!  You guys are awesome!  Thank you!