Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6026

MongoDB: Column is not quoted in "order by" clause and throws JsonParseException

    XMLWordPrintableJSON

Details

    Description

      The following query fails with a JsonParseException:

      select state as "STATE", avg(pop) as "AVG(pop)"
      from zips
      group by "STATE"
      order by "AVG(pop)" 

       
      Stack trace:
       

      org.bson.json.JsonParseException: JSON reader was expecting ':' but found '('.
      	at org.bson.json.JsonReader.readBsonType(JsonReader.java:150)
      	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:85)
      	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:42)
      	at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:104)
      	at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:87)
      	at org.bson.BsonDocument.parse(BsonDocument.java:66)
      	at org.apache.calcite.adapter.mongodb.MongoTable.aggregate(MongoTable.java:138)
      	at org.apache.calcite.adapter.mongodb.MongoTable.access$200(MongoTable.java:53)
      	at org.apache.calcite.adapter.mongodb.MongoTable$MongoQueryable.aggregate(MongoTable.java:189) 

       

      This is caused by the column name in the "order by" clause not being escaped.

       

      Attachments

        Issue Links

          Activity

            People

              tnieradzik Tim Nieradzik
              tnieradzik Tim Nieradzik
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: