You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by "PHILO-HE (via GitHub)" <gi...@apache.org> on 2024/07/10 07:40:23 UTC
[PR] [UT] Add a test to validate any unary expression with its accepted types [incubator-gluten]
PHILO-HE opened a new pull request, #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392
## What changes were proposed in this pull request?
(Please fill in changes proposed in this fix)
(Fixes: \#ISSUE-ID)
## How was this patch tested?
(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
(If this patch involves UI changes, please attach a screenshot; otherwise, remove this)
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#issuecomment-2222448213
@zhztheplayer, do you have any other comment? 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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#issuecomment-2221894248
When doing expression converter, it can go into CH's expression validation path in scala code. So maybe we can keep it run for CH. cc @zzcclp
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "zhztheplayer (via GitHub)" <gi...@apache.org>.
zhztheplayer commented on PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#issuecomment-2221822521
Does the change apply to CH backend as well?
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "zhztheplayer (via GitHub)" <gi...@apache.org>.
zhztheplayer merged PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "zzcclp (via GitHub)" <gi...@apache.org>.
zzcclp commented on code in PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#discussion_r1674982388
##########
gluten-ut/test/src/test/scala/org/apache/spark/sql/GlutenExpressionDataTypesValidation.scala:
##########
@@ -0,0 +1,158 @@
+/*
+ * 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.spark.sql
+
+import org.apache.gluten.GlutenConfig
+import org.apache.gluten.execution.{ProjectExecTransformer, WholeStageTransformerSuite}
+import org.apache.gluten.extension.GlutenPlan
+import org.apache.gluten.utils.{BackendTestUtils, SystemParameters}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.rdd.RDD
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions._
+import org.apache.spark.sql.execution.LeafExecNode
+import org.apache.spark.sql.execution.metric.SQLMetric
+import org.apache.spark.sql.types._
+
+class GlutenExpressionDataTypesValidation extends WholeStageTransformerSuite {
+ protected val resourcePath: String = null
+ protected val fileFormat: String = null
+ override protected val logLevel: String = "INFO"
+
+ override protected def sparkConf: SparkConf = {
+ val conf = super.sparkConf
+ .set("spark.plugins", "org.apache.gluten.GlutenPlugin")
+ .set("spark.default.parallelism", "1")
+ .set("spark.memory.offHeap.enabled", "true")
+ .set("spark.memory.offHeap.size", "1024MB")
+ .set("spark.ui.enabled", "false")
+ .set("spark.gluten.ui.enabled", "false")
+ if (BackendTestUtils.isCHBackendLoaded()) {
+ conf
+ .set("spark.gluten.sql.enable.native.validation", "false")
+ .set(GlutenConfig.GLUTEN_LIB_PATH, SystemParameters.getClickHouseLibPath)
+ }
+ conf
+ }
+
+ private case class DummyPlan() extends LeafExecNode {
+ override def output: Seq[Attribute] = Seq()
+
+ override val metrics: Map[String, SQLMetric] = Map.empty
+
+ override def doExecute(): RDD[InternalRow] = throw new UnsupportedOperationException(
+ "Just a dummy plan.")
+ }
+
+ private val allPrimitiveDataTypes: Seq[DataType] =
+ Seq(
+ ByteType,
+ ShortType,
+ IntegerType,
+ LongType,
+ FloatType,
+ DoubleType,
+ DecimalType(5, 1),
+ StringType,
+ BinaryType,
+ DateType,
+ TimestampType)
+
+ private val allComplexDataTypes: Seq[DataType] = Seq(
+ // Currently, only check certain inner types, assuming they are representative
+ // for checking most expressions.
+ ArrayType(IntegerType),
+ MapType(StringType, IntegerType),
+ StructType(Seq(StructField("a", StringType), StructField("b", IntegerType)))
+ )
+
+ def generateChildExpression(t: DataType): Expression = {
+ t match {
+ case _: IntegralType => Literal(null, t)
+ case _: FractionalType => Literal(null, t)
+ case StringType | BinaryType => Literal("123")
+ case DateType => Literal(null, t)
+ case TimestampType => Literal(null, t)
+ case ArrayType(_, _) => Literal(null, t)
+ case MapType(_, _, _) => Literal(null, t)
+ case StructType(_) => Literal(null, t)
+ case _ => throw new UnsupportedOperationException("Not supported type: " + t)
+ }
+ }
+ def generateGlutenProjectPlan(expr: Expression): GlutenPlan = {
+ val namedExpr = Seq(Alias(expr, "r")())
+ ProjectExecTransformer(namedExpr, DummyPlan())
+ }
+
+ test("cast") {
+ for (from <- allPrimitiveDataTypes ++ allComplexDataTypes) {
+ for (to <- allPrimitiveDataTypes ++ allComplexDataTypes) {
+ if (to != from) {
+ val castExpr = Cast(generateChildExpression(from), to)
+ if (castExpr.checkInputDataTypes().isSuccess) {
+ val glutenProject = generateGlutenProjectPlan(castExpr)
+ if (glutenProject.doValidate().isValid) {
Review Comment:
It seems the api of the `ValidationResult` had already changed?
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on code in PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#discussion_r1674987707
##########
gluten-ut/test/src/test/scala/org/apache/spark/sql/GlutenExpressionDataTypesValidation.scala:
##########
@@ -0,0 +1,158 @@
+/*
+ * 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.spark.sql
+
+import org.apache.gluten.GlutenConfig
+import org.apache.gluten.execution.{ProjectExecTransformer, WholeStageTransformerSuite}
+import org.apache.gluten.extension.GlutenPlan
+import org.apache.gluten.utils.{BackendTestUtils, SystemParameters}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.rdd.RDD
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions._
+import org.apache.spark.sql.execution.LeafExecNode
+import org.apache.spark.sql.execution.metric.SQLMetric
+import org.apache.spark.sql.types._
+
+class GlutenExpressionDataTypesValidation extends WholeStageTransformerSuite {
+ protected val resourcePath: String = null
+ protected val fileFormat: String = null
+ override protected val logLevel: String = "INFO"
+
+ override protected def sparkConf: SparkConf = {
+ val conf = super.sparkConf
+ .set("spark.plugins", "org.apache.gluten.GlutenPlugin")
+ .set("spark.default.parallelism", "1")
+ .set("spark.memory.offHeap.enabled", "true")
+ .set("spark.memory.offHeap.size", "1024MB")
+ .set("spark.ui.enabled", "false")
+ .set("spark.gluten.ui.enabled", "false")
+ if (BackendTestUtils.isCHBackendLoaded()) {
+ conf
+ .set("spark.gluten.sql.enable.native.validation", "false")
+ .set(GlutenConfig.GLUTEN_LIB_PATH, SystemParameters.getClickHouseLibPath)
+ }
+ conf
+ }
+
+ private case class DummyPlan() extends LeafExecNode {
+ override def output: Seq[Attribute] = Seq()
+
+ override val metrics: Map[String, SQLMetric] = Map.empty
+
+ override def doExecute(): RDD[InternalRow] = throw new UnsupportedOperationException(
+ "Just a dummy plan.")
+ }
+
+ private val allPrimitiveDataTypes: Seq[DataType] =
+ Seq(
+ ByteType,
+ ShortType,
+ IntegerType,
+ LongType,
+ FloatType,
+ DoubleType,
+ DecimalType(5, 1),
+ StringType,
+ BinaryType,
+ DateType,
+ TimestampType)
+
+ private val allComplexDataTypes: Seq[DataType] = Seq(
+ // Currently, only check certain inner types, assuming they are representative
+ // for checking most expressions.
+ ArrayType(IntegerType),
+ MapType(StringType, IntegerType),
+ StructType(Seq(StructField("a", StringType), StructField("b", IntegerType)))
+ )
+
+ def generateChildExpression(t: DataType): Expression = {
+ t match {
+ case _: IntegralType => Literal(null, t)
+ case _: FractionalType => Literal(null, t)
+ case StringType | BinaryType => Literal("123")
+ case DateType => Literal(null, t)
+ case TimestampType => Literal(null, t)
+ case ArrayType(_, _) => Literal(null, t)
+ case MapType(_, _, _) => Literal(null, t)
+ case StructType(_) => Literal(null, t)
+ case _ => throw new UnsupportedOperationException("Not supported type: " + t)
+ }
+ }
+ def generateGlutenProjectPlan(expr: Expression): GlutenPlan = {
+ val namedExpr = Seq(Alias(expr, "r")())
+ ProjectExecTransformer(namedExpr, DummyPlan())
+ }
+
+ test("cast") {
+ for (from <- allPrimitiveDataTypes ++ allComplexDataTypes) {
+ for (to <- allPrimitiveDataTypes ++ allComplexDataTypes) {
+ if (to != from) {
+ val castExpr = Cast(generateChildExpression(from), to)
+ if (castExpr.checkInputDataTypes().isSuccess) {
+ val glutenProject = generateGlutenProjectPlan(castExpr)
+ if (glutenProject.doValidate().isValid) {
Review Comment:
@zzcclp, yes, I will fix it soon. 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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "zhztheplayer (via GitHub)" <gi...@apache.org>.
zhztheplayer commented on code in PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#discussion_r1673309224
##########
gluten-ut/test/src/test/scala/org/apache/spark/sql/GlutenExpressionDataTypesValidation.scala:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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.spark.sql
+
+import org.apache.gluten.GlutenConfig
+import org.apache.gluten.execution.{ProjectExecTransformer, WholeStageTransformerSuite}
+import org.apache.gluten.extension.GlutenPlan
+import org.apache.gluten.utils.{BackendTestUtils, SystemParameters}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.rdd.RDD
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions._
+import org.apache.spark.sql.execution.LeafExecNode
+import org.apache.spark.sql.execution.metric.SQLMetric
+import org.apache.spark.sql.types._
+
+class GlutenExpressionDataTypesValidation extends WholeStageTransformerSuite {
+ protected val resourcePath: String = null
+ protected val fileFormat: String = null
+ override protected val logLevel: String = "INFO"
+
+ override protected def sparkConf: SparkConf = {
+ val conf = super.sparkConf
+ .set("spark.plugins", "org.apache.gluten.GlutenPlugin")
+ .set("spark.default.parallelism", "1")
+ .set("spark.memory.offHeap.enabled", "true")
+ .set("spark.memory.offHeap.size", "1024MB")
+ .set("spark.ui.enabled", "false")
+ .set("spark.gluten.ui.enabled", "false")
+ if (BackendTestUtils.isCHBackendLoaded()) {
+ conf
+ .set("spark.gluten.sql.enable.native.validation", "false")
+ .set(GlutenConfig.GLUTEN_LIB_PATH, SystemParameters.getClickHouseLibPath)
+ }
+ conf
+ }
+
+ private case class DummyPlan() extends LeafExecNode {
+ override def output: Seq[Attribute] = Seq()
+
+ override val metrics: Map[String, SQLMetric] = Map.empty
+
+ override def doExecute(): RDD[InternalRow] = throw new UnsupportedOperationException(
+ "Just a dummy plan.")
+ }
+
+ private val allPrimitiveDataTypes: Seq[DataType] =
+ Seq(
+ ByteType,
+ ShortType,
+ IntegerType,
+ LongType,
+ FloatType,
+ DoubleType,
+ DecimalType(5, 1),
+ StringType,
+ BinaryType,
+ DateType,
+ TimestampType)
+
+ private val allComplexDataTypes: Seq[DataType] = Seq(
+ // Currently, only check certain inner types, assuming they are representative
+ // for checking most expressions.
+ ArrayType(IntegerType),
+ MapType(StringType, IntegerType),
+ StructType(Seq(StructField("a", StringType), StructField("b", IntegerType)))
+ )
+
+ def generateChildExpression(t: DataType): Expression = {
+ t match {
+ case _: IntegralType => Literal(null, t)
+ case _: FractionalType => Literal(null, t)
+ case StringType | BinaryType => Literal("123")
+ case DateType => Literal(null, t)
+ case TimestampType => Literal(null, t)
+ case ArrayType(_, _) => Literal(null, t)
+ case MapType(_, _, _) => Literal(null, t)
+ case StructType(_) => Literal(null, t)
+ case _ => throw new UnsupportedOperationException("Not supported type: " + t)
+ }
+ }
+ def generateGlutenProjectPlan(expr: Expression): GlutenPlan = {
+ val namedExpr = Seq(Alias(expr, "r")())
+ ProjectExecTransformer(namedExpr, DummyPlan())
+ }
+
+ test("cast") {
+ for (from <- allPrimitiveDataTypes ++ allComplexDataTypes) {
+ for (to <- allPrimitiveDataTypes ++ allComplexDataTypes) {
+ if (to != from) {
+ val castExpr = Cast(generateChildExpression(from), to)
+ if (castExpr.checkInputDataTypes().isSuccess) {
+ val glutenProject = generateGlutenProjectPlan(castExpr)
+ if (glutenProject.doValidate().isValid) {
+ logInfo("## cast validation passes: cast from " + from + " to " + to)
+ } else {
+ // scalastyle:off
+ logInfo("!! cast validation fails: cast from " + from + " to " + to)
Review Comment:
Should every `// scalastyle:off` requires for a corresponding `// scalastyle:on`? I am not sure about it but didn't see independent usages of `// scalastyle:off` before.
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a test to validate any unary expression with its accepted types [incubator-gluten]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#issuecomment-2219785062
Run Gluten Clickhouse CI
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on code in PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#discussion_r1673315772
##########
gluten-ut/test/src/test/scala/org/apache/spark/sql/GlutenExpressionDataTypesValidation.scala:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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.spark.sql
+
+import org.apache.gluten.GlutenConfig
+import org.apache.gluten.execution.{ProjectExecTransformer, WholeStageTransformerSuite}
+import org.apache.gluten.extension.GlutenPlan
+import org.apache.gluten.utils.{BackendTestUtils, SystemParameters}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.rdd.RDD
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions._
+import org.apache.spark.sql.execution.LeafExecNode
+import org.apache.spark.sql.execution.metric.SQLMetric
+import org.apache.spark.sql.types._
+
+class GlutenExpressionDataTypesValidation extends WholeStageTransformerSuite {
+ protected val resourcePath: String = null
+ protected val fileFormat: String = null
+ override protected val logLevel: String = "INFO"
+
+ override protected def sparkConf: SparkConf = {
+ val conf = super.sparkConf
+ .set("spark.plugins", "org.apache.gluten.GlutenPlugin")
+ .set("spark.default.parallelism", "1")
+ .set("spark.memory.offHeap.enabled", "true")
+ .set("spark.memory.offHeap.size", "1024MB")
+ .set("spark.ui.enabled", "false")
+ .set("spark.gluten.ui.enabled", "false")
+ if (BackendTestUtils.isCHBackendLoaded()) {
+ conf
+ .set("spark.gluten.sql.enable.native.validation", "false")
+ .set(GlutenConfig.GLUTEN_LIB_PATH, SystemParameters.getClickHouseLibPath)
+ }
+ conf
+ }
+
+ private case class DummyPlan() extends LeafExecNode {
+ override def output: Seq[Attribute] = Seq()
+
+ override val metrics: Map[String, SQLMetric] = Map.empty
+
+ override def doExecute(): RDD[InternalRow] = throw new UnsupportedOperationException(
+ "Just a dummy plan.")
+ }
+
+ private val allPrimitiveDataTypes: Seq[DataType] =
+ Seq(
+ ByteType,
+ ShortType,
+ IntegerType,
+ LongType,
+ FloatType,
+ DoubleType,
+ DecimalType(5, 1),
+ StringType,
+ BinaryType,
+ DateType,
+ TimestampType)
+
+ private val allComplexDataTypes: Seq[DataType] = Seq(
+ // Currently, only check certain inner types, assuming they are representative
+ // for checking most expressions.
+ ArrayType(IntegerType),
+ MapType(StringType, IntegerType),
+ StructType(Seq(StructField("a", StringType), StructField("b", IntegerType)))
+ )
+
+ def generateChildExpression(t: DataType): Expression = {
+ t match {
+ case _: IntegralType => Literal(null, t)
+ case _: FractionalType => Literal(null, t)
+ case StringType | BinaryType => Literal("123")
+ case DateType => Literal(null, t)
+ case TimestampType => Literal(null, t)
+ case ArrayType(_, _) => Literal(null, t)
+ case MapType(_, _, _) => Literal(null, t)
+ case StructType(_) => Literal(null, t)
+ case _ => throw new UnsupportedOperationException("Not supported type: " + t)
+ }
+ }
+ def generateGlutenProjectPlan(expr: Expression): GlutenPlan = {
+ val namedExpr = Seq(Alias(expr, "r")())
+ ProjectExecTransformer(namedExpr, DummyPlan())
+ }
+
+ test("cast") {
+ for (from <- allPrimitiveDataTypes ++ allComplexDataTypes) {
+ for (to <- allPrimitiveDataTypes ++ allComplexDataTypes) {
+ if (to != from) {
+ val castExpr = Cast(generateChildExpression(from), to)
+ if (castExpr.checkInputDataTypes().isSuccess) {
+ val glutenProject = generateGlutenProjectPlan(castExpr)
+ if (glutenProject.doValidate().isValid) {
+ logInfo("## cast validation passes: cast from " + from + " to " + to)
+ } else {
+ // scalastyle:off
+ logInfo("!! cast validation fails: cast from " + from + " to " + to)
Review Comment:
This is wrongly kept. I will remove it. 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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on code in PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#discussion_r1674989299
##########
gluten-ut/test/src/test/scala/org/apache/spark/sql/GlutenExpressionDataTypesValidation.scala:
##########
@@ -0,0 +1,158 @@
+/*
+ * 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.spark.sql
+
+import org.apache.gluten.GlutenConfig
+import org.apache.gluten.execution.{ProjectExecTransformer, WholeStageTransformerSuite}
+import org.apache.gluten.extension.GlutenPlan
+import org.apache.gluten.utils.{BackendTestUtils, SystemParameters}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.rdd.RDD
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions._
+import org.apache.spark.sql.execution.LeafExecNode
+import org.apache.spark.sql.execution.metric.SQLMetric
+import org.apache.spark.sql.types._
+
+class GlutenExpressionDataTypesValidation extends WholeStageTransformerSuite {
+ protected val resourcePath: String = null
+ protected val fileFormat: String = null
+ override protected val logLevel: String = "INFO"
+
+ override protected def sparkConf: SparkConf = {
+ val conf = super.sparkConf
+ .set("spark.plugins", "org.apache.gluten.GlutenPlugin")
+ .set("spark.default.parallelism", "1")
+ .set("spark.memory.offHeap.enabled", "true")
+ .set("spark.memory.offHeap.size", "1024MB")
+ .set("spark.ui.enabled", "false")
+ .set("spark.gluten.ui.enabled", "false")
+ if (BackendTestUtils.isCHBackendLoaded()) {
+ conf
+ .set("spark.gluten.sql.enable.native.validation", "false")
+ .set(GlutenConfig.GLUTEN_LIB_PATH, SystemParameters.getClickHouseLibPath)
+ }
+ conf
+ }
+
+ private case class DummyPlan() extends LeafExecNode {
+ override def output: Seq[Attribute] = Seq()
+
+ override val metrics: Map[String, SQLMetric] = Map.empty
+
+ override def doExecute(): RDD[InternalRow] = throw new UnsupportedOperationException(
+ "Just a dummy plan.")
+ }
+
+ private val allPrimitiveDataTypes: Seq[DataType] =
+ Seq(
+ ByteType,
+ ShortType,
+ IntegerType,
+ LongType,
+ FloatType,
+ DoubleType,
+ DecimalType(5, 1),
+ StringType,
+ BinaryType,
+ DateType,
+ TimestampType)
+
+ private val allComplexDataTypes: Seq[DataType] = Seq(
+ // Currently, only check certain inner types, assuming they are representative
+ // for checking most expressions.
+ ArrayType(IntegerType),
+ MapType(StringType, IntegerType),
+ StructType(Seq(StructField("a", StringType), StructField("b", IntegerType)))
+ )
+
+ def generateChildExpression(t: DataType): Expression = {
+ t match {
+ case _: IntegralType => Literal(null, t)
+ case _: FractionalType => Literal(null, t)
+ case StringType | BinaryType => Literal("123")
+ case DateType => Literal(null, t)
+ case TimestampType => Literal(null, t)
+ case ArrayType(_, _) => Literal(null, t)
+ case MapType(_, _, _) => Literal(null, t)
+ case StructType(_) => Literal(null, t)
+ case _ => throw new UnsupportedOperationException("Not supported type: " + t)
+ }
+ }
+ def generateGlutenProjectPlan(expr: Expression): GlutenPlan = {
+ val namedExpr = Seq(Alias(expr, "r")())
+ ProjectExecTransformer(namedExpr, DummyPlan())
+ }
+
+ test("cast") {
+ for (from <- allPrimitiveDataTypes ++ allComplexDataTypes) {
+ for (to <- allPrimitiveDataTypes ++ allComplexDataTypes) {
+ if (to != from) {
+ val castExpr = Cast(generateChildExpression(from), to)
+ if (castExpr.checkInputDataTypes().isSuccess) {
+ val glutenProject = generateGlutenProjectPlan(castExpr)
+ if (glutenProject.doValidate().isValid) {
Review Comment:
FYI. Just noted hongze's fix: https://github.com/apache/incubator-gluten/pull/6418
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a test to validate any unary expression with its accepted types [incubator-gluten]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#issuecomment-2219781296
Run Gluten Clickhouse CI
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#issuecomment-2221890334
Run Gluten Clickhouse CI
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a test to validate any unary expression with its accepted types [incubator-gluten]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#issuecomment-2219780926
<!--
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/LICEGJ-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.
-->
Thanks for opening a pull request!
Could you open an issue for this pull request on Github Issues?
https://github.com/apache/incubator-gluten/issues
Then could you also rename ***commit message*** and ***pull request title*** in the following format?
[GLUTEN-${ISSUES_ID}][COMPONENT]feat/fix: ${detailed message}
See also:
* [Other pull requests](https://github.com/apache/incubator-gluten/pulls/)
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a tool to validate any unary expression with all its accepted types [incubator-gluten]
Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#issuecomment-2221829292
> Does the change apply to CH backend as well?
CH backend will also run this. But as it doesn't implement doValidate API for native validation, this tool doesn't produce correct result. I will disable it for CH backend. 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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org
Re: [PR] [UT] Add a test to validate any unary expression with its accepted types [incubator-gluten]
Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on PR #6392:
URL: https://github.com/apache/incubator-gluten/pull/6392#issuecomment-2221802612
@rui-mo, do you have any comment?
--
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: commits-unsubscribe@gluten.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org