Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ public static String unquoteText(String text) {
for (int chIndex = 1; chIndex < text.length() - 1; chIndex++) {
currentChar = text.charAt(chIndex);
nextChar = text.charAt(chIndex + 1);
if (currentChar == enclosingQuote && nextChar == currentChar) {

if ((currentChar == '\\' && (nextChar == '"' || nextChar == '\\' || nextChar == '\''))
|| (currentChar == nextChar && currentChar == enclosingQuote)) {
chIndex++;
currentChar = nextChar;
}
textSB.append(currentChar);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/user/dql/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Here is an example for different type of literals::
+---------+---------+---------+---------+--------+---------+---------+-----------+----------+
| "Hello" | 'Hello' | "It""s" | 'It''s' | "It's" | '"Its"' | 'It\'s' | 'It\\\'s' | "\I\t\s" |
|---------+---------+---------+---------+--------+---------+---------+-----------+----------|
| Hello | Hello | It"s | It's | It's | "Its" | It\'s | It\\\'s | \I\t\s |
| Hello | Hello | It"s | It's | It's | "Its" | It's | It\'s | \I\t\s |
+---------+---------+---------+---------+--------+---------+---------+-----------+----------+


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public void testWildcardEscaping() throws IOException {
executeQuery(
String.format(
"search source=%s"
+ " `attributes.error.type`=\\\"C:\\\\\\\\Users\\\\\\\\admin\\\""
+ " `attributes.error.type`=\\\"C:\\\\\\\\\\\\\\\\Users\\\\\\\\\\\\\\\\admin\\\""
+ " | sort time | fields attributes.error.type",
TEST_INDEX_OTEL_LOGS));
verifyDataRows(backslashSearch, rows("C:\\Users\\admin"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void test_backslash_wildcard() throws IOException {
String query =
"SELECT KeywordBody FROM "
+ TEST_INDEX_WILDCARD
+ " WHERE wildcard_query(KeywordBody, '*\\\\\\\\\\\\_')";
+ " WHERE wildcard_query(KeywordBody, '*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_')";
JSONObject result = executeJdbcRequest(query);
verifyDataRows(result, rows("test backslash wildcard \\_"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ public void testReplaceWithRegexPattern() {
String ppl = "source=EMP | eval no_digits = replace(JOB, '\\\\d+', '') | fields JOB, no_digits";
RelNode root = getRelNode(ppl);
String expectedLogical =
"LogicalProject(JOB=[$2], no_digits=[REGEXP_REPLACE($2, '\\\\d+':VARCHAR, '':VARCHAR)])\n"
"LogicalProject(JOB=[$2], no_digits=[REGEXP_REPLACE($2, '\\d+':VARCHAR, '':VARCHAR)])\n"
+ " LogicalTableScan(table=[[scott, EMP]])\n";
verifyLogical(root, expectedLogical);

String expectedSparkSql =
"SELECT `JOB`, REGEXP_REPLACE(`JOB`, '\\\\d+', '') `no_digits`\n" + "FROM `scott`.`EMP`";
"SELECT `JOB`, REGEXP_REPLACE(`JOB`, '\\d+', '') `no_digits`\n" + "FROM `scott`.`EMP`";
verifyPPLToSparkSQL(root, expectedSparkSql);
}

Expand All @@ -303,12 +303,12 @@ public void testReplaceWithRegexCaptureGroups() {
RelNode root = getRelNode(ppl);
String expectedLogical =
"LogicalProject(ENAME=[$1], swapped=[REGEXP_REPLACE($1, '^(.)(.)':VARCHAR,"
+ " '\\$2\\$1')])\n"
+ " '$2$1')])\n"
+ " LogicalTableScan(table=[[scott, EMP]])\n";
verifyLogical(root, expectedLogical);

String expectedSparkSql =
"SELECT `ENAME`, REGEXP_REPLACE(`ENAME`, '^(.)(.)', '\\$2\\$1') `swapped`\n"
"SELECT `ENAME`, REGEXP_REPLACE(`ENAME`, '^(.)(.)', '$2$1') `swapped`\n"
+ "FROM `scott`.`EMP`";
verifyPPLToSparkSQL(root, expectedSparkSql);
}
Expand Down
Loading