Skip to content

Failure to parse DECIMAL(<scale>, <precision>) #228

Closed
@dlurton

Description

@dlurton
PartiQL> cast(foo as decimal(2, 2))
   | !!
org.partiql.lang.syntax.ParserException: Apparently DataType needs multiple lengths, sizes, etc
	Parser Error: at line 1, column 13: Internal error - malformed parse tree detected, <UNKNOWN> : <UNKNOWN>

	at org.partiql.lang.syntax.SqlParser$ParseNode.errMalformedParseTree(SqlParser.kt:160)
	at org.partiql.lang.syntax.SqlParser.toDataType(SqlParser.kt:722)
	at org.partiql.lang.syntax.SqlParser.toExprNode(SqlParser.kt:305)
	at org.partiql.lang.syntax.SqlParser.parseExprNode(SqlParser.kt:1919)
	at org.partiql.cli.Repl$parsePartiQLWithFilters$1.invoke(Repl.kt:267)
	at org.partiql.cli.Repl$parsePartiQLWithFilters$1.invoke(Repl.kt:106)
	at org.partiql.cli.Repl$executeTemplate$totalMs$1.invoke(Repl.kt:212)
	at org.partiql.cli.Repl$executeTemplate$totalMs$1.invoke(Repl.kt:106)
	at org.partiql.cli.Timer$DefaultImpls.timeIt(Repl.kt:96)
	at org.partiql.cli.Repl$1.timeIt(Repl.kt:112)
	at org.partiql.cli.Repl.executeTemplate(Repl.kt:211)
	at org.partiql.cli.Repl.parsePartiQLWithFilters(Repl.kt:265)
	at org.partiql.cli.Repl.run(Repl.kt:316)
	at org.partiql.cli.Main.runRepl(main.kt:155)
	at org.partiql.cli.Main.main(main.kt:140)
ERROR! 

Note that cast(foo as decimal(1)) works without issue however.

Tasks outlined by this issue:

  1. Update SqlParser to parse multiple arguments for DECIMAL and NUMERIC when they are used with 2 arguments. (Also verify that these are the only two types that include more than one parameter.)
  2. Add tests to SqlParserTests for those types when used with more than one argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions