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

ESQL: Remove qualifier from attrs #110581

Merged
merged 10 commits into from
Aug 8, 2024

Conversation

alex-spies
Copy link
Contributor

@alex-spies alex-spies commented Jul 8, 2024

In ES|QL's analyzer, we resolve names to field attributes, like some_field in FROM some_idx | KEEP some_field.

The Attribute type, being copied from (S)QL, has a name and a qualified name, e.g. some_field and some_idx.some_field.

However, we never use the qualifier (some_idx in above's example). In the analyzer, the qualifier is always set to null and during optimization, we often do not take the qualified name into account, because we know the name alone matters.

This is due to ES|QL's treatment of names, which is different from SQL's: at each point in the query, the (intermediate) result's columns must have unique names.

Let's remove Attribute.qualifier. As it is right now, it is confusing because one doesn't know if it may or may not contain relevant info, and especially the Attribute.cluster private member looks like it does something for cross cluster queries, but it really doesn't.

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jul 8, 2024
Copy link
Contributor

@luigidellaquila luigidellaquila left a comment

Choose a reason for hiding this comment

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

Thanks Alex, LGTM

In the analyzer, the qualifier is always set to null

This alone justifies the removal IMHO.

There is a chance that we'll need similar concepts when we implement joins, but my gut feeling says that we'll adopt completely different solutions (as we do for LOOKUP and ENRICH).

And in general, I'd rather add a piece of information only when I need it, to avoid biases in the design of future features.

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.

For the moment, let's keep it as is.

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.
But I'd like @bpintea and @costin to weigh in, as well.
For the record, I am ok removing this for now (#101177 might use it) because it's code that's not used. It was a valid code in ES SQL especially, but ES|QL for now doesn't use it and it creates confusion among contributors.

Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

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

Lgtm

@alex-spies alex-spies added the test-full-bwc Trigger full BWC version matrix tests label Jul 26, 2024
@alex-spies
Copy link
Contributor Author

alex-spies commented Aug 8, 2024

Discussed this offline with @costin .

It's not unlikely that we'll require qualifiers again in some capacity, esp. to improve the language in cases when join-like commands like LOOKUP, ENRICH and INLINESTATS add multiple new attributes.

However, removing qualifiers for now is still advantageous because until qualifiers come back, we have clarity on their usage (none), and if/when they come back, we'll see in the diff exactly where and how they are required for new language features. For instance, it seems reasonable that only Aliases and ReferenceAttributes will require qualifiers because we'll only assign qualifiers when renaming fields; but FieldAttributes may not have qualifiers because they directly reflect index fields.

I'll try to merge this as soon as CI is happy.

@alex-spies alex-spies merged commit f90dc31 into elastic:main Aug 8, 2024
15 checks passed
@alex-spies alex-spies deleted the remove-qualifier-from-attrs branch August 8, 2024 15:30
@alex-spies
Copy link
Contributor Author

Thanks for the reviews @luigidellaquila , @astefan and @bpintea !

weizijun added a commit to weizijun/elasticsearch that referenced this pull request Aug 9, 2024
* upstream/main: (22 commits)
  Prune changelogs after 8.15.0 release
  Bump versions after 8.15.0 release
  EIS integration (elastic#111154)
  Skip LOOKUP/INLINESTATS cases unless on snapshot (elastic#111755)
  Always enforce strict role validation (elastic#111056)
  Mute org.elasticsearch.xpack.esql.analysis.VerifierTests testUnsupportedAndMultiTypedFields elastic#111753
  [ML] Force time shift integration test (elastic#111620)
  ESQL: Add tests for sort, where with unsupported type (elastic#111737)
  [ML] Force time shift documentation (elastic#111668)
  Fix remote cluster credential secure settings reload   (elastic#111535)
  ESQL: Fix for overzealous validation in case of invalid mapped fields (elastic#111475)
  Pass allow security manager flag in gradle test policy setup plugin (elastic#111725)
  Rename streamContent/Separator to bulkContent/Separator (elastic#111716)
  Mute org.elasticsearch.tdigest.ComparisonTests testSparseGaussianDistribution elastic#111721
  Remove 8.14 from branches.json
  Only emit product origin in deprecation log if present (elastic#111683)
  Forward port release notes for v8.15.0 (elastic#111714)
  [ES|QL] Combine Disjunctive CIDRMatch (elastic#111501)
  ESQL: Remove qualifier from attrs (elastic#110581)
  Force using the last centroid during merging (elastic#111644)
  ...

# Conflicts:
#	server/src/main/java/org/elasticsearch/TransportVersions.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceNamedWriteablesProvider.java
@astefan astefan mentioned this pull request Aug 20, 2024
3 tasks
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Sep 4, 2024
In ES|QL's analyzer, we resolve names to field attributes, like some_field in FROM some_idx | KEEP some_field. The Attribute class, being copied from (S)QL, has a name and a qualified name, e.g. some_field and qualifier.some_field.

However, we never use the qualifier, so remove it.
davidkyle pushed a commit to davidkyle/elasticsearch that referenced this pull request Sep 5, 2024
In ES|QL's analyzer, we resolve names to field attributes, like some_field in FROM some_idx | KEEP some_field. The Attribute class, being copied from (S)QL, has a name and a qualified name, e.g. some_field and qualifier.some_field.

However, we never use the qualifier, so remove it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) test-full-bwc Trigger full BWC version matrix tests v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants