Skip to content

chore: Remove obsolete supportedSortType function after Arrow updates #1946

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2335,10 +2335,6 @@ object QueryPlanSerde extends Logging with CometExprShim {
}

case SortExec(sortOrder, _, child, _) if CometConf.COMET_EXEC_SORT_ENABLED.get(conf) =>
if (!supportedSortType(op, sortOrder)) {
return None
}

val sortOrders = sortOrder.map(exprToProto(_, child.output))

if (sortOrders.forall(_.isDefined) && childOp.nonEmpty) {
Expand Down Expand Up @@ -2939,41 +2935,6 @@ object QueryPlanSerde extends Logging with CometExprShim {

}

// TODO: Remove this constraint when we upgrade to new arrow-rs including
// https://github.com/apache/arrow-rs/pull/6225
def supportedSortType(op: SparkPlan, sortOrder: Seq[SortOrder]): Boolean = {
def canRank(dt: DataType): Boolean = {
dt match {
case _: ByteType | _: ShortType | _: IntegerType | _: LongType | _: FloatType |
_: DoubleType | _: TimestampType | _: DecimalType | _: DateType =>
true
case _: BinaryType | _: StringType => true
case _ => false
}
}

if (sortOrder.length == 1) {
val canSort = sortOrder.head.dataType match {
case _: BooleanType => true
case _: ByteType | _: ShortType | _: IntegerType | _: LongType | _: FloatType |
_: DoubleType | _: TimestampType | _: TimestampNTZType | _: DecimalType |
_: DateType =>
true
case _: BinaryType | _: StringType => true
case ArrayType(elementType, _) => canRank(elementType)
case _ => false
}
if (!canSort) {
withInfo(op, s"Sort on single column of type ${sortOrder.head.dataType} is not supported")
false
} else {
true
}
} else {
true
}
}

private def validatePartitionAndSortSpecsForWindowFunc(
partitionSpec: Seq[Expression],
orderSpec: Seq[SortOrder],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import org.apache.spark.sql.execution.metric.{SQLMetric, SQLMetrics, SQLShuffleR
import org.apache.spark.sql.vectorized.ColumnarBatch

import org.apache.comet.serde.QueryPlanSerde.exprToProto
import org.apache.comet.serde.QueryPlanSerde.supportedSortType

/**
* Comet physical plan node for Spark `TakeOrderedAndProjectExec`.
Expand Down Expand Up @@ -134,7 +133,6 @@ object CometTakeOrderedAndProjectExec {
def isSupported(plan: TakeOrderedAndProjectExec): Boolean = {
val exprs = plan.projectList.map(exprToProto(_, plan.child.output))
val sortOrders = plan.sortOrder.map(exprToProto(_, plan.child.output))
exprs.forall(_.isDefined) && sortOrders.forall(_.isDefined) && plan.offset == 0 &&
supportedSortType(plan, plan.sortOrder)
exprs.forall(_.isDefined) && sortOrders.forall(_.isDefined) && plan.offset == 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class CometExecSuite extends CometTestBase {
}
}

test("Sort on single struct should fallback to Spark") {
test("Sort on single struct should work in Comet") {
withSQLConf(
SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true",
SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> "false",
Expand All @@ -180,7 +180,7 @@ class CometExecSuite extends CometTestBase {
withParquetFile(data1) { file =>
readParquetFile(file) { df =>
val sort = df.sort("_1")
checkSparkAnswer(sort)
checkSparkAnswerAndOperator(sort)
}
}

Expand All @@ -195,7 +195,7 @@ class CometExecSuite extends CometTestBase {
withParquetFile(data2) { file =>
readParquetFile(file) { df =>
val sort = df.sort("_1")
checkSparkAnswer(sort)
checkSparkAnswerAndOperator(sort)
}
}
}
Expand Down
Loading