huaxingao commented on code in PR #733:
URL: https://github.com/apache/datafusion-comet/pull/733#discussion_r1771810211
##########
native/core/src/execution/datafusion/planner.rs:
##########
@@ -1692,16 +1692,33 @@ impl PhysicalPlanner {
.and_then(|inner| inner.lower_frame_bound_struct.as_ref())
{
Some(l) => match l {
- LowerFrameBoundStruct::UnboundedPreceding(_) => {
- WindowFrameBound::Preceding(ScalarValue::UInt64(None))
- }
+ LowerFrameBoundStruct::UnboundedPreceding(_) => match units {
+ WindowFrameUnits::Rows => {
+ WindowFrameBound::Preceding(ScalarValue::UInt64(None))
+ }
+ WindowFrameUnits::Range | WindowFrameUnits::Groups => {
Review Comment:
We don't use `Groups`, but if we don't specify this case,
`UpperFrameBoundStruct::UnboundedFollowing(_) => match units` fails with
`pattern datafusion_expr::WindowFrameUnits::Groups not covered`.
##########
spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala:
##########
@@ -3277,4 +3295,41 @@ object QueryPlanSerde extends Logging with
ShimQueryPlanSerde with CometExprShim
true
}
}
+
+ private def validatePartitionAndSortSpecsForWindowFunc(
+ partitionSpec: Seq[Expression],
+ orderSpec: Seq[SortOrder],
+ op: SparkPlan): Boolean = {
+ if (partitionSpec.length != orderSpec.length) {
+ withInfo(op, "Partitioning and sorting specifications do not match")
+ return false
+ } else {
+ val partitionColumnNames = partitionSpec.collect { case a:
AttributeReference =>
+ a.name
+ }
+
+ if (partitionColumnNames.length != partitionSpec.length) {
+ withInfo(op, "Unsupported partitioning specification")
+ return false
+ }
+
+ val orderColumnNames = orderSpec.collect { case s: SortOrder =>
+ s.child match {
+ case a: AttributeReference => a.name
+ }
+ }
+
+ if (orderColumnNames.length != orderSpec.length) {
+ withInfo(op, "Unsupported SortOrder")
+ return false
+ }
+
+ if (partitionColumnNames.toSet != orderColumnNames.toSet) {
+ withInfo(op, "Partitioning and sorting specifications do not match")
+ return false
+ }
Review Comment:
Fixed. Thanks!
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]