Skip to content

Conversation

@twalthr
Copy link
Contributor

@twalthr twalthr commented May 22, 2019

What is the purpose of the change

This PR updates ImplicitExpressionOperations#cast and TypeLiteralExpression. The Java expression API remains untouched for now.

This PR builds on top of #8500.

Brief change log

  • Deprecate old cast()
  • Update TypeLiteralExpression
  • Use legacy conversion where applicable

Verifying this change

This change is already covered by existing tests.

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

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

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? JavaDocs

@flinkbot
Copy link
Collaborator

flinkbot commented May 22, 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

@dawidwys dawidwys left a comment

Choose a reason for hiding this comment

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

Generally +1. Before merging I would only slightly improve the deprecation note on expressionDsl#cast


/**
* Expression that wraps {@link TypeInformation} as a literal.
* Expression that wraps {@link DataType} as a literal.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: How about we add a note why do we need it? That this is primarily used for casts.

call(CAST, expr, typeLiteral(toType))

/**
* @deprecated Use [[cast(DataType)]] instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could we add a bit longer note that it might be unsafe to mix the DataType and TypeInformation stacks?

// check for constant
return ExpressionUtils.extractValue(e, BasicTypeInfo.INT_TYPE_INFO)
.map((v) -> (Expression) valueLiteral(v * multiplier, TimeIntervalTypeInfo.INTERVAL_MONTHS))
.orElse(
Copy link
Contributor

Choose a reason for hiding this comment

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

This changes the behavior of this method right? Previously e.g. (1 + 3).toMonthInterval or even (1 + f0).toMonthInterval was possible right? (Even though e.g. the window aggregation did not accept it)

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, that's right but this behavior was not even tested somewhere and for simplification of the design I think it is ok to limit the values to constants. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, just wanted to double check.

@twalthr twalthr force-pushed the FLINK-12254_CAST branch from 00a2f44 to 9490e4b Compare May 27, 2019 09:21
@twalthr
Copy link
Contributor Author

twalthr commented May 27, 2019

Thanks for the feedback @dawidwys. I updated the PR. Will merge this once Travis is green.

@dawidwys
Copy link
Contributor

@flinkbot approve all

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.

4 participants