Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-6026] MongoDB: Column is not quoted in "order by" clause and throws JsonParseException #3443

Merged
merged 1 commit into from
Sep 26, 2023

Commits on Sep 26, 2023

  1. [CALCITE-6026] MongoDB: Column is not quoted in "order by" clause and…

    … throws JsonParseException
    
    The following query fails with a `JsonParseException`:
    
    ```sql
    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.
    tindzk committed Sep 26, 2023
    Configuration menu
    Copy the full SHA
    3a06e7b View commit details
    Browse the repository at this point in the history