Skip to content
Open
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
5 changes: 5 additions & 0 deletions docs/changelog/135744.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 135744
summary: Non-Correlated Subquery in FROM command
area: ES|QL
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public abstract class Attribute extends NamedExpression {
/**
* Changing this will break bwc with 8.15, see {@link FieldAttribute#fieldName()}.
*/
protected static final String SYNTHETIC_ATTRIBUTE_NAME_PREFIX = "$$";
public static final String SYNTHETIC_ATTRIBUTE_NAME_PREFIX = "$$";

public static final String SYNTHETIC_ATTRIBUTE_NAME_SEPARATOR = "$";

private static final TransportVersion ESQL_QUALIFIERS_IN_ATTRIBUTES = TransportVersion.fromName("esql_qualifiers_in_attributes");

Expand Down Expand Up @@ -77,7 +79,7 @@ public Attribute(
}

public static String rawTemporaryName(String... parts) {
var name = String.join("$", parts);
var name = String.join(SYNTHETIC_ATTRIBUTE_NAME_SEPARATOR, parts);
return name.isEmpty() || name.startsWith(SYNTHETIC_ATTRIBUTE_NAME_PREFIX) ? name : SYNTHETIC_ATTRIBUTE_NAME_PREFIX + name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V12;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_PLANNING_V1;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.METADATA_FIELDS_REMOTE_TEST;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.SUBQUERY_IN_FROM_COMMAND;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.UNMAPPED_FIELDS;
import static org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.hasCapabilities;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -172,6 +173,12 @@ protected void shouldSkipTest(String testName) throws IOException {
hasCapabilities(adminClient(), List.of(ENABLE_FORK_FOR_REMOTE_INDICES.capabilityName()))
);
}
// Subqueries in FROM are not fully tested in CCS yet
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When there is subquery exists in the query convertToRemoteIndices doesn't generate a correct remote index pattern yet, the query becomes invalid. Subqueries are not fully tested in CCS yet, working on it as a follow up.

// And convertToRemoteIndices does not generate correct queries with subqueries in the FROM command yet
assumeFalse(
"Subqueries in FROM command not yet supported in CCS",
testCase.requiredCapabilities.contains(SUBQUERY_IN_FROM_COMMAND.capabilityName())
);
}

private TestFeatureService remoteFeaturesService() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ protected void shouldSkipTest(String testName) throws IOException {
testCase.requiredCapabilities.contains(UNMAPPED_FIELDS.capabilityName())
);

assumeFalse(
"Tests using subqueries are skipped since we don't support nested subqueries",
testCase.requiredCapabilities.contains(SUBQUERY_IN_FROM_COMMAND.capabilityName())
);

assumeTrue("Cluster needs to support FORK", hasCapabilities(adminClient(), List.of(FORK_V9.capabilityName())));
}
}
Loading