Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Redefine the Expression interface and Type #550

Merged

Conversation

penghuo
Copy link
Contributor

@penghuo penghuo commented Jul 8, 2020

Issue #, if available:

Description of changes:

1.Expression

In current design, the Expression has two observers, valueOf and type.

public interface Expression {

  /**
   * Evaluate the value of expression in the value environment.
   */
  ExprValue valueOf(Environment<Expression, ExprValue> valueEnv);

  /**
   * Evaluate the type of expression in the type environment.
   */
  ExprType type(Environment<Expression, ExprType> typeEnv);
}

The Expression is construct during the analyzer stage with the type environment provided by the storage engine. so the type observer should not rely on the type environment during the execution stage.
The interface of Expression should be changed as follows

public interface Expression {

  /**
   * Evaluate the value of expression in the value environment.
   */
  ExprValue valueOf(Environment<Expression, ExprValue> valueEnv);

  /**
   * Retrieve the type of expression.
   */
  ExprType type();
}

2.Expression Type (ExprType)

The ExprType define the Type of expression in the QueryEngine. In current design, ExprType is enum which can't been extended.
In this PR, we define the ExprType as the interface and define the ExprCoreType which extends the ExprType.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@penghuo penghuo requested review from chloe-zh and dai-chen July 8, 2020 01:29
@penghuo penghuo self-assigned this Jul 8, 2020
@penghuo penghuo added the SQL label Jul 8, 2020
Copy link
Member

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

Copy link
Member

@chloe-zh chloe-zh left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@penghuo penghuo merged commit 8df9a88 into opendistro-for-elasticsearch:develop Jul 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants