[ 
https://issues.apache.org/jira/browse/CALCITE-4728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17398283#comment-17398283
 ] 

Julian Hyde commented on CALCITE-4728:
--------------------------------------

[~jamesstarr], Good point. I think we should separate this into:
 # a syntax for defining functions and procedures (where the body of the 
function is treated as a black box, and the function parser doesn't understand 
the language but can just recognize the delimiter at the end), and
 # a syntax for PL/SQL-style BEGIN ... END blocks (begin, end, if, then, while, 
with embedded SQL). Blocks are hard to parse and validate because may have 
embedded SQL.

Do you agree?

 

> Parse and validate procedural code (such as SQL/PSM, PL/SQL, PL/pgSQL, T-SQL)
> -----------------------------------------------------------------------------
>
>                 Key: CALCITE-4728
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4728
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Priority: Major
>
> Parse and validate procedural code (such as the SQL standard's SQL/PSM, 
> Oracle's PL/SQL, PostgreSQL's PL/pgSQL, MSSQL's T-SQL).
> This would entail:
>  * Extensions to the SQL parser. (I'm not sure whether this would be the core 
> parser or an extended parser such as Babel.)
>  * AST classes (sub-classes of {{SqlNode}}) for functions, procedures, 
> blocks, variable and parameter declarations, variable assignment, 
> if-then-else, loop, and so forth.
>  * Extensions to the validator to validate blocks.
>  * Extensions to the validator to validate a SQL statement that is inside a 
> block. (Variables and parameters are in scope.)
> Optional:
>  * Extend Interpreter to execute functions, procedures, blocks.
>  * Some means to convert a block into executable Java code.
>  * Extend {{SqlDialect}} so that ASTs of functions, procedures and blocks can 
> be emitted using the syntax of particular dialects.
> The languages are sufficiently similar that we can use the same AST classes 
> for all.
> I don't think we need to extend {{RelNode}} to represent blocks. (It's not a 
> good fit, since a block does not evaluate to a relation.) Possibly we would 
> create some data structure to represent a validated block (e.g. the type of 
> each variable; each use of a variable points to the variable's definition). 
> {{SqlToRelConverter}} would create this data structure in order "freeze" the 
> state of the validator.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to