0

I am using org.teiid.query.parser.QueryParser to parse a SQL string into Query object. It works fine for ansi quoted identifiers (double quotes). However, it is throwing error while parsing the identifiers quoted with square brackets, single quotes and backticks.

Getting the below error: java.lang.Exception: org.teiid.api.exception.query.QueryParserException: TEIID31100 Parsing error: Encountered "select [*][[*]dbo.empid]" at line 1, column 8. Was expecting: "char" | "date" | "time" | "timestamp" | "cast" | "convert" | "all" | "any" | "array" | "array_agg" ...

This is how I am using it: Query query = (Query)QueryParser.getQueryParser().parseCommand(sqlString, new ParseInfo());

The ParseInfo paramenter in above statement has ANSI_QUOTED_DEFAULT property as true due to which it is able to parse the sql string with double quoted identifiers. For e.g: Select "dbo.empid" From "dbo"."Emp" "Ex"

My application requires to parse SQL strings with other types of quoting as given below.

  • Square brackets: select [dbo.empid] From [dbo].[Emp] [Ex]

  • Single quotes: Select 'dbo.empid' From 'dbo'.'Emp' 'Ex'

  • Backticks: Select dbo.empid From dbo.Emp Ex

The Query parser is not parsing the above three sql statements.

Is there any teiid property setting or any other teiid configuration required in the code to allow any type of quoting?

M S
  • 1
  • 1

1 Answers1

0

Is there any teiid property setting or any other teiid configuration required in the code to allow any type of quoting?

The short answer is currently no. The parsing support for quoted identifiers is just the ansi standard double quotes. For string literals as you have seen it's the default single quote or a property that allows for double quotes.

If there is a particular sql dialect you are trying to have Teiid support, you can see if there is a JIRA issue already open for that - https://issues.redhat.com/projects/TEIID/issues

More than likely there is more syntax you would need supported than just alternative quoting.

Steven Hawkins
  • 538
  • 1
  • 4
  • 7