Error: java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 0

Description:

When you try to use the split method with reserved characters, you will get the error as shown below.

Example: select split(sourceurl, '?')[0] as url from Sample;

Error: Caused by: java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 0

Cause: Here the split will not work in usual manner where it should return expected output. Instead it will throw the above error. This is because few characters are reserved characters which include “?” pattern also. Hence it cannot be parsed by split method.

Action:

To address this error, use escape sequence along with reserved characters.

Solution for above example-

    select split(sourceurl, "\\?") [0] as url from Sample;

 

 

Have more questions? Submit a request

Comments

Powered by Zendesk