Skip to content

Commit 13d8b4b

Browse files
committed
Fix multi cluster tests to accept SET statements
1 parent ee1316c commit 13d8b4b

File tree

1 file changed

+10
-2
lines changed
  • x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq

1 file changed

+10
-2
lines changed

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,15 @@ static CsvSpecReader.CsvTestCase convertToRemoteIndices(CsvSpecReader.CsvTestCas
304304
String first = commands[0].trim();
305305
// If true, we're using *:index, otherwise we're using *:index,index
306306
boolean onlyRemotes = canUseRemoteIndicesOnly() && randomBoolean();
307-
String[] commandParts = first.split("\\s+", 2);
307+
308+
// Split "SET a=b; FROM x" into "SET a=b" and "FROM x"
309+
int lastSetDelimiterPosition = first.lastIndexOf(';');
310+
String setStatements = lastSetDelimiterPosition == -1 ? "" : first.substring(0, lastSetDelimiterPosition + 1);
311+
String afterSetStatements = lastSetDelimiterPosition == -1 ? first : first.substring(lastSetDelimiterPosition + 1);
312+
313+
// Split "FROM a, b, c" into "FROM" and "a, b, c"
314+
String[] commandParts = afterSetStatements.trim().split("\\s+", 2);
315+
308316
String command = commandParts[0].trim();
309317
if (command.equalsIgnoreCase("from") || command.equalsIgnoreCase("ts")) {
310318
String[] indexMetadataParts = commandParts[1].split("(?i)\\bmetadata\\b", 2);
@@ -326,7 +334,7 @@ static CsvSpecReader.CsvTestCase convertToRemoteIndices(CsvSpecReader.CsvTestCas
326334
+ remoteIndices
327335
+ " "
328336
+ (indexMetadataParts.length == 1 ? "" : "metadata " + indexMetadataParts[1]);
329-
testCase.query = newFirstCommand + query.substring(first.length());
337+
testCase.query = setStatements + newFirstCommand + query.substring(first.length());
330338
}
331339
}
332340

0 commit comments

Comments
 (0)