Skip to content

Conversation

@dawidwys
Copy link
Contributor

@dawidwys dawidwys commented Mar 20, 2019

What is the purpose of the change

Splits FieldReferenceExpression into UnresolvedFieldReferenceExpression and FieldReferenceExpression. The latter should use indices of input and field within input as a reference rather than simply always looking up field by name.

Proper use of the FieldReferenceExpression is not part of this PR.

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@dawidwys
Copy link
Contributor Author

@KurtYoung @twalthr Could you have a look?

@flinkbot
Copy link
Collaborator

flinkbot commented Mar 20, 2019

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Review Progress

  • ✅ 1. The [description] looks good.
  • ✅ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ✅ 4. The change fits into the overall [architecture].
  • ✅ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.

Details
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

Copy link
Contributor

@twalthr twalthr left a comment

Choose a reason for hiding this comment

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

Thank you @dawidwys. The changes look good to me.
@flinkbot approve all

this.name = Preconditions.checkNotNull(name);
this.resultType = Optional.of(resultType);
this.resultType = Preconditions.checkNotNull(resultType);
this.inputIndex = inputIndex;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add check for negative values?

}
FieldReferenceExpression that = (FieldReferenceExpression) o;
return Objects.equals(name, that.name) && Objects.equals(resultType, that.resultType);
return inputIndex == that.inputIndex &&
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: order according to field member order?

@twalthr
Copy link
Contributor

twalthr commented Mar 20, 2019

One minor comment: maybe rename the commit message because ResolvedFieldReference does not exist.

@JingsongLi
Copy link
Contributor

Thank you @dawidwys , LGTM, I created a JIRA to track blink aggregation Expressions refactor: https://issues.apache.org/jira/browse/FLINK-11983

@Override
public RexNode visit(Expression other) {
if (other instanceof ResolvedAggInputReference) {
if (other instanceof UnresolvedFieldReferenceExpression) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I need some clarification here. AFAIK, the only "unresolved" expressions only exist during the phase we constructing table API in original Flink, right? The unresolved expression never get a chance to translate to Calcite's RexNode. It should be resolved before that or an exception will throw.

Are we changing this now? If we want to change this, it will be a little ambiguous with who are responsible for resolving all these expressions. Not sure "ExpressionVisitor" is the one, since it can see unresolved & resolved expressions in the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree UnresolvedFieldReference cannot be translated into RexNode and also that it should never end up in the Planner. This is also the main purpose of the UnresolvedFieldReference to make this distinction clear.

ExpressionVisitor is just a way to traverse the operation tree. I am currently working on moving all the resolution of expressions into a single place in the API module, as part of FLINK-11884. I agree we should move this resolution here up to the API module as well once it's in place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the clarification, +1 to "move this resolution here up to the API module"

Copy link
Contributor

@KurtYoung KurtYoung left a comment

Choose a reason for hiding this comment

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

Thanks @dawidwys for fixing this. I got some conceptual questions.

@dawidwys dawidwys merged commit 339ca78 into apache:master Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants