Skip to content

Commit 985fc27

Browse files
committed
Handle ROW and triple quotes
1 parent 318948a commit 985fc27

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,8 @@ public static String addRemoteIndices(String query, Set<String> lookupIndices, b
12981298
String[] commandParts = afterSetStatements.trim().split("\\s+", 2);
12991299

13001300
String command = commandParts[0].trim();
1301-
String commandArgs = commandParts[1].trim();
13021301
if (SourceCommand.isSourceCommand(command)) {
1302+
String commandArgs = commandParts[1].trim();
13031303
String[] indices = new EsqlParser().createStatement(afterSetStatements)
13041304
.collect(UnresolvedRelation.class)
13051305
.getFirst()
@@ -1332,7 +1332,7 @@ private static String getStuffAfterIndices(String commandArgs, String lastIndex)
13321332
} else {
13331333
stuffAfterIndices = commandArgs.trim();
13341334
}
1335-
if (stuffAfterIndices.startsWith("\"")) {
1335+
while (stuffAfterIndices.startsWith("\"")) {
13361336
stuffAfterIndices = stuffAfterIndices.substring(1).trim();
13371337
}
13381338
return stuffAfterIndices;

x-pack/plugin/esql/qa/testFixtures/src/test/java/org/elasticsearch/xpack/esql/EsqlTestUtilsTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,24 @@ public void testSubquery() {
8888
| KEEP _index, emp_no, languages, language_name""")
8989
);
9090
}
91+
92+
public void testTripleQuotes() {
93+
assertThat(
94+
EsqlTestUtils.addRemoteIndices("from \"\"\"employees\"\"\" | limit 2", Set.of(), false),
95+
equalTo("from *:employees,employees | limit 2")
96+
);
97+
}
98+
99+
public void testRow() {
100+
assertThat(
101+
EsqlTestUtils.addRemoteIndices("""
102+
ROW a = "1953-01-23T12:15:00Z - some text - 127.0.0.1;"\s
103+
| DISSECT a "%{Y}-%{M}-%{D}T%{h}:%{m}:%{s}Z - %{msg} - %{ip};"\s
104+
| KEEP Y, M, D, h, m, s, msg, ip""", Set.of(), false),
105+
equalTo("""
106+
ROW a = "1953-01-23T12:15:00Z - some text - 127.0.0.1;"\s
107+
| DISSECT a "%{Y}-%{M}-%{D}T%{h}:%{m}:%{s}Z - %{msg} - %{ip};"\s
108+
| KEEP Y, M, D, h, m, s, msg, ip""")
109+
);
110+
}
91111
}

0 commit comments

Comments
 (0)