You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by "SpamOnMe@freenet.de" <Sp...@freenet.de> on 2022/05/26 09:15:50 UTC
How to use MongoDB collections starting with numbers?
Hello,
I've got a few Mongo collections and would like to use:
01_test
apache drill (mongo.crm_test)> SHOW DATABASES;
+--------------------+
| SCHEMA_NAME |
+--------------------+
| mongo.01_test |
| mongo.test |
apache drill (mongo.crm_test)> usemongo.test;
+------+--------------------------------------------+
| ok | summary |
+------+--------------------------------------------+
| true| Default schema changed to [mongo.test]|
+------+--------------------------------------------+
But:
apache drill (mongo.test)> usemongo.01_test;
Error: PARSE ERROR: Encountered ".01" at line 1, column 10.
SQL Query: use mongo.01_test
^
[Error Id: 056ff092-822b-4113-bf06-27e960cfe69a ] (state=,code=0)
I've tried it with " and ' but nothing seems to be working for
a collection, starting with a number.
How to do this?
Thanks and kind regards,
Chris
Re: How to use MongoDB collections starting with numbers?
Posted by James Turton <dz...@apache.org>.
Also note that identifiers must be quoted with `backticks` in Drill SQL.
On 2022/05/26 11:24, luoc wrote:
> Hi Chris,
>
> It is strongly recommended not to create table names beginning with numbers in mongo. Although mongo supports this, it can become very complex in ANSI SQL.
>
>> On May 26, 2022, at 17:16, SpamOnMe@freenet.de wrote:
>>
>> Hello,
>>
>> I've got a few Mongo collections and would like to use:
>> 01_test
>>
>> apache drill (mongo.crm_test)> SHOW DATABASES;
>> +--------------------+
>> | SCHEMA_NAME |
>> +--------------------+
>> | mongo.01_test |
>> | mongo.test |
>>
>> apache drill (mongo.crm_test)> usemongo.test;
>> +------+--------------------------------------------+
>> | ok | summary |
>> +------+--------------------------------------------+
>> | true| Default schema changed to [mongo.test]|
>> +------+--------------------------------------------+
>>
>> But:
>>
>> apache drill (mongo.test)> usemongo.01_test;
>> Error: PARSE ERROR: Encountered ".01" at line 1, column 10.
>>
>> SQL Query: use mongo.01_test
>> ^
>>
>> [Error Id: 056ff092-822b-4113-bf06-27e960cfe69a ] (state=,code=0)
>>
>>
>> I've tried it with " and ' but nothing seems to be working for
>> a collection, starting with a number.
>> How to do this?
>>
>> Thanks and kind regards,
>> Chris
Re: How to use MongoDB collections starting with numbers?
Posted by luoc <lu...@apache.org>.
Hi Chris,
It is strongly recommended not to create table names beginning with numbers in mongo. Although mongo supports this, it can become very complex in ANSI SQL.
> On May 26, 2022, at 17:16, SpamOnMe@freenet.de wrote:
>
> Hello,
>
> I've got a few Mongo collections and would like to use:
> 01_test
>
> apache drill (mongo.crm_test)> SHOW DATABASES;
> +--------------------+
> | SCHEMA_NAME |
> +--------------------+
> | mongo.01_test |
> | mongo.test |
>
> apache drill (mongo.crm_test)> usemongo.test;
> +------+--------------------------------------------+
> | ok | summary |
> +------+--------------------------------------------+
> | true| Default schema changed to [mongo.test]|
> +------+--------------------------------------------+
>
> But:
>
> apache drill (mongo.test)> usemongo.01_test;
> Error: PARSE ERROR: Encountered ".01" at line 1, column 10.
>
> SQL Query: use mongo.01_test
> ^
>
> [Error Id: 056ff092-822b-4113-bf06-27e960cfe69a ] (state=,code=0)
>
>
> I've tried it with " and ' but nothing seems to be working for
> a collection, starting with a number.
> How to do this?
>
> Thanks and kind regards,
> Chris