You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "andygrove (via GitHub)" <gi...@apache.org> on 2025/11/16 16:37:07 UTC
[PR] chore: Refactor more expr serde [datafusion-comet]
andygrove opened a new pull request, #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Part of https://github.com/apache/datafusion-comet/issues/2019
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Finish refactoring expression serde out of `QueryPlanSerde` [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2535666849
##########
spark/src/main/scala/org/apache/comet/serde/CometMakeDecimal.scala:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.serde
+
+import org.apache.spark.sql.catalyst.expressions.{Attribute, MakeDecimal}
+import org.apache.spark.sql.types.DecimalType
+
+import org.apache.comet.serde.QueryPlanSerde.{exprToProtoInternal, optExprWithInfo, scalarFunctionExprToProtoWithReturnType}
+
+object CometMakeDecimal extends CometExpressionSerde[MakeDecimal] {
+ override def convert(
+ expr: MakeDecimal,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+ val childExpr = exprToProtoInternal(expr.child, inputs, binding)
+ val optExpr = scalarFunctionExprToProtoWithReturnType(
+ "make_decimal",
+ DecimalType(expr.precision, expr.scale),
+ false,
Review Comment:
I see what changed now. Previously, we only supported `MakeDecimal` in the case that `nullOnOverflow=true`, but now we always support it. So this PR does introduce a functional change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Finish refactoring expression serde out of `QueryPlanSerde` [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2535670571
##########
spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala:
##########
@@ -204,17 +203,16 @@ object QueryPlanSerde extends Logging with CometExprShim {
private val miscExpressions: Map[Class[_ <: Expression], CometExpressionSerde[_]] = Map(
// TODO PromotePrecision
// TODO KnownFloatingPointNormalized
- // TODO ScalarSubquery
// TODO UnscaledValue
Review Comment:
Updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Refactor more expr serde [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2534696127
##########
spark/src/main/scala/org/apache/comet/serde/CometMakeDecimal.scala:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.serde
+
+import org.apache.spark.sql.catalyst.expressions.{Attribute, MakeDecimal}
+import org.apache.spark.sql.types.DecimalType
+
+import org.apache.comet.serde.QueryPlanSerde.{exprToProtoInternal, optExprWithInfo, scalarFunctionExprToProtoWithReturnType}
+
+object CometMakeDecimal extends CometExpressionSerde[MakeDecimal] {
+ override def convert(
+ expr: MakeDecimal,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+ val childExpr = exprToProtoInternal(expr.child, inputs, binding)
+ val optExpr = scalarFunctionExprToProtoWithReturnType(
+ "make_decimal",
+ DecimalType(expr.precision, expr.scale),
+ false,
Review Comment:
Thanks. I filed https://github.com/apache/datafusion-comet/issues/2793 to investigate. For this PR, I wanted to just refactor and not make any functional changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Refactor more expr serde [datafusion-comet]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2533069720
##########
spark/src/main/scala/org/apache/comet/serde/CometUnscaledValue.scala:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.serde
+
+import org.apache.spark.sql.catalyst.expressions.{Attribute, UnscaledValue}
+import org.apache.spark.sql.types.LongType
+
+import org.apache.comet.serde.QueryPlanSerde.{exprToProtoInternal, optExprWithInfo, scalarFunctionExprToProtoWithReturnType}
+
+class CometUnscaledValue extends CometExpressionSerde[UnscaledValue] {
Review Comment:
```suggestion
object CometUnscaledValue extends CometExpressionSerde[UnscaledValue] {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Refactor more expr serde [datafusion-comet]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#issuecomment-3538968614
## [Codecov](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `0%` with `46 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 10.76%. Comparing base ([`f09f8af`](https://app.codecov.io/gh/apache/datafusion-comet/commit/f09f8af64c6599255e116a376f4f008f2fd63b43?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`9adfadd`](https://app.codecov.io/gh/apache/datafusion-comet/commit/9adfadd102f370128b0f65d79791d779f64e7b8e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 706 commits behind head on main.
| [Files with missing lines](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...che/comet/serde/CometBloomFilterMightContain.scala](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&filepath=spark%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fcomet%2Fserde%2FCometBloomFilterMightContain.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3Bhcmsvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9jb21ldC9zZXJkZS9Db21ldEJsb29tRmlsdGVyTWlnaHRDb250YWluLnNjYWxh) | 0.00% | [14 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...a/org/apache/comet/serde/CometScalarSubquery.scala](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&filepath=spark%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fcomet%2Fserde%2FCometScalarSubquery.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3Bhcmsvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9jb21ldC9zZXJkZS9Db21ldFNjYWxhclN1YnF1ZXJ5LnNjYWxh) | 0.00% | [12 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...cala/org/apache/comet/serde/CometMakeDecimal.scala](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&filepath=spark%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fcomet%2Fserde%2FCometMakeDecimal.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3Bhcmsvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9jb21ldC9zZXJkZS9Db21ldE1ha2VEZWNpbWFsLnNjYWxh) | 0.00% | [8 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...la/org/apache/comet/serde/CometUnscaledValue.scala](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&filepath=spark%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fcomet%2Fserde%2FCometUnscaledValue.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3Bhcmsvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9jb21ldC9zZXJkZS9Db21ldFVuc2NhbGVkVmFsdWUuc2NhbGE=) | 0.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [.../scala/org/apache/comet/serde/QueryPlanSerde.scala](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&filepath=spark%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fcomet%2Fserde%2FQueryPlanSerde.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3Bhcmsvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9jb21ldC9zZXJkZS9RdWVyeVBsYW5TZXJkZS5zY2FsYQ==) | 0.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...rc/main/scala/org/apache/comet/serde/strings.scala](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&filepath=spark%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fcomet%2Fserde%2Fstrings.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3Bhcmsvc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9jb21ldC9zZXJkZS9zdHJpbmdzLnNjYWxh) | 0.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #2791 +/- ##
=============================================
- Coverage 56.12% 10.76% -45.37%
+ Complexity 976 232 -744
=============================================
Files 119 161 +42
Lines 11743 14106 +2363
Branches 2251 2342 +91
=============================================
- Hits 6591 1518 -5073
- Misses 4012 12413 +8401
+ Partials 1140 175 -965
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/datafusion-comet/pull/2791?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Finish refactoring expression serde out of `QueryPlanSerde` [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2535670942
##########
spark/src/main/scala/org/apache/comet/serde/CometUnscaledValue.scala:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.serde
+
+import org.apache.spark.sql.catalyst.expressions.{Attribute, UnscaledValue}
+import org.apache.spark.sql.types.LongType
+
+import org.apache.comet.serde.QueryPlanSerde.{exprToProtoInternal, optExprWithInfo, scalarFunctionExprToProtoWithReturnType}
+
+class CometUnscaledValue extends CometExpressionSerde[UnscaledValue] {
Review Comment:
Updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Finish refactoring expression serde out of `QueryPlanSerde` [datafusion-comet]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2536329409
##########
spark/src/main/scala/org/apache/comet/serde/strings.scala:
##########
@@ -21,15 +21,34 @@ package org.apache.comet.serde
import java.util.Locale
-import org.apache.spark.sql.catalyst.expressions.{Attribute, Cast, Concat, Expression, InitCap, Length, Like, Literal, Lower, RegExpReplace, RLike, StringLPad, StringRepeat, StringRPad, Substring, Upper}
-import org.apache.spark.sql.types.{BinaryType, DataTypes, LongType, StringType}
+import org.apache.spark.sql.catalyst.expressions.{Attribute, Cast, Concat, Expression, InitCap, Length, Like, Literal, Lower, RegExpReplace, Reverse, RLike, StringLPad, StringRepeat, StringRPad, Substring, Upper}
+import org.apache.spark.sql.types.{ArrayType, BinaryType, DataTypes, LongType, StringType}
import org.apache.comet.CometConf
import org.apache.comet.CometSparkSessionExtensions.withInfo
import org.apache.comet.expressions.{CometCast, CometEvalMode, RegExp}
import org.apache.comet.serde.ExprOuterClass.Expr
import org.apache.comet.serde.QueryPlanSerde.{createBinaryExpr, exprToProtoInternal, optExprWithInfo, scalarFunctionExprToProto}
+object CometReverse extends CometScalarFunction[Reverse]("reverse") {
Review Comment:
Why is `Reverse` placed in `strings.scala`? In Spark, it belongs to `collection_funcs`.
https://github.com/apache/spark/blob/35a99f84a352ad995593d0a7a5a1433d235fcbc5/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala#L1348-L1363
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Finish refactoring expression serde out of `QueryPlanSerde` [datafusion-comet]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2536820473
##########
spark/src/main/scala/org/apache/comet/serde/misc.scala:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.serde
+
+import org.apache.spark.sql.catalyst.expressions.{Attribute, BloomFilterMightContain, KnownFloatingPointNormalized, MakeDecimal, UnscaledValue}
+import org.apache.spark.sql.catalyst.optimizer.NormalizeNaNAndZero
+import org.apache.spark.sql.types.{DecimalType, LongType}
+
+import org.apache.comet.CometSparkSessionExtensions.withInfo
+import org.apache.comet.serde.QueryPlanSerde.{exprToProtoInternal, optExprWithInfo, scalarFunctionExprToProtoWithReturnType, serializeDataType}
+
+object CometUnscaledValue extends CometExpressionSerde[UnscaledValue] {
+ override def convert(
+ expr: UnscaledValue,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+ val childExpr = exprToProtoInternal(expr.child, inputs, binding)
+ val optExpr =
+ scalarFunctionExprToProtoWithReturnType("unscaled_value", LongType, false, childExpr)
+ optExprWithInfo(optExpr, expr, expr.child)
+
+ }
+}
+object CometKnownFloatingPointNormalized
+ extends CometExpressionSerde[KnownFloatingPointNormalized] {
+
+ override def getSupportLevel(expr: KnownFloatingPointNormalized): SupportLevel = {
+ expr.child match {
+ case _: NormalizeNaNAndZero => Compatible()
+ case _ => Unsupported()
Review Comment:
```suggestion
case _ => Unsupported(Some("KnownFloatingPointNormalized only supports NormalizeNaNAndZero child expressions"))
```
##########
spark/src/main/scala/org/apache/comet/serde/misc.scala:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.serde
+
+import org.apache.spark.sql.catalyst.expressions.{Attribute, BloomFilterMightContain, KnownFloatingPointNormalized, MakeDecimal, UnscaledValue}
+import org.apache.spark.sql.catalyst.optimizer.NormalizeNaNAndZero
+import org.apache.spark.sql.types.{DecimalType, LongType}
+
+import org.apache.comet.CometSparkSessionExtensions.withInfo
+import org.apache.comet.serde.QueryPlanSerde.{exprToProtoInternal, optExprWithInfo, scalarFunctionExprToProtoWithReturnType, serializeDataType}
+
+object CometUnscaledValue extends CometExpressionSerde[UnscaledValue] {
+ override def convert(
+ expr: UnscaledValue,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+ val childExpr = exprToProtoInternal(expr.child, inputs, binding)
+ val optExpr =
+ scalarFunctionExprToProtoWithReturnType("unscaled_value", LongType, false, childExpr)
+ optExprWithInfo(optExpr, expr, expr.child)
+
+ }
+}
+object CometKnownFloatingPointNormalized
+ extends CometExpressionSerde[KnownFloatingPointNormalized] {
+
+ override def getSupportLevel(expr: KnownFloatingPointNormalized): SupportLevel = {
+ expr.child match {
+ case _: NormalizeNaNAndZero => Compatible()
+ case _ => Unsupported()
+ }
+ }
+
+ override def convert(
+ expr: KnownFloatingPointNormalized,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+
+ val wrapped = expr.child.asInstanceOf[NormalizeNaNAndZero].child
+
+ val dataType = serializeDataType(wrapped.dataType)
+ if (dataType.isEmpty) {
+ withInfo(wrapped, s"Unsupported datatype ${wrapped.dataType}")
+ return None
+ }
+ val ex = exprToProtoInternal(wrapped, inputs, binding)
+ ex.map { child =>
+ val builder = ExprOuterClass.NormalizeNaNAndZero
+ .newBuilder()
+ .setChild(child)
+ .setDatatype(dataType.get)
+ ExprOuterClass.Expr.newBuilder().setNormalizeNanAndZero(builder).build()
+ }
Review Comment:
```suggestion
}
optExprWithInfo(optExpr, expr, wrapped)
```
##########
spark/src/main/scala/org/apache/comet/serde/CometScalarSubquery.scala:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.serde
+
+import org.apache.spark.sql.catalyst.expressions.Attribute
+import org.apache.spark.sql.execution.ScalarSubquery
+
+import org.apache.comet.CometSparkSessionExtensions.withInfo
+import org.apache.comet.serde.QueryPlanSerde.{serializeDataType, supportedDataType}
+
+object CometScalarSubquery extends CometExpressionSerde[ScalarSubquery] {
+ override def convert(
+ expr: ScalarSubquery,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+ if (supportedDataType(expr.dataType)) {
+ val dataType = serializeDataType(expr.dataType)
+ if (dataType.isEmpty) {
+ withInfo(expr, s"Scalar subquery returns unsupported datatype ${expr.dataType}")
Review Comment:
```suggestion
withInfo(expr, s"Failed to serialize datatype ${expr.dataType} for scalar subquery")
```
`if (supportedDataType(expr.dataType))` has passed, so the problem must be at `serializeDataType(expr.dataType)`
##########
spark/src/main/scala/org/apache/comet/serde/misc.scala:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.serde
+
+import org.apache.spark.sql.catalyst.expressions.{Attribute, BloomFilterMightContain, KnownFloatingPointNormalized, MakeDecimal, UnscaledValue}
+import org.apache.spark.sql.catalyst.optimizer.NormalizeNaNAndZero
+import org.apache.spark.sql.types.{DecimalType, LongType}
+
+import org.apache.comet.CometSparkSessionExtensions.withInfo
+import org.apache.comet.serde.QueryPlanSerde.{exprToProtoInternal, optExprWithInfo, scalarFunctionExprToProtoWithReturnType, serializeDataType}
+
+object CometUnscaledValue extends CometExpressionSerde[UnscaledValue] {
+ override def convert(
+ expr: UnscaledValue,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+ val childExpr = exprToProtoInternal(expr.child, inputs, binding)
+ val optExpr =
+ scalarFunctionExprToProtoWithReturnType("unscaled_value", LongType, false, childExpr)
+ optExprWithInfo(optExpr, expr, expr.child)
+
+ }
+}
+object CometKnownFloatingPointNormalized
+ extends CometExpressionSerde[KnownFloatingPointNormalized] {
+
+ override def getSupportLevel(expr: KnownFloatingPointNormalized): SupportLevel = {
+ expr.child match {
+ case _: NormalizeNaNAndZero => Compatible()
+ case _ => Unsupported()
+ }
+ }
+
+ override def convert(
+ expr: KnownFloatingPointNormalized,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+
+ val wrapped = expr.child.asInstanceOf[NormalizeNaNAndZero].child
+
+ val dataType = serializeDataType(wrapped.dataType)
+ if (dataType.isEmpty) {
+ withInfo(wrapped, s"Unsupported datatype ${wrapped.dataType}")
+ return None
+ }
+ val ex = exprToProtoInternal(wrapped, inputs, binding)
+ ex.map { child =>
Review Comment:
```suggestion
val optExpr = ex.map { child =>
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Finish refactoring expression serde out of `QueryPlanSerde` [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2535663111
##########
docs/source/user-guide/latest/configs.md:
##########
@@ -289,6 +291,7 @@ These settings can be used to determine which parts of the plan are accelerated
| `spark.comet.expression.Remainder.enabled` | Enable Comet acceleration for `Remainder` | true |
| `spark.comet.expression.Reverse.enabled` | Enable Comet acceleration for `Reverse` | true |
| `spark.comet.expression.Round.enabled` | Enable Comet acceleration for `Round` | true |
+| `spark.comet.expression.ScalarSubquery.enabled` | Enable Comet acceleration for `ScalarSubquery` | true |
| `spark.comet.expression.Second.enabled` | Enable Comet acceleration for `Second` | true |
| `spark.comet.expression.Sha1.enabled` | Enable Comet acceleration for `Sha1` | true |
| `spark.comet.expression.Sha2.enabled` | Enable Comet acceleration for `Sha2` | true |
Review Comment:
Updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Finish refactoring expression serde out of `QueryPlanSerde` [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2536015650
##########
spark/src/test/resources/tpcds-plan-stability/approved-plans-v1_4-spark4_0/q1/explain.txt:
##########
@@ -1,49 +1,45 @@
== Physical Plan ==
-TakeOrderedAndProject (45)
-+- * Project (44)
- +- * BroadcastHashJoin Inner BuildRight (43)
- :- * Project (37)
- : +- * BroadcastHashJoin Inner BuildRight (36)
- : :- * Project (30)
- : : +- * BroadcastHashJoin Inner BuildRight (29)
- : : :- * Filter (13)
- : : : +- * HashAggregate (12)
- : : : +- * CometColumnarToRow (11)
Review Comment:
This PR added support for `MakeDecimal` in ANSI mode, although we still need to add tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Finish refactoring expression serde out of `QueryPlanSerde` [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2539567924
##########
spark/src/main/scala/org/apache/comet/serde/strings.scala:
##########
@@ -21,15 +21,34 @@ package org.apache.comet.serde
import java.util.Locale
-import org.apache.spark.sql.catalyst.expressions.{Attribute, Cast, Concat, Expression, InitCap, Length, Like, Literal, Lower, RegExpReplace, RLike, StringLPad, StringRepeat, StringRPad, Substring, Upper}
-import org.apache.spark.sql.types.{BinaryType, DataTypes, LongType, StringType}
+import org.apache.spark.sql.catalyst.expressions.{Attribute, Cast, Concat, Expression, InitCap, Length, Like, Literal, Lower, RegExpReplace, Reverse, RLike, StringLPad, StringRepeat, StringRPad, Substring, Upper}
+import org.apache.spark.sql.types.{ArrayType, BinaryType, DataTypes, LongType, StringType}
import org.apache.comet.CometConf
import org.apache.comet.CometSparkSessionExtensions.withInfo
import org.apache.comet.expressions.{CometCast, CometEvalMode, RegExp}
import org.apache.comet.serde.ExprOuterClass.Expr
import org.apache.comet.serde.QueryPlanSerde.{createBinaryExpr, exprToProtoInternal, optExprWithInfo, scalarFunctionExprToProto}
+object CometReverse extends CometScalarFunction[Reverse]("reverse") {
Review Comment:
Thanks. Moved to match Spark organization.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Finish refactoring expression serde out of `QueryPlanSerde` [datafusion-comet]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2535716028
##########
spark/src/test/resources/tpcds-plan-stability/approved-plans-v1_4-spark4_0/q1/explain.txt:
##########
@@ -1,49 +1,45 @@
== Physical Plan ==
-TakeOrderedAndProject (45)
-+- * Project (44)
- +- * BroadcastHashJoin Inner BuildRight (43)
- :- * Project (37)
- : +- * BroadcastHashJoin Inner BuildRight (36)
- : :- * Project (30)
- : : +- * BroadcastHashJoin Inner BuildRight (29)
- : : :- * Filter (13)
- : : : +- * HashAggregate (12)
- : : : +- * CometColumnarToRow (11)
Review Comment:
there is no fallback to Spark?
##########
spark/src/test/resources/tpcds-plan-stability/approved-plans-v1_4-spark4_0/q1/explain.txt:
##########
@@ -1,49 +1,45 @@
== Physical Plan ==
-TakeOrderedAndProject (45)
-+- * Project (44)
- +- * BroadcastHashJoin Inner BuildRight (43)
- :- * Project (37)
- : +- * BroadcastHashJoin Inner BuildRight (36)
- : :- * Project (30)
- : : +- * BroadcastHashJoin Inner BuildRight (29)
- : : :- * Filter (13)
- : : : +- * HashAggregate (12)
- : : : +- * CometColumnarToRow (11)
Review Comment:
there is no fallback to Spark anymore?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Finish refactoring expression serde out of `QueryPlanSerde` [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] chore: Refactor more expr serde [datafusion-comet]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2791:
URL: https://github.com/apache/datafusion-comet/pull/2791#discussion_r2532926789
##########
spark/src/main/scala/org/apache/comet/serde/CometMakeDecimal.scala:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.serde
+
+import org.apache.spark.sql.catalyst.expressions.{Attribute, MakeDecimal}
+import org.apache.spark.sql.types.DecimalType
+
+import org.apache.comet.serde.QueryPlanSerde.{exprToProtoInternal, optExprWithInfo, scalarFunctionExprToProtoWithReturnType}
+
+object CometMakeDecimal extends CometExpressionSerde[MakeDecimal] {
+ override def convert(
+ expr: MakeDecimal,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+ val childExpr = exprToProtoInternal(expr.child, inputs, binding)
+ val optExpr = scalarFunctionExprToProtoWithReturnType(
+ "make_decimal",
+ DecimalType(expr.precision, expr.scale),
+ false,
Review Comment:
```suggestion
!expr.nullOnOverflow,
```
##########
docs/source/user-guide/latest/configs.md:
##########
@@ -289,6 +291,7 @@ These settings can be used to determine which parts of the plan are accelerated
| `spark.comet.expression.Remainder.enabled` | Enable Comet acceleration for `Remainder` | true |
| `spark.comet.expression.Reverse.enabled` | Enable Comet acceleration for `Reverse` | true |
| `spark.comet.expression.Round.enabled` | Enable Comet acceleration for `Round` | true |
+| `spark.comet.expression.ScalarSubquery.enabled` | Enable Comet acceleration for `ScalarSubquery` | true |
| `spark.comet.expression.Second.enabled` | Enable Comet acceleration for `Second` | true |
| `spark.comet.expression.Sha1.enabled` | Enable Comet acceleration for `Sha1` | true |
| `spark.comet.expression.Sha2.enabled` | Enable Comet acceleration for `Sha2` | true |
Review Comment:
There is no new entry for UnscaledValue
##########
spark/src/main/scala/org/apache/comet/serde/CometBloomFilterMightContain.scala:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.comet.serde
+
+import org.apache.spark.sql.catalyst.expressions.{Attribute, BloomFilterMightContain}
+
+import org.apache.comet.CometSparkSessionExtensions.withInfo
+import org.apache.comet.serde.QueryPlanSerde.exprToProtoInternal
+
+object CometBloomFilterMightContain extends CometExpressionSerde[BloomFilterMightContain] {
+
+ override def convert(
+ expr: BloomFilterMightContain,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+
+ val bloomFilter = expr.left
+ val value = expr.right
+ val bloomFilterExpr = exprToProtoInternal(bloomFilter, inputs, binding)
+ val valueExpr = exprToProtoInternal(value, inputs, binding)
+ if (bloomFilterExpr.isDefined && valueExpr.isDefined) {
Review Comment:
nit: Pattern matching is a bit more idiomatic:
```suggestion
(bloomFilterExpr, valueExpr) match {
case (Some(bf), Some(v)) =>
```
##########
spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala:
##########
@@ -204,17 +203,16 @@ object QueryPlanSerde extends Logging with CometExprShim {
private val miscExpressions: Map[Class[_ <: Expression], CometExpressionSerde[_]] = Map(
// TODO PromotePrecision
// TODO KnownFloatingPointNormalized
- // TODO ScalarSubquery
// TODO UnscaledValue
Review Comment:
```suggestion
classOf[UnscaledValue] -> CometUnscaledValue
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org