Skip to content

refactor: move AttributeReference and KnownFloatingPointNormalized expression support checks to getSupportLevel#4745

Open
peterxcli wants to merge 2 commits into
apache:mainfrom
peterxcli:misc-scalar-serdes
Open

refactor: move AttributeReference and KnownFloatingPointNormalized expression support checks to getSupportLevel#4745
peterxcli wants to merge 2 commits into
apache:mainfrom
peterxcli:misc-scalar-serdes

Conversation

@peterxcli

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #4673.

Rationale for this change

This finishes the misc scalar serde follow-up for #4673. These serdes still had static support decisions in convert, even though the dispatcher expects those decisions to come from getSupportLevel.

Binding-dependent failures and child fallback rollups still stay in convert.

What changes are included in this PR?

Move static support checks into getSupportLevel for:

  • AttributeReference: unsupported data types.
  • FromUnixTime: unsupported native datetime format when the incompatible native path is enabled, while keeping the default codegen-dispatch path unchanged.
  • KnownFloatingPointNormalized: unsupported wrapped child data types.

The remaining withFallbackReason calls in these files are for child conversion or binding-dependent failures.

How are these changes tested?

Added focused coverage in CometExpressionSuite for the misc scalar serde getSupportLevel decisions.

Also ran:

./mvnw test -Pspark-3.5 -Pscala-2.12 -Dtest=none -Dsuites="org.apache.comet.CometExpressionSuite misc scalar serdes report static unsupported cases via getSupportLevel" -Dscalastyle.skip=true

@peterxcli peterxcli changed the title Report unsupported scalar serde cases in support level refactor: move AttributeReference, FromUnixTime and KnownFloatingPointNormalized expression support checks to getSupportLevel Jun 28, 2026
override def getSupportLevel(expr: FromUnixTime): SupportLevel = Incompatible(None)
override def getSupportLevel(expr: FromUnixTime): SupportLevel = {
if (expr.format == Literal(TimestampFormatter.defaultPattern()) ||
!CometConf.isExprAllowIncompat(getExprConfigName(expr))) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm confused about the reference to isExprAllowIncompat here. Typically we would just return Incompatible and then rely on the serde framework checkign this flag.

// TODO: DataFusion supports only -8334601211038 <= sec <= 8210266876799
// https://github.com/apache/datafusion/issues/16594
object CometFromUnixTime extends CometExpressionSerde[FromUnixTime] with CodegenDispatchFallback {
private val unsupportedFormatReason = "Datetime pattern format is unsupported"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you implement getUnsupportedReasons, referencing unsupportedFormatReason so that this gets generated into the docs?

@peterxcli peterxcli requested a review from andygrove July 12, 2026 13:14
@peterxcli peterxcli marked this pull request as ready for review July 12, 2026 13:16
@peterxcli peterxcli changed the title refactor: move AttributeReference, FromUnixTime and KnownFloatingPointNormalized expression support checks to getSupportLevel refactor: move AttributeReference and KnownFloatingPointNormalized expression support checks to getSupportLevel Jul 12, 2026
@peterxcli

Copy link
Copy Markdown
Member Author

@andygrove looks like the above two comments have been addressed in your pr #4847, I have merged the upstream main, please take another looks on the refactor for AttributeReference and KnownFloatingPointNormalized expr. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move static support decisions from serde convert into getSupportLevel

2 participants