Skip to content

[CORE] Refactor ExpressionConverter to use explicit Option return instead of Option(null)#11757

Merged
zml1206 merged 4 commits intoapache:mainfrom
acvictor:acvictor/nullSome
Mar 17, 2026
Merged

[CORE] Refactor ExpressionConverter to use explicit Option return instead of Option(null)#11757
zml1206 merged 4 commits intoapache:mainfrom
acvictor:acvictor/nullSome

Conversation

@acvictor
Copy link
Contributor

@acvictor acvictor commented Mar 13, 2026

What changes are proposed in this pull request?

This PR replaces Option { expr match { ... case _ => null } } with explicit Some(...)/None returns in tryTransformWithoutExpressionMapping to make the intent clearer and avoid the subtle dependency on Option.apply's null-handling behavior.

How was this patch tested?

Existing UTs.

Was this patch authored or co-authored using generative AI tooling?

No

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

@github-actions github-actions bot added the CORE works for Gluten Core label Mar 13, 2026
@acvictor acvictor marked this pull request as ready for review March 13, 2026 17:10
@acvictor
Copy link
Contributor Author

@baibaichen can you please review this PR? Thanks!

Copy link
Contributor

@zml1206 zml1206 left a comment

Choose a reason for hiding this comment

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

This is not a bug fix, it's a code optimization. Option(null) is equivalent to None, Some(null) is not equivalent, Option is used here. Please change the title and description.

@acvictor acvictor changed the title Fix Some(null) in ExpressionConverter bypassing expression transformation fallback Refactor ExpressionConverter to use explicit Option return instead of Option(null) Mar 16, 2026
@acvictor
Copy link
Contributor Author

This is not a bug fix, it's a code optimization. Option(null) is equivalent to None, Some(null) is not equivalent, Option is used here. Please change the title and description.

Done, thanks for the review!

@zml1206 zml1206 changed the title Refactor ExpressionConverter to use explicit Option return instead of Option(null) [CORE] Refactor ExpressionConverter to use explicit Option return instead of Option(null) Mar 17, 2026
Comment on lines +289 to +299
Some(replacePythonUDFWithExpressionTransformer(pythonUDF, attributeSeq, expressionsMap))
case scalaUDF: ScalaUDF =>
Some(replaceScalaUDFWithExpressionTransformer(scalaUDF, attributeSeq, expressionsMap))
case _ if HiveUDFTransformer.isHiveUDF(expr) =>
Some(
BackendsApiManager.getSparkPlanExecApiInstance.genHiveUDFTransformer(expr, attributeSeq))
case staticInvoke: StaticInvoke =>
Some(
replaceStaticInvokeWithExpressionTransformer(staticInvoke, attributeSeq, expressionsMap))
case invoke: Invoke =>
Some(replaceInvokeWithExpressionTransformer(invoke, attributeSeq, expressionsMap))
Copy link
Contributor

@zml1206 zml1206 Mar 17, 2026

Choose a reason for hiding this comment

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

Please use Option instead of Some to prevent the existence of Some(null), although it should not exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

@github-actions
Copy link

Run Gluten Clickhouse CI on x86

Copy link
Contributor

@zml1206 zml1206 left a comment

Choose a reason for hiding this comment

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

Thanks.

@zml1206 zml1206 merged commit 739f9e6 into apache:main Mar 17, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants