Apache Calcite: Handle special characters in MongoDB collection names

638 views Asked by At

Is there a way to execute SQL queries on MongoDB if the collection's name contains special characters such as 1a84375b-9bd0-4ec3-9f93-536ce380f813? I encounter org.apache.calcite.sql.parser.impl.ParseException when I execute my statement. Are there any escape characters?

1

There are 1 answers

1
Julian Hyde On

In Calcite SQL, you can quote identifiers (table names and column names). In the default dialect, you use double quotes. For example,

SELECT "a column"
FROM "a table with spaces in the name"

Also note that when if identifiers are quoted, Calcite retains their case (it does not convert to upper or lower case) and uses case-sensitive matching.

By the way, this is the same as Oracle and several other common SQL dialects.