Skip to content

Parse user type hints to ValuesSourceTypes#66662

Open
RobertoMiyoshi wants to merge 11 commits intoelastic:mainfrom
RobertoMiyoshi:master
Open

Parse user type hints to ValuesSourceTypes#66662
RobertoMiyoshi wants to merge 11 commits intoelastic:mainfrom
RobertoMiyoshi:master

Conversation

@RobertoMiyoshi
Copy link
Copy Markdown

Closes #53424. The previous mapping of user type hints to the ValuesSourceType was based on a Surjective function, i.e., several of ValueTypes can be mapped to the same ValuesSourceType. In order to maintain compatibility with previous version, this PR is proposing a new mapping through a Bijection, covering the parsing and output the same json that is currently accepted, and also serializing and deserializing the same bytes.

…f SOLID principles trying to reduce maintenance and modification costs by improving understandability, reliability, reusability and robustness.
…ctices of SOLID principles trying to reduce maintenance and modification costs by improving understandability, reliability, reusability and robustness."

This reverts commit 90fb919
…f SOLID principles trying to reduce maintenance and modification costs by improving understandability, reliability, reusability and robustness.
…ctices of SOLID principles trying to reduce maintenance and modification costs by improving understandability, reliability, reusability and robustness."

This reverts commit 90fb919
@astefan astefan added the :Analytics/Aggregations Aggregations label Dec 21, 2020
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Dec 21, 2020
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

Copy link
Copy Markdown
Member

@not-napoleon not-napoleon left a comment

Choose a reason for hiding this comment

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

I think you're overcomplicating this. Here's roughly how I expect this should work:

  • ValueType#lenientParse(String) should start returning a ValuesSourceType instead
  • userValueTypeHint should change to be a ValuesSourceType
  • When we go to serialize userValueTypeHint we should have some function that serializes it based on the old ValueType ids (and deserializes it, naturally).

There may be complications there that I haven't thought about, since I'm not actively working on this, but that's the general approach I want to follow here. Let's see how far we can get doing that.

I don't want to add any new concepts for representing types in the aggs framework. We have too many of those already, and the long term goal is to reduce the number of ways we represent type information.

Also, as I said on your previous PR, please follow the CONTRIBUTING.md guild for formatting and checkstyle, and run ./gradlew check locally before submitting the PR. Also, please don't include unrelated formatting changes or other "cleanups". I suggest either disabling your IDE's auto-format, or importing our settings (again, follow the instructions in CONTRIBUTING) and only format the parts of the file you're changing. In Intellij, you can do this by going to code > format file > only VCS changed text

import java.io.IOException;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.Arrays;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please follow our formatting guidelines, listed here: https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md#java-language-formatting-guidelines. Wildcard imports are specifically forbidden. There are instructions in that file for configuring intellij to use our formatting & checkstyle settings, or you can run ./gradlew precommit to run checkstyle.

public static List<ValuesSourceType> ALL_CORE = Arrays.asList(CoreValuesSourceType.values());
public static List<ValuesSourceType> ALL_CORE = Arrays.asList(values());

public enum ValueType implements Writeable {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This look like it's just duplicated from ValueType? I don't think we need a new, second, ValueType concept here.

@elasticsearchmachine elasticsearchmachine changed the base branch from master to main July 22, 2022 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/Aggregations Aggregations Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parse user type hints directly to ValuesSourceTypes

4 participants