Hi,
  I encountered a problem when using string literal in Flink. Currently,
Flink will escape the string literal during codegen, so for the query below:

SELECT 'a\nb'; it will print => a\nb

then for the query

SELECT SPLIT_INDEX(col, '\n', 0);

The col can not split by the newline. If we want to split by the newline,
we should use

SELECT SPLIT_INDEX(col, '
', 0)

or

SELECT SPLIT_INDEX(col, CHR(10), 0)

The above way could be more intuitive. Some other databases support these
"Special Character Escape Sequences"[1].

In this way, we can directly use
SELECT SPLIT_INDEX(col, '\n', 0); for the query.

I know this is not standard behavior in ANSI SQL. I'm opening this thread
for some opinions from the community guys.

[1]:
https://dev.mysql.com/doc/refman/8.0/en/string-literals.html#character-escape-sequences

Thanks,
Aitozi

Reply via email to