[ 
https://issues.apache.org/jira/browse/CALCITE-4979?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Bright updated CALCITE-4979:
-----------------------------------
    Description: 
Calcite currently supports [extending the 
parser]([https://calcite.apache.org/docs/adapter.html#extending-the-parser)] 
with `config.fmpp` that has sections statements including alter and drop.

I require the ability to introduce a custom `SELECT` like statement which 
requires adding adding an additional clause to the LeafQuery syntax in the 
`Parser.jj` file eg:

{code}
/**
 * Parses a leaf in a query expression (SELECT, VALUES or TABLE).
 */
SqlNode LeafQuery(ExprContext exprContext) :
{
    SqlNode e;
}
{
    {
        // ensure a query is legal in this context
        checkQueryExpression(exprContext);
    }
    e = SqlSelect() { return e; }
|
<#-- Add methods to parse additional select statements here -->
<#list 
(parser.selectStatementParserMethods!default.parser.selectStatementParserMethods)
 as method>
    e = ${method} { return e; }
|
</#list>
    e = TableConstructor() { return e; }
|
    e = ExplicitTable(getPos()) { return e; }
}
{code}

I would like to add a new section `selectStatementParserMethods` to the config 
eg:

{code}
  # List of methods for parsing custom select statements.
  # Return type of method implementation should be 'SqlNode'.
  # Example: SqlSelect()
  selectStatementParserMethods: [
  ]
{code}

Files required to be updated main codegen are:
 * core/src/main/codegen/templates/Parser.jj
 * core/src/main/codegen/default_config.fmpp

  was:
Calcite currently supports [extending the 
parser]([https://calcite.apache.org/docs/adapter.html#extending-the-parser)] 
with `config.fmpp` that has sections statements including alter and drop.

I require the ability to introduce a custom `SELECT` like statement which 
requires adding adding an additional clause to the LeafQuery syntax in the 
`Parser.jj` file eg:

{{    /**}}
{{    * Parses a leaf in a query expression (SELECT, VALUES or TABLE).}}
{{    */}}
{{    SqlNode LeafQuery(ExprContext exprContext) :}}
{{    {}}
{{        SqlNode e;}}
{{    }}}
{{    {}}
{{        {}}
{{            // ensure a query is legal in this context}}
{{            checkQueryExpression(exprContext);}}
{{        }}}
{{        e = SqlSelect() \{ return e; }}}
{{    |}}
{{    <#-- Add methods to parse additional select statements here -->}}
{{    <#list 
(parser.selectStatementParserMethods!default.parser.selectStatementParserMethods)
 as method>}}
{{        e = ${method} \{ return e; }}}
{{    |}}
{{    </#list>}}
{{        e = TableConstructor() \{ return e; }}}
{{    |}}
{{        e = ExplicitTable(getPos()) \{ return e; }}}
{{    }}}

I would like to add a new section `selectStatementParserMethods` to the config 
eg:

{{    # List of methods for parsing custom select statements.}}
{{    selectStatementParserMethods: [}}
{{      "SqlCustomSelect()"}}
{{    ]}}

Files required to be updated main codegen are:
 * core/src/main/codegen/templates/Parser.jj
 * core/src/main/codegen/default_config.fmpp


> Add support for extending parser to support additional select statements
> ------------------------------------------------------------------------
>
>                 Key: CALCITE-4979
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4979
>             Project: Calcite
>          Issue Type: New Feature
>          Components: extensions
>    Affects Versions: 1.29.0
>         Environment: * mac-arm64
>            Reporter: Julian Bright
>            Priority: Minor
>
> Calcite currently supports [extending the 
> parser]([https://calcite.apache.org/docs/adapter.html#extending-the-parser)] 
> with `config.fmpp` that has sections statements including alter and drop.
> I require the ability to introduce a custom `SELECT` like statement which 
> requires adding adding an additional clause to the LeafQuery syntax in the 
> `Parser.jj` file eg:
> {code}
> /**
>  * Parses a leaf in a query expression (SELECT, VALUES or TABLE).
>  */
> SqlNode LeafQuery(ExprContext exprContext) :
> {
>     SqlNode e;
> }
> {
>     {
>         // ensure a query is legal in this context
>         checkQueryExpression(exprContext);
>     }
>     e = SqlSelect() { return e; }
> |
> <#-- Add methods to parse additional select statements here -->
> <#list 
> (parser.selectStatementParserMethods!default.parser.selectStatementParserMethods)
>  as method>
>     e = ${method} { return e; }
> |
> </#list>
>     e = TableConstructor() { return e; }
> |
>     e = ExplicitTable(getPos()) { return e; }
> }
> {code}
> I would like to add a new section `selectStatementParserMethods` to the 
> config eg:
> {code}
>   # List of methods for parsing custom select statements.
>   # Return type of method implementation should be 'SqlNode'.
>   # Example: SqlSelect()
>   selectStatementParserMethods: [
>   ]
> {code}
> Files required to be updated main codegen are:
>  * core/src/main/codegen/templates/Parser.jj
>  * core/src/main/codegen/default_config.fmpp



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to