How to get around " 'this' missing for xmlelement" error? #6689
-
|
I'm trying to use sqlglot to grab the columns from a complex Oracle SQL query. Because the full original query is literally hundreds of lines long, I'll just post the troublesome line. The line is a subquery used as part of a select statement for a parent subquery. ... sqlglot throws an error near the "ImageID" portion, claiming it's missing a "this". I know for a fact that the Oracle SQL query itself is perfectly fine, so how can I get around this error? Similar discussions appear to have led to issues and bug reports, but I couldn't find anything about xmlelement in particular. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
after a lot of tinkering, I still haven't quite found a solution, but it appears that the " 'this' is missing for <class 'sqlglot.expressions.XMLElement'>" error appears under one of two conditions: 1) the xmlelement is inside an xmlagg or 2) the xmlelement is inside an xmlserialize. I'm going to need to do some more tinkering though, especially with the xmlserialize one because that one will sometimes instead throw an error "Expecting ')' " shortly after the xmlserialize statement, and often in the place where the xmlelement is. |
Beta Was this translation helpful? Give feedback.
-
|
Seems like there was a feature gap related to |
Beta Was this translation helpful? Give feedback.
-
|
Well that helped with the XMLElement error swimmingly! However, I'm now running into another wall: XMLSerialize keeps causing "Expected ')'" errors. An example snippet that throws the error: select XMLSERIALIZE( DOCUMENT XMLELEMENT("FeatureCollection", XMLATTRIBUTES("http://localhost:2345/custom" as "xmlns:custom"), XMLAGG( XMLDOCS.XMLDOC ) ) ) as XMLDOC from ... sqlglot throws an error right after "DOCUMENT". Trouble is I have several Oracle SQL files I'm trying to read, and XMLSerialize seems to be a pretty common thing. The error doesn't always show up right after "DOCUMENT" for them, but they all throw the same "Expected ')'" error somewhere in their code blobs. Since I really just need the columns, and XMLSerialize isn't exactly a column from a table, is there an appropriate XML object I could substitute it with to get what I need? |
Beta Was this translation helpful? Give feedback.
Seems like there was a feature gap related to
XMLELEMENTparsing– see f866c83.