-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] fix: add proto roundtrips for Spark tests and fix issues it surfaces #315
base: main
Are you sure you want to change the base?
Changes from 7 commits
6a18734
c56197e
351c6b6
681a02e
a7effe2
591848a
e374c85
ab104f5
05ce603
13a3b99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,7 +131,7 @@ class ToSubstraitRel extends AbstractLogicalPlanVisitor with Logging { | |
val aggregates = collectAggregates(actualResultExprs, aggExprToOutputOrdinal) | ||
val aggOutputMap = aggregates.zipWithIndex.map { | ||
case (e, i) => | ||
AttributeReference(s"agg_func_$i", e.dataType)() -> e | ||
AttributeReference(s"agg_func_$i", e.dataType, nullable = e.nullable)() -> e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these were causing wrong nullability for the type in the created pojos. I don't think that type field is used anywhere so it didn't cause harm, but still failed roundtrip tests as the type isn't written in proto and then it got correctly evaluated from other fields on read. |
||
} | ||
val aggOutput = aggOutputMap.map(_._1) | ||
|
||
|
@@ -145,7 +145,7 @@ class ToSubstraitRel extends AbstractLogicalPlanVisitor with Logging { | |
} | ||
val groupOutputMap = actualGroupExprs.zipWithIndex.map { | ||
case (e, i) => | ||
AttributeReference(s"group_col_$i", e.dataType)() -> e | ||
AttributeReference(s"group_col_$i", e.dataType, nullable = e.nullable)() -> e | ||
} | ||
val groupOutput = groupOutputMap.map(_._1) | ||
|
||
|
@@ -185,13 +185,10 @@ class ToSubstraitRel extends AbstractLogicalPlanVisitor with Logging { | |
} | ||
|
||
override def visitWindow(window: Window): relation.Rel = { | ||
val windowExpressions = window.windowExpressions.map { | ||
case w: WindowExpression => fromWindowCall(w, window.child.output) | ||
case a: Alias if a.child.isInstanceOf[WindowExpression] => | ||
fromWindowCall(a.child.asInstanceOf[WindowExpression], window.child.output) | ||
case other => | ||
throw new UnsupportedOperationException(s"Unsupported window expression: $other") | ||
}.asJava | ||
val windowExpressions = window.windowExpressions | ||
.flatMap(expr => expr.collect { case w: WindowExpression => w }) | ||
.map(fromWindowCall(_, window.child.output)) | ||
.asJava | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the previous code would fail if there was a column like Alias(Alias(WindowExpression(..))), this catches those. It doesn't explicitly fail if there's some other wrappers for WindowExpressions than Alias, but I hope that's not the case in valid Spark plans |
||
|
||
val partitionExpressions = window.partitionSpec.map(toExpression(window.child.output)).asJava | ||
val sorts = window.orderSpec.map(toSortField(window.child.output)).asJava | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not 100% sure about this, is it actually meant to return a struct type? given it's scalar that seems a bit weird