Skip to content
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

Have average support nulls for 3.2.0 #3503

Merged
merged 1 commit into from
Sep 16, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, SessionCatalog}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.errors.attachTree
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.Average
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.catalyst.trees.TreeNode
Expand All @@ -54,7 +55,7 @@ import org.apache.spark.sql.execution.joins.{BroadcastHashJoinExec, BroadcastNes
import org.apache.spark.sql.execution.python.{AggregateInPandasExec, ArrowEvalPythonExec, FlatMapGroupsInPandasExec, MapInPandasExec, WindowInPandasExec}
import org.apache.spark.sql.execution.window.WindowExecBase
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.rapids.{GpuFileSourceScanExec, GpuStringReplace, GpuTimeSub}
import org.apache.spark.sql.rapids.{GpuAverage, GpuFileSourceScanExec, GpuStringReplace, GpuTimeSub}
import org.apache.spark.sql.rapids.execution.{GpuBroadcastExchangeExecBase, GpuBroadcastNestedLoopJoinExecBase, GpuShuffleExchangeExecBase, JoinTypeChecks, SerializeBatchDeserializeHostBuffer, SerializeConcatHostBuffersDeserializeBatch}
import org.apache.spark.sql.rapids.execution.python.GpuPythonUDF
import org.apache.spark.sql.rapids.execution.python.shims.spark301._
Expand Down Expand Up @@ -288,6 +289,19 @@ abstract class SparkBaseShims extends Spark30XShims {
"Convert a column of one type of data into another type",
new CastChecks(),
(cast, conf, p, r) => new CastExprMeta[AnsiCast](cast, true, conf, p, r)),
GpuOverrides.expr[Average](
"Average aggregate operator",
ExprChecks.fullAgg(
TypeSig.DOUBLE, TypeSig.DOUBLE + TypeSig.DECIMAL_128_FULL,
Seq(ParamCheck("input", TypeSig.integral + TypeSig.fp, TypeSig.numeric))),
(a, conf, p, r) => new AggExprMeta[Average](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
val dataType = a.child.dataType
GpuOverrides.checkAndTagFloatAgg(dataType, conf, this)
}

override def convertToGpu(child: Expression): GpuExpression = GpuAverage(child)
}),
GpuOverrides.expr[RegExpReplace](
"RegExpReplace support for string literal input patterns",
ExprChecks.projectOnly(TypeSig.STRING, TypeSig.STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, SessionCatalog}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.errors.attachTree
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.Average
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.catalyst.trees.TreeNode
Expand All @@ -56,7 +57,7 @@ import org.apache.spark.sql.execution.joins._
import org.apache.spark.sql.execution.python._
import org.apache.spark.sql.execution.window.WindowExecBase
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.rapids.{GpuFileSourceScanExec, GpuStringReplace, GpuTimeSub}
import org.apache.spark.sql.rapids.{GpuAverage, GpuFileSourceScanExec, GpuStringReplace, GpuTimeSub}
import org.apache.spark.sql.rapids.execution.{GpuBroadcastExchangeExecBase, GpuBroadcastNestedLoopJoinExecBase, GpuShuffleExchangeExecBase, JoinTypeChecks, SerializeBatchDeserializeHostBuffer, SerializeConcatHostBuffersDeserializeBatch, TrampolineUtil}
import org.apache.spark.sql.rapids.execution.python.{GpuFlatMapGroupsInPandasExecMeta, GpuPythonUDF}
import org.apache.spark.sql.rapids.execution.python.shims.spark301db._
Expand Down Expand Up @@ -311,6 +312,19 @@ abstract class SparkBaseShims extends Spark30XShims {
"Convert a column of one type of data into another type",
new CastChecks(),
(cast, conf, p, r) => new CastExprMeta[AnsiCast](cast, true, conf, p, r)),
GpuOverrides.expr[Average](
"Average aggregate operator",
ExprChecks.fullAgg(
TypeSig.DOUBLE, TypeSig.DOUBLE + TypeSig.DECIMAL_128_FULL,
Seq(ParamCheck("input", TypeSig.integral + TypeSig.fp, TypeSig.numeric))),
(a, conf, p, r) => new AggExprMeta[Average](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
val dataType = a.child.dataType
GpuOverrides.checkAndTagFloatAgg(dataType, conf, this)
}

override def convertToGpu(child: Expression): GpuExpression = GpuAverage(child)
}),
GpuOverrides.expr[RegExpReplace](
"RegExpReplace support for string literal input patterns",
ExprChecks.projectOnly(TypeSig.STRING, TypeSig.STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, SessionCatalog}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.errors.attachTree
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.Average
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.catalyst.trees.TreeNode
Expand All @@ -54,7 +55,7 @@ import org.apache.spark.sql.execution.joins.{BroadcastHashJoinExec, BroadcastNes
import org.apache.spark.sql.execution.python.{AggregateInPandasExec, ArrowEvalPythonExec, FlatMapGroupsInPandasExec, MapInPandasExec, WindowInPandasExec}
import org.apache.spark.sql.execution.window.WindowExecBase
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.rapids.{GpuFileSourceScanExec, GpuStringReplace, GpuTimeSub}
import org.apache.spark.sql.rapids.{GpuAverage, GpuFileSourceScanExec, GpuStringReplace, GpuTimeSub}
import org.apache.spark.sql.rapids.execution.{GpuBroadcastExchangeExecBase, GpuBroadcastNestedLoopJoinExecBase, GpuShuffleExchangeExecBase, JoinTypeChecks, SerializeBatchDeserializeHostBuffer, SerializeConcatHostBuffersDeserializeBatch}
import org.apache.spark.sql.rapids.execution.python.GpuPythonUDF
import org.apache.spark.sql.rapids.execution.python.shims.spark302._
Expand Down Expand Up @@ -288,6 +289,19 @@ abstract class SparkBaseShims extends Spark30XShims {
"Convert a column of one type of data into another type",
new CastChecks(),
(cast, conf, p, r) => new CastExprMeta[AnsiCast](cast, true, conf, p, r)),
GpuOverrides.expr[Average](
"Average aggregate operator",
ExprChecks.fullAgg(
TypeSig.DOUBLE, TypeSig.DOUBLE + TypeSig.DECIMAL_128_FULL,
Seq(ParamCheck("input", TypeSig.integral + TypeSig.fp, TypeSig.numeric))),
(a, conf, p, r) => new AggExprMeta[Average](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
val dataType = a.child.dataType
GpuOverrides.checkAndTagFloatAgg(dataType, conf, this)
}

override def convertToGpu(child: Expression): GpuExpression = GpuAverage(child)
}),
GpuOverrides.expr[RegExpReplace](
"RegExpReplace support for string literal input patterns",
ExprChecks.projectOnly(TypeSig.STRING, TypeSig.STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, SessionCatalog}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.errors.attachTree
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.Average
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.catalyst.trees.TreeNode
Expand All @@ -54,7 +55,7 @@ import org.apache.spark.sql.execution.joins.{BroadcastHashJoinExec, BroadcastNes
import org.apache.spark.sql.execution.python.{AggregateInPandasExec, ArrowEvalPythonExec, FlatMapGroupsInPandasExec, MapInPandasExec, WindowInPandasExec}
import org.apache.spark.sql.execution.window.WindowExecBase
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.rapids.{GpuFileSourceScanExec, GpuStringReplace, GpuTimeSub}
import org.apache.spark.sql.rapids.{GpuAverage, GpuFileSourceScanExec, GpuStringReplace, GpuTimeSub}
import org.apache.spark.sql.rapids.execution.{GpuBroadcastExchangeExecBase, GpuBroadcastNestedLoopJoinExecBase, GpuShuffleExchangeExecBase, JoinTypeChecks, SerializeBatchDeserializeHostBuffer, SerializeConcatHostBuffersDeserializeBatch}
import org.apache.spark.sql.rapids.execution.python.GpuPythonUDF
import org.apache.spark.sql.rapids.execution.python.shims.spark303._
Expand Down Expand Up @@ -288,6 +289,19 @@ abstract class SparkBaseShims extends Spark30XShims {
"Convert a column of one type of data into another type",
new CastChecks(),
(cast, conf, p, r) => new CastExprMeta[AnsiCast](cast, true, conf, p, r)),
GpuOverrides.expr[Average](
"Average aggregate operator",
ExprChecks.fullAgg(
TypeSig.DOUBLE, TypeSig.DOUBLE + TypeSig.DECIMAL_128_FULL,
Seq(ParamCheck("input", TypeSig.integral + TypeSig.fp, TypeSig.numeric))),
(a, conf, p, r) => new AggExprMeta[Average](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
val dataType = a.child.dataType
GpuOverrides.checkAndTagFloatAgg(dataType, conf, this)
}

override def convertToGpu(child: Expression): GpuExpression = GpuAverage(child)
}),
GpuOverrides.expr[RegExpReplace](
"RegExpReplace support for string literal input patterns",
ExprChecks.projectOnly(TypeSig.STRING, TypeSig.STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, SessionCatalog}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.errors.attachTree
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.Average
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.catalyst.trees.TreeNode
Expand All @@ -53,7 +54,7 @@ import org.apache.spark.sql.execution.joins.{BroadcastHashJoinExec, BroadcastNes
import org.apache.spark.sql.execution.python.{AggregateInPandasExec, ArrowEvalPythonExec, FlatMapGroupsInPandasExec, MapInPandasExec, WindowInPandasExec}
import org.apache.spark.sql.execution.window.WindowExecBase
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.rapids.{GpuFileSourceScanExec, GpuStringReplace, GpuTimeSub}
import org.apache.spark.sql.rapids.{GpuAverage, GpuFileSourceScanExec, GpuStringReplace, GpuTimeSub}
import org.apache.spark.sql.rapids.execution.{GpuBroadcastExchangeExecBase, GpuBroadcastNestedLoopJoinExecBase, GpuShuffleExchangeExecBase, JoinTypeChecks, SerializeBatchDeserializeHostBuffer, SerializeConcatHostBuffersDeserializeBatch}
import org.apache.spark.sql.rapids.execution.python.GpuPythonUDF
import org.apache.spark.sql.rapids.execution.python.shims.spark304._
Expand Down Expand Up @@ -288,6 +289,19 @@ abstract class SparkBaseShims extends Spark30XShims {
"Convert a column of one type of data into another type",
new CastChecks(),
(cast, conf, p, r) => new CastExprMeta[AnsiCast](cast, true, conf, p, r)),
GpuOverrides.expr[Average](
"Average aggregate operator",
ExprChecks.fullAgg(
TypeSig.DOUBLE, TypeSig.DOUBLE + TypeSig.DECIMAL_128_FULL,
Seq(ParamCheck("input", TypeSig.integral + TypeSig.fp, TypeSig.numeric))),
(a, conf, p, r) => new AggExprMeta[Average](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
val dataType = a.child.dataType
GpuOverrides.checkAndTagFloatAgg(dataType, conf, this)
}

override def convertToGpu(child: Expression): GpuExpression = GpuAverage(child)
}),
GpuOverrides.expr[RegExpReplace](
"RegExpReplace support for string literal input patterns",
ExprChecks.projectOnly(TypeSig.STRING, TypeSig.STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, SessionCatalog}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.errors.attachTree
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.Average
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.catalyst.trees.TreeNode
Expand Down Expand Up @@ -221,6 +222,19 @@ abstract class SparkBaseShims extends Spark30XShims {
super.tagExprForGpu()
}
}),
GpuOverrides.expr[Average](
"Average aggregate operator",
ExprChecks.fullAgg(
TypeSig.DOUBLE, TypeSig.DOUBLE + TypeSig.DECIMAL_128_FULL,
Seq(ParamCheck("input", TypeSig.integral + TypeSig.fp, TypeSig.numeric))),
(a, conf, p, r) => new AggExprMeta[Average](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
val dataType = a.child.dataType
GpuOverrides.checkAndTagFloatAgg(dataType, conf, this)
}

override def convertToGpu(child: Expression): GpuExpression = GpuAverage(child)
}),
GpuOverrides.expr[RegExpReplace](
"RegExpReplace support for string literal input patterns",
ExprChecks.projectOnly(TypeSig.STRING, TypeSig.STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, SessionCatalog}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.errors.attachTree
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.Average
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.catalyst.trees.TreeNode
Expand Down Expand Up @@ -235,6 +236,19 @@ abstract class SparkBaseShims extends Spark30XShims {
super.tagExprForGpu()
}
}),
GpuOverrides.expr[Average](
"Average aggregate operator",
ExprChecks.fullAgg(
TypeSig.DOUBLE, TypeSig.DOUBLE + TypeSig.DECIMAL_128_FULL,
Seq(ParamCheck("input", TypeSig.integral + TypeSig.fp, TypeSig.numeric))),
(a, conf, p, r) => new AggExprMeta[Average](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
val dataType = a.child.dataType
GpuOverrides.checkAndTagFloatAgg(dataType, conf, this)
}

override def convertToGpu(child: Expression): GpuExpression = GpuAverage(child)
}),
GpuOverrides.expr[RegExpReplace](
"RegExpReplace support for string literal input patterns",
ExprChecks.projectOnly(TypeSig.STRING, TypeSig.STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, SessionCatalog}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.errors.attachTree
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.Average
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.catalyst.trees.TreeNode
Expand Down Expand Up @@ -207,6 +208,19 @@ abstract class SparkBaseShims extends Spark30XShims {
super.tagExprForGpu()
}
}),
GpuOverrides.expr[Average](
"Average aggregate operator",
ExprChecks.fullAgg(
TypeSig.DOUBLE, TypeSig.DOUBLE + TypeSig.DECIMAL_128_FULL,
Seq(ParamCheck("input", TypeSig.integral + TypeSig.fp, TypeSig.numeric))),
(a, conf, p, r) => new AggExprMeta[Average](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
val dataType = a.child.dataType
GpuOverrides.checkAndTagFloatAgg(dataType, conf, this)
}

override def convertToGpu(child: Expression): GpuExpression = GpuAverage(child)
}),
GpuOverrides.expr[RegExpReplace](
"RegExpReplace support for string literal input patterns",
ExprChecks.projectOnly(TypeSig.STRING, TypeSig.STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, SessionCatalog}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.errors.attachTree
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.Average
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.catalyst.trees.TreeNode
Expand Down Expand Up @@ -221,6 +222,19 @@ abstract class SparkBaseShims extends Spark30XShims {
super.tagExprForGpu()
}
}),
GpuOverrides.expr[Average](
"Average aggregate operator",
ExprChecks.fullAgg(
TypeSig.DOUBLE, TypeSig.DOUBLE + TypeSig.DECIMAL_128_FULL,
Seq(ParamCheck("input", TypeSig.integral + TypeSig.fp, TypeSig.numeric))),
(a, conf, p, r) => new AggExprMeta[Average](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
val dataType = a.child.dataType
GpuOverrides.checkAndTagFloatAgg(dataType, conf, this)
}

override def convertToGpu(child: Expression): GpuExpression = GpuAverage(child)
}),
GpuOverrides.expr[RegExpReplace](
"RegExpReplace support for string literal input patterns",
ExprChecks.projectOnly(TypeSig.STRING, TypeSig.STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, SessionCatalog}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import org.apache.spark.sql.catalyst.errors.attachTree
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate.Average
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.catalyst.trees.TreeNode
Expand Down Expand Up @@ -221,6 +222,19 @@ abstract class SparkBaseShims extends Spark30XShims {
super.tagExprForGpu()
}
}),
GpuOverrides.expr[Average](
"Average aggregate operator",
ExprChecks.fullAgg(
TypeSig.DOUBLE, TypeSig.DOUBLE + TypeSig.DECIMAL_128_FULL,
Seq(ParamCheck("input", TypeSig.integral + TypeSig.fp, TypeSig.numeric))),
(a, conf, p, r) => new AggExprMeta[Average](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
val dataType = a.child.dataType
GpuOverrides.checkAndTagFloatAgg(dataType, conf, this)
}

override def convertToGpu(child: Expression): GpuExpression = GpuAverage(child)
}),
GpuOverrides.expr[RegExpReplace](
"RegExpReplace support for string literal input patterns",
ExprChecks.projectOnly(TypeSig.STRING, TypeSig.STRING,
Expand Down
Loading