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

[FLINK-18325] [table-common] Handle null when calling SqlDataTypeSpec#getNullable #13836

Closed
wants to merge 1 commit into from

Conversation

Aaaaaaron
Copy link
Member

What is the purpose of the change

SqlDataTypeSpec#getNullable may return null(by Calcite design, it returns "Boolean" instead "boolean"), so the caller should handle null itself. In Calcite, every place calls this method adds the null judge.

Below is the code from Calcite.
org.apache.calcite.sql.SqlDataTypeSpec

  /** Whether data type allows nulls.
   *
   * <p>Nullable is nullable! Null means "not specified". E.g.
   * {@code CAST(x AS INTEGER)} preserves the same nullability as {@code x}.
   */
  private Boolean nullable;

Brief change log

Handle "null" when calling SqlDataTypeSpec#getNullable.

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): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (no)

@flinkbot
Copy link
Collaborator

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.

Automated Checks

Last check on commit 394a442 (Thu Oct 29 07:22:11 UTC 2020)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

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.


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

@Aaaaaaron Aaaaaaron changed the title [FLINK-18325] [table-common] Handle "null" when calling SqlDataTypeSpec#getNullable [FLINK-18325] [table-common] Handle null when calling SqlDataTypeSpec#getNullable Oct 29, 2020
@flinkbot
Copy link
Collaborator

flinkbot commented Oct 29, 2020

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build
  • @flinkbot run azure re-run the last Azure build

@Aaaaaaron
Copy link
Member Author

Can someone review this PR?

@wuchong
Copy link
Member

wuchong commented Nov 3, 2020

From the implementation of ExtendedDataType in flink-sql-parser/parserImpls.ftl, the default nullable has been set to true. So it is always not null in Flink and it's safe to just call SqlDataTypeSpec#getNullable. However, I'm fine to add this null check. What do you think @danny0405 ?

@danny0405
Copy link
Contributor

From the implementation of ExtendedDataType in flink-sql-parser/parserImpls.ftl, the default nullable has been set to true. So it is always not null in Flink and it's safe to just call SqlDataTypeSpec#getNullable. However, I'm fine to add this null check. What do you think @danny0405 ?

Yes, we always set the flag in Flink so it should be null-safe, but adding an explicit check is better(in case maybe there are some changes in the parser later on).

@wuchong
Copy link
Member

wuchong commented Nov 3, 2020

Thanks @danny0405 . Then I'm fine with this PR.

LGTM.

wuchong pushed a commit to wuchong/flink that referenced this pull request Nov 3, 2020
@wuchong
Copy link
Member

wuchong commented Nov 4, 2020

@wuchong wuchong closed this in 9652b6d Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants