The hacky way would be to add a grammar clause like this I think:

| "DEFAULT"

To the "TableRef2" node in the parser grammar:
https://github.com/apache/calcite/blob/82dd78a14f6aef2eeec2f9c94978d04b4acc5359/core/src/main/codegen/templates/Parser.jj#L2087-L2276

Not sure all the implications this would have elsewhere though.

Also for personal opinion -- the notion of a "DEFAULT" database I'm not
sure is a universal thing.
I've never worked with analytical DB's, only Postgres/MySQL -- and in these
DB's the default database is implicit in your queries.

IE if I connect to a database called "mydb", all queries are automatically
prefixed implicitly with "mydb."

MySQL I don't think has a default database. A brand-new MySQL DB has 0
databases.
There is one called "mysql" but that's a system DB, like "pg_catalog" or
"information_schema".

Confusingly this is different in Postgres, where the "postgres" DB is one
that exists by default
and IS intended to be a user-facing DB.


On Mon, Apr 11, 2022 at 11:36 PM Yanjing Wang <[email protected]>
wrote:

> Hi community,
>
> In hive, DEFAULT is a default database, so one can write sql
> SELECT * FROM DEFAULT.t
>
> In trino, one can write
> SELECT * FROM HIVE.DEFAULT.t
>
> But now Calcite treat DEFAULT as a keyword which will be resolved to
> DEFAULT() function.
>
> What should I do to make the parser to support the DEFAULT in the table
> identifier?
>
> I tried to add the DEFAULT to non-keywords but it would cause DEFAULT()
> function fails.
>
> Now I must tell the user wrap the DEFAULT using quotes like this
> SELECT * FROM HIVE."DEFAULT".t
>
> Thanks in advance.
>

Reply via email to