Skip to content

enhance: avoid cast expr in Between as much as possible. #6102

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

jackwener
Copy link
Member

Which issue does this PR close?

part of #5928.

Rationale for this change

Part of job about type_coercion.

What changes are included in this PR?

avoid cast expr in Between as much as possible.

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules labels Apr 23, 2023
@jackwener jackwener changed the title feat: avoid cast expr in Between as much as possible. enhance: avoid cast expr in Between as much as possible. Apr 23, 2023
));
Ok(expr)
let between_common_type = comparison_coercion(&low_type, &high_type).ok_or(DataFusionError::Internal(format!("Failed to coerce types {low_type} and {high_type} in BETWEEN expression")))?;
// Because low/high is Literal, cast them as much as possible to avoid cast expr.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the high and low are always Literal?

@mingmwang
Copy link
Contributor

@jackwener
Could you please help to check the behavior of PG?

In Spark 3.x, there is a configuration to control the String/Date type cast conversions.

  val LEGACY_CAST_DATETIME_TO_STRING =
    buildConf("spark.sql.legacy.typeCoercion.datetimeToString.enabled")
      .internal()
      .doc("If it is set to true, date/timestamp will cast to string in binary comparisons " +
        s"with String when ${ANSI_ENABLED.key} is false.")
      .version("3.0.0")
      .booleanConf
      .createWithDefault(false)

@jackwener
Copy link
Member Author

@mingmwang thanks, this PR is wrong. I will fix it

@jackwener jackwener closed this Apr 24, 2023
@jackwener jackwener deleted the type branch May 12, 2023 12:29
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants