File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
lang/src/org/partiql/lang Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package org.partiql.lang.ast
2
2
3
3
import com.amazon.ionelement.api.toIonElement
4
4
import org.partiql.lang.domains.PartiqlAst
5
+ import org.partiql.pig.runtime.SymbolPrimitive
5
6
import org.partiql.pig.runtime.asPrimitive
6
7
7
8
/* * Converts an [ExprNode] to a [PartiqlAst.statement]. */
@@ -23,6 +24,9 @@ fun ExprNode.toAstStatement(): PartiqlAst.Statement {
23
24
private fun PartiQlMetaContainer.toElectrolyteMetaContainer (): ElectrolyteMetaContainer =
24
25
com.amazon.ionelement.api.metaContainerOf(map { it.tag to it })
25
26
27
+ private fun SymbolicName.toSymbolPrimitive () : SymbolPrimitive =
28
+ SymbolPrimitive (this .name, this .metas.toElectrolyteMetaContainer())
29
+
26
30
private fun ExprNode.toAstDdl (): PartiqlAst .Statement {
27
31
val thiz = this
28
32
val metas = metas.toElectrolyteMetaContainer()
@@ -55,7 +59,7 @@ private fun ExprNode.toAstExec() : PartiqlAst.Statement {
55
59
56
60
return PartiqlAst .build {
57
61
when (node) {
58
- is Exec -> exec (node.procedureName.name , node.args.map { it.toAstExpr() }, metas)
62
+ is Exec -> exec_ (node.procedureName.toSymbolPrimitive() , node.args.map { it.toAstExpr() }, metas)
59
63
else -> error(" Can't convert ${node.javaClass} to PartiqlAst.Statement.Exec" )
60
64
}
61
65
}
Original file line number Diff line number Diff line change @@ -2243,10 +2243,13 @@ class SqlParser(private val ion: IonSystem) : Parser {
2243
2243
}
2244
2244
2245
2245
/* *
2246
- * Checks that the given [Token] list does not have `EXEC` calls outside of the top level query. Throws
2246
+ * Checks that the given [Token] list does not have any top-level tokens outside of the top level query. Throws
2247
2247
* an error if so.
2248
+ *
2249
+ * Currently only checks for `EXEC`. DDL and DML along with corresponding error codes to be added in the future
2250
+ * (https://github.com/partiql/partiql-lang-kotlin/issues/354).
2248
2251
*/
2249
- private fun List<Token>.checkForUnexpectedExec () {
2252
+ private fun List<Token>.checkUnexpectedTopLevelToken () {
2250
2253
for ((index, token) in this .withIndex()) {
2251
2254
if (token.keywordText == " exec" && index != 0 ) {
2252
2255
token.err(" EXEC call found at unexpected location" , PARSE_EXEC_AT_UNEXPECTED_LOCATION )
@@ -2257,7 +2260,7 @@ class SqlParser(private val ion: IonSystem) : Parser {
2257
2260
/* * Entry point into the parser. */
2258
2261
override fun parseExprNode (source : String ): ExprNode {
2259
2262
val tokens = SqlLexer (ion).tokenize(source)
2260
- tokens.checkForUnexpectedExec ()
2263
+ tokens.checkUnexpectedTopLevelToken ()
2261
2264
val node = tokens.parseExpression()
2262
2265
val rem = node.remaining
2263
2266
if (! rem.onlyEndOfStatement()) {
You can’t perform that action at this time.
0 commit comments