Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: Fix qualified attribute resolution with CCS #81320

Merged
merged 5 commits into from
Dec 9, 2021

Conversation

bpintea
Copy link
Contributor

@bpintea bpintea commented Dec 3, 2021

In case the fields are qualified only by the index name in a
CCS SQL query, the field resolution was failing since an
attribute's qualification contains the cluster name, while a field's doesn't.

This changes the existing Attribute#qualifiedName() to return a qualification
including the index name only and adds (for completion) a new method,
fullyQualifiedName(), which will return the 'cluster:index' qualification.

This will allow queries like this to work:
SELECT remote_index.field FROM remote_cluster:remote_index
or
SELECT remote_index.field FROM remote_index when the cluster is provided
through the xDBC "cluster" parameter.

In case the fields are qualified only by the index name in a
cross cluster search query, the field resolution was failing since an
attribute's qualification contains the cluster name, while a field's doesn't.

This changes the existing  `Attribute#qualifiedName()` to return a qualification
including the index name only and adds (for completion) a new method,
`fullyQualifiedName()`, which will return the 'cluster:index' qualification.

This will allow queries like this to work:
 `SELECT remote_index.field FROM remote_cluster:remote_index`
or
 `SELECT remote_index.field FROM remote_index` when the cluster is provided
through the xDBC "cluster" parameter.
@bpintea bpintea marked this pull request as ready for review December 6, 2021 08:45
@elasticmachine elasticmachine added the Team:QL (Deprecated) Meta label for query languages team label Dec 6, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

Left some minor comments - LGTM otherwise.

Comment on lines 17 to 18
import static org.elasticsearch.transport.RemoteClusterAware.buildRemoteIndexName;
import static org.elasticsearch.xpack.ql.util.RemoteClusterUtils.splitQualifiedIndex;
Copy link
Member

Choose a reason for hiding this comment

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

Let's wrap this functionality (which is just string manipulation) inside StringUtils inside ql - those methods can call just delegate behind the scenes.
RemoteClusterUtils might be be folded into that if possible.

The upside is we don't depend directly on transport or remote write but rather it's just a StringUtils.splitCatalog or something similar.

@@ -62,6 +74,10 @@ public String qualifiedName() {
return qualifier == null ? name() : qualifier + "." + name();
}

public String fullyQualifiedName() {
Copy link
Member

Choose a reason for hiding this comment

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

Who uses fully qualified name? If there's nobody I would remove it.
If it has to stay, I recommend rename it something like catalogQualifiedName() - fully doesn't convey much.

- remove currently unused method;
- move RemoteClusterUtils methods into StringUtils.
@bpintea
Copy link
Contributor Author

bpintea commented Dec 8, 2021

@elasticmachine run elasticsearch-ci/part-2

@bpintea bpintea added the auto-backport Automatically create backport pull requests when merged label Dec 8, 2021
@bpintea
Copy link
Contributor Author

bpintea commented Dec 8, 2021

@elasticmachine update branch

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM

@bpintea bpintea merged commit b291bf1 into elastic:master Dec 9, 2021
@bpintea bpintea deleted the fix/field_qualifier_with_ccs branch December 9, 2021 07:26
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.0

bpintea added a commit to bpintea/elasticsearch that referenced this pull request Dec 9, 2021
In case the fields are qualified only by the index name in a
cross cluster search query, the field resolution was failing since an
attribute's qualification contains the cluster name, while a field's doesn't.

This changes the existing  `Attribute#qualifiedName()` to return a qualification
including the index name only and adds (for completion) a new method,
`fullyQualifiedName()`, which will return the 'cluster:index' qualification.

This will allow queries like this to work:
 `SELECT remote_index.field FROM remote_cluster:remote_index`
or
 `SELECT remote_index.field FROM remote_index` when the cluster is provided
through the xDBC "cluster" parameter.
bpintea added a commit that referenced this pull request Dec 9, 2021
In case the fields are qualified only by the index name in a
cross cluster search query, the field resolution was failing since an
attribute's qualification contains the cluster name, while a field's doesn't.

This changes the existing  `Attribute#qualifiedName()` to return a qualification
including the index name only and adds (for completion) a new method,
`fullyQualifiedName()`, which will return the 'cluster:index' qualification.

This will allow queries like this to work:
 `SELECT remote_index.field FROM remote_cluster:remote_index`
or
 `SELECT remote_index.field FROM remote_index` when the cluster is provided
through the xDBC "cluster" parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/SQL SQL querying auto-backport Automatically create backport pull requests when merged >bug Team:QL (Deprecated) Meta label for query languages team v8.0.0-rc1 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants