Is it possible to access the offset for where a parsed node appears in the source string? #1947
-
When the parsed SQL has a syntax error, the offset of where the error occurred is presented in the error message. I'm doing additional query processing, to make it actually work, and so additional errors can be generated during this phase. Unfortunately, I cannot seem to access the original offsets, and so the error messages are less helpful. Is this feature available, but I just can't find it? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Can you share some code please? But I am interested only in the first error token and do not understand yer what exactly you try to achieve. |
Beta Was this translation helpful? Give feedback.
-
Ok, understood. However, this exceeds the capability of JSQLParser since it is not aware of the actual schema objects. I am still lost what you mean by "original offset" though. |
Beta Was this translation helpful? Give feedback.
-
Reading again, I think I understand your requirement better: You want to get the position of a particular token (which you throw an error for). Most, but not all Productions link the AstNode, which should give your this position. |
Beta Was this translation helpful? Give feedback.
-
I see it now, thanks! |
Beta Was this translation helpful? Give feedback.
Reading again, I think I understand your requirement better: You want to get the position of a particular token (which you throw an error for).
Most, but not all Productions link the AstNode, which should give your this position.