maropu commented on a change in pull request #30334: URL: https://github.com/apache/spark/pull/30334#discussion_r593163172
########## File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/UnionEstimationSuite.scala ########## @@ -0,0 +1,194 @@ +/* + * 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.catalyst.statsEstimation + +import org.apache.spark.sql.catalyst.expressions.{AttributeMap, AttributeReference} +import org.apache.spark.sql.catalyst.plans.logical +import org.apache.spark.sql.catalyst.plans.logical.{ColumnStat, Union} +import org.apache.spark.sql.types.{ByteType, DateType, Decimal, DecimalType, DoubleType, FloatType, IntegerType, LongType, ShortType, TimestampType} + +class UnionEstimationSuite extends StatsEstimationTestBase { + + test("test row size estimation") { + val attrInt = AttributeReference("cint", IntegerType)() + + val sz = Some(BigInt(1024)) + val child1 = StatsTestPlan( + outputList = Seq(attrInt), + rowCount = 2, + attributeStats = AttributeMap(Nil), + size = sz) + + val child2 = StatsTestPlan( + outputList = Seq(attrInt), + rowCount = 2, + attributeStats = AttributeMap(Nil), + size = sz) + + val union = Union(Seq(child1, child2)) + val expectedStats = logical.Statistics(sizeInBytes = 2 * 1024, rowCount = Some(4)) + assert(union.stats === expectedStats) + } + + test("col stats estimation") { + val sz = Some(BigInt(1024)) + + val attrInt = AttributeReference("cint", IntegerType)() + val attrDouble = AttributeReference("cdouble", DoubleType)() + val attrShort = AttributeReference("cshort", ShortType)() + val attrLong = AttributeReference("clong", LongType)() + val attrByte = AttributeReference("cbyte", ByteType)() + val attrFloat = AttributeReference("cfloat", FloatType)() + val attrDecimal = AttributeReference("cdecimal", DecimalType(5, 4))() + val attrDate = AttributeReference("cdate", DateType)() + val attrTimestamp = AttributeReference("ctimestamp", TimestampType)() + + val s1 = 1.toShort + val s2 = 4.toShort + val b1 = 1.toByte + val b2 = 4.toByte + val columnInfo: AttributeMap[ColumnStat] = AttributeMap( Review comment: nit: `val columnInfo = AttributeMap(` ########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/UnionEstimation.scala ########## @@ -0,0 +1,120 @@ +/* + * 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.catalyst.plans.logical.statsEstimation + +import scala.collection.mutable.ArrayBuffer + +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeMap} +import org.apache.spark.sql.catalyst.plans.logical.{ColumnStat, Statistics, Union} +import org.apache.spark.sql.types._ + +/** + * Estimate the number of output rows by doing the sum of output rows for each child of union, + * and estimate min and max stats for each column by finding the overall min and max of that + * column coming from its children. + */ +object UnionEstimation { + import EstimationUtils._ + + private def createStatComparator(dt: DataType): (Any, Any) => Boolean = dt match { + case ByteType => (a: Any, b: Any) => + ByteType.ordering.lt(a.asInstanceOf[Byte], b.asInstanceOf[Byte]) + case ShortType => (a: Any, b: Any) => + ShortType.ordering.lt(a.asInstanceOf[Short], b.asInstanceOf[Short]) + case IntegerType => (a: Any, b: Any) => + IntegerType.ordering.lt(a.asInstanceOf[Int], b.asInstanceOf[Int]) + case LongType => (a: Any, b: Any) => + LongType.ordering.lt(a.asInstanceOf[Long], b.asInstanceOf[Long]) + case FloatType => (a: Any, b: Any) => + FloatType.ordering.lt(a.asInstanceOf[Float], b.asInstanceOf[Float]) + case DoubleType => (a: Any, b: Any) => + DoubleType.ordering.lt(a.asInstanceOf[Double], b.asInstanceOf[Double]) + case _: DecimalType => (a: Any, b: Any) => + dt.asInstanceOf[DecimalType].ordering.lt(a.asInstanceOf[Decimal], b.asInstanceOf[Decimal]) + case DateType => (a: Any, b: Any) => + DateType.ordering.lt(a.asInstanceOf[DateType.InternalType], + b.asInstanceOf[DateType.InternalType]) + case TimestampType => (a: Any, b: Any) => + TimestampType.ordering.lt(a.asInstanceOf[TimestampType.InternalType], + b.asInstanceOf[TimestampType.InternalType]) + case _ => + throw new IllegalStateException(s"Unsupported data type: ${dt.catalogString}") + } + + private def isTypeSupported(dt: DataType): Boolean = dt match { + case ByteType | IntegerType | ShortType | FloatType | LongType | + DoubleType | DateType | _: DecimalType | TimestampType => true + case _ => false + } + + def estimate(union: Union): Option[Statistics] = { + val sizeInBytes = union.children.map(_.stats.sizeInBytes).sum + val outputRows: Option[BigInt] = if (rowCountsExist(union.children: _*)) { Review comment: nit: `val outputRows =` ########## File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/UnionEstimationSuite.scala ########## @@ -0,0 +1,194 @@ +/* + * 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.catalyst.statsEstimation + +import org.apache.spark.sql.catalyst.expressions.{AttributeMap, AttributeReference} +import org.apache.spark.sql.catalyst.plans.logical +import org.apache.spark.sql.catalyst.plans.logical.{ColumnStat, Union} +import org.apache.spark.sql.types.{ByteType, DateType, Decimal, DecimalType, DoubleType, FloatType, IntegerType, LongType, ShortType, TimestampType} + +class UnionEstimationSuite extends StatsEstimationTestBase { + + test("test row size estimation") { + val attrInt = AttributeReference("cint", IntegerType)() + + val sz = Some(BigInt(1024)) + val child1 = StatsTestPlan( + outputList = Seq(attrInt), + rowCount = 2, + attributeStats = AttributeMap(Nil), + size = sz) + + val child2 = StatsTestPlan( + outputList = Seq(attrInt), + rowCount = 2, + attributeStats = AttributeMap(Nil), + size = sz) + + val union = Union(Seq(child1, child2)) + val expectedStats = logical.Statistics(sizeInBytes = 2 * 1024, rowCount = Some(4)) + assert(union.stats === expectedStats) + } + + test("col stats estimation") { + val sz = Some(BigInt(1024)) + + val attrInt = AttributeReference("cint", IntegerType)() + val attrDouble = AttributeReference("cdouble", DoubleType)() + val attrShort = AttributeReference("cshort", ShortType)() + val attrLong = AttributeReference("clong", LongType)() + val attrByte = AttributeReference("cbyte", ByteType)() + val attrFloat = AttributeReference("cfloat", FloatType)() + val attrDecimal = AttributeReference("cdecimal", DecimalType(5, 4))() + val attrDate = AttributeReference("cdate", DateType)() + val attrTimestamp = AttributeReference("ctimestamp", TimestampType)() + + val s1 = 1.toShort + val s2 = 4.toShort + val b1 = 1.toByte + val b2 = 4.toByte + val columnInfo: AttributeMap[ColumnStat] = AttributeMap( + Seq( + attrInt -> ColumnStat( + distinctCount = Some(2), + min = Some(1), + max = Some(4), + nullCount = Some(0), + avgLen = Some(4), + maxLen = Some(4)), + attrDouble -> ColumnStat( + distinctCount = Some(2), + min = Some(5.0), + max = Some(4.0), + nullCount = Some(0), + avgLen = Some(4), + maxLen = Some(4)), + attrShort -> ColumnStat(min = Some(s1), max = Some(s2)), + attrLong -> ColumnStat(min = Some(1L), max = Some(4L)), + attrByte -> ColumnStat(min = Some(b1), max = Some(b2)), + attrFloat -> ColumnStat(min = Some(1.1f), max = Some(4.1f)), + attrDecimal -> ColumnStat(min = Some(Decimal(13.5)), max = Some(Decimal(19.5))), + attrDate -> ColumnStat(min = Some(1), max = Some(4)), + attrTimestamp -> ColumnStat(min = Some(1L), max = Some(4L)))) + + val s3 = 2.toShort + val s4 = 6.toShort + val b3 = 2.toByte + val b4 = 6.toByte + val columnInfo1: AttributeMap[ColumnStat] = AttributeMap( Review comment: nit: `val columnInfo1 = AttributeMap(` ########## File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/UnionEstimationSuite.scala ########## @@ -0,0 +1,194 @@ +/* + * 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.catalyst.statsEstimation + +import org.apache.spark.sql.catalyst.expressions.{AttributeMap, AttributeReference} +import org.apache.spark.sql.catalyst.plans.logical +import org.apache.spark.sql.catalyst.plans.logical.{ColumnStat, Union} +import org.apache.spark.sql.types.{ByteType, DateType, Decimal, DecimalType, DoubleType, FloatType, IntegerType, LongType, ShortType, TimestampType} + +class UnionEstimationSuite extends StatsEstimationTestBase { + + test("test row size estimation") { + val attrInt = AttributeReference("cint", IntegerType)() + + val sz = Some(BigInt(1024)) + val child1 = StatsTestPlan( + outputList = Seq(attrInt), + rowCount = 2, + attributeStats = AttributeMap(Nil), + size = sz) + + val child2 = StatsTestPlan( + outputList = Seq(attrInt), + rowCount = 2, + attributeStats = AttributeMap(Nil), + size = sz) + + val union = Union(Seq(child1, child2)) + val expectedStats = logical.Statistics(sizeInBytes = 2 * 1024, rowCount = Some(4)) + assert(union.stats === expectedStats) + } + + test("col stats estimation") { + val sz = Some(BigInt(1024)) + + val attrInt = AttributeReference("cint", IntegerType)() + val attrDouble = AttributeReference("cdouble", DoubleType)() + val attrShort = AttributeReference("cshort", ShortType)() + val attrLong = AttributeReference("clong", LongType)() + val attrByte = AttributeReference("cbyte", ByteType)() + val attrFloat = AttributeReference("cfloat", FloatType)() + val attrDecimal = AttributeReference("cdecimal", DecimalType(5, 4))() + val attrDate = AttributeReference("cdate", DateType)() + val attrTimestamp = AttributeReference("ctimestamp", TimestampType)() + + val s1 = 1.toShort + val s2 = 4.toShort + val b1 = 1.toByte + val b2 = 4.toByte + val columnInfo: AttributeMap[ColumnStat] = AttributeMap( + Seq( + attrInt -> ColumnStat( + distinctCount = Some(2), + min = Some(1), + max = Some(4), + nullCount = Some(0), + avgLen = Some(4), + maxLen = Some(4)), + attrDouble -> ColumnStat( + distinctCount = Some(2), + min = Some(5.0), + max = Some(4.0), + nullCount = Some(0), + avgLen = Some(4), + maxLen = Some(4)), + attrShort -> ColumnStat(min = Some(s1), max = Some(s2)), + attrLong -> ColumnStat(min = Some(1L), max = Some(4L)), + attrByte -> ColumnStat(min = Some(b1), max = Some(b2)), + attrFloat -> ColumnStat(min = Some(1.1f), max = Some(4.1f)), + attrDecimal -> ColumnStat(min = Some(Decimal(13.5)), max = Some(Decimal(19.5))), + attrDate -> ColumnStat(min = Some(1), max = Some(4)), + attrTimestamp -> ColumnStat(min = Some(1L), max = Some(4L)))) + + val s3 = 2.toShort + val s4 = 6.toShort + val b3 = 2.toByte + val b4 = 6.toByte + val columnInfo1: AttributeMap[ColumnStat] = AttributeMap( + Seq( + AttributeReference("cint1", IntegerType)() -> ColumnStat( + distinctCount = Some(2), + min = Some(3), + max = Some(6), + nullCount = Some(0), + avgLen = Some(8), + maxLen = Some(8)), + AttributeReference("cdouble1", DoubleType)() -> ColumnStat( + distinctCount = Some(2), + min = Some(2.0), + max = Some(7.0), + nullCount = Some(0), + avgLen = Some(8), + maxLen = Some(8)), + AttributeReference("cshort1", ShortType)() -> ColumnStat(min = Some(s3), max = Some(s4)), + AttributeReference("clong1", LongType)() -> ColumnStat(min = Some(2L), max = Some(6L)), + AttributeReference("cbyte1", ByteType)() -> ColumnStat(min = Some(b3), max = Some(b4)), + AttributeReference("cfloat1", FloatType)() -> ColumnStat( + min = Some(2.2f), + max = Some(6.1f)), + AttributeReference("cdecimal1", DecimalType(5, 4))() -> ColumnStat( + min = Some(Decimal(14.5)), + max = Some(Decimal(19.9))), + AttributeReference("cdate1", DateType)() -> ColumnStat(min = Some(3), max = Some(6)), + AttributeReference("ctimestamp1", TimestampType)() -> ColumnStat( + min = Some(3L), + max = Some(6L)))) + + val child1 = StatsTestPlan( + outputList = columnInfo.keys.toSeq.sortWith(_.exprId.id < _.exprId.id), + rowCount = 2, + attributeStats = columnInfo, + size = sz) + + val child2 = StatsTestPlan( + outputList = columnInfo1.keys.toSeq.sortWith(_.exprId.id < _.exprId.id), + rowCount = 2, + attributeStats = columnInfo1, + size = sz) + + val union = Union(Seq(child1, child2)) + + val expectedStats = logical.Statistics( + sizeInBytes = 2 * 1024, + rowCount = Some(4), + attributeStats = AttributeMap( + Seq( + attrInt -> ColumnStat(min = Some(1), max = Some(6)), + attrDouble -> ColumnStat(min = Some(2.0), max = Some(7.0)), + attrShort -> ColumnStat(min = Some(s1), max = Some(s4)), + attrLong -> ColumnStat(min = Some(1L), max = Some(6L)), + attrByte -> ColumnStat(min = Some(b1), max = Some(b4)), + attrFloat -> ColumnStat(min = Some(1.1f), max = Some(6.1f)), + attrDecimal -> ColumnStat(min = Some(Decimal(13.5)), max = Some(Decimal(19.9))), + attrDate -> ColumnStat(min = Some(1), max = Some(6)), + attrTimestamp -> ColumnStat(min = Some(1L), max = Some(6L))))) + assert(union.stats === expectedStats) + } + + test("col stats estimation when min max stats not present for one child") { + val sz = Some(BigInt(1024)) + + val attrInt = AttributeReference("cint", IntegerType)() + + val columnInfo: AttributeMap[ColumnStat] = AttributeMap( + Seq( + attrInt -> ColumnStat( + distinctCount = Some(2), + min = Some(2), + max = Some(2), + nullCount = Some(0), + avgLen = Some(4), + maxLen = Some(4)))) + + val columnInfo1: AttributeMap[ColumnStat] = AttributeMap( Review comment: nit: `val columnInfo1 = AttributeMap(` ########## File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/UnionEstimationSuite.scala ########## @@ -0,0 +1,194 @@ +/* + * 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.catalyst.statsEstimation + +import org.apache.spark.sql.catalyst.expressions.{AttributeMap, AttributeReference} +import org.apache.spark.sql.catalyst.plans.logical +import org.apache.spark.sql.catalyst.plans.logical.{ColumnStat, Union} +import org.apache.spark.sql.types.{ByteType, DateType, Decimal, DecimalType, DoubleType, FloatType, IntegerType, LongType, ShortType, TimestampType} + +class UnionEstimationSuite extends StatsEstimationTestBase { + + test("test row size estimation") { + val attrInt = AttributeReference("cint", IntegerType)() + + val sz = Some(BigInt(1024)) + val child1 = StatsTestPlan( + outputList = Seq(attrInt), + rowCount = 2, + attributeStats = AttributeMap(Nil), + size = sz) + + val child2 = StatsTestPlan( + outputList = Seq(attrInt), + rowCount = 2, + attributeStats = AttributeMap(Nil), + size = sz) + + val union = Union(Seq(child1, child2)) + val expectedStats = logical.Statistics(sizeInBytes = 2 * 1024, rowCount = Some(4)) + assert(union.stats === expectedStats) + } + + test("col stats estimation") { + val sz = Some(BigInt(1024)) + + val attrInt = AttributeReference("cint", IntegerType)() + val attrDouble = AttributeReference("cdouble", DoubleType)() + val attrShort = AttributeReference("cshort", ShortType)() + val attrLong = AttributeReference("clong", LongType)() + val attrByte = AttributeReference("cbyte", ByteType)() + val attrFloat = AttributeReference("cfloat", FloatType)() + val attrDecimal = AttributeReference("cdecimal", DecimalType(5, 4))() + val attrDate = AttributeReference("cdate", DateType)() + val attrTimestamp = AttributeReference("ctimestamp", TimestampType)() + + val s1 = 1.toShort + val s2 = 4.toShort + val b1 = 1.toByte + val b2 = 4.toByte + val columnInfo: AttributeMap[ColumnStat] = AttributeMap( + Seq( + attrInt -> ColumnStat( + distinctCount = Some(2), + min = Some(1), + max = Some(4), + nullCount = Some(0), + avgLen = Some(4), + maxLen = Some(4)), + attrDouble -> ColumnStat( + distinctCount = Some(2), + min = Some(5.0), + max = Some(4.0), + nullCount = Some(0), + avgLen = Some(4), + maxLen = Some(4)), + attrShort -> ColumnStat(min = Some(s1), max = Some(s2)), + attrLong -> ColumnStat(min = Some(1L), max = Some(4L)), + attrByte -> ColumnStat(min = Some(b1), max = Some(b2)), + attrFloat -> ColumnStat(min = Some(1.1f), max = Some(4.1f)), + attrDecimal -> ColumnStat(min = Some(Decimal(13.5)), max = Some(Decimal(19.5))), + attrDate -> ColumnStat(min = Some(1), max = Some(4)), + attrTimestamp -> ColumnStat(min = Some(1L), max = Some(4L)))) + + val s3 = 2.toShort + val s4 = 6.toShort + val b3 = 2.toByte + val b4 = 6.toByte + val columnInfo1: AttributeMap[ColumnStat] = AttributeMap( + Seq( + AttributeReference("cint1", IntegerType)() -> ColumnStat( + distinctCount = Some(2), + min = Some(3), + max = Some(6), + nullCount = Some(0), + avgLen = Some(8), + maxLen = Some(8)), + AttributeReference("cdouble1", DoubleType)() -> ColumnStat( + distinctCount = Some(2), + min = Some(2.0), + max = Some(7.0), + nullCount = Some(0), + avgLen = Some(8), + maxLen = Some(8)), + AttributeReference("cshort1", ShortType)() -> ColumnStat(min = Some(s3), max = Some(s4)), + AttributeReference("clong1", LongType)() -> ColumnStat(min = Some(2L), max = Some(6L)), + AttributeReference("cbyte1", ByteType)() -> ColumnStat(min = Some(b3), max = Some(b4)), + AttributeReference("cfloat1", FloatType)() -> ColumnStat( + min = Some(2.2f), + max = Some(6.1f)), + AttributeReference("cdecimal1", DecimalType(5, 4))() -> ColumnStat( + min = Some(Decimal(14.5)), + max = Some(Decimal(19.9))), + AttributeReference("cdate1", DateType)() -> ColumnStat(min = Some(3), max = Some(6)), + AttributeReference("ctimestamp1", TimestampType)() -> ColumnStat( + min = Some(3L), + max = Some(6L)))) + + val child1 = StatsTestPlan( + outputList = columnInfo.keys.toSeq.sortWith(_.exprId.id < _.exprId.id), + rowCount = 2, + attributeStats = columnInfo, + size = sz) + + val child2 = StatsTestPlan( + outputList = columnInfo1.keys.toSeq.sortWith(_.exprId.id < _.exprId.id), + rowCount = 2, + attributeStats = columnInfo1, + size = sz) + + val union = Union(Seq(child1, child2)) + + val expectedStats = logical.Statistics( + sizeInBytes = 2 * 1024, + rowCount = Some(4), + attributeStats = AttributeMap( + Seq( + attrInt -> ColumnStat(min = Some(1), max = Some(6)), + attrDouble -> ColumnStat(min = Some(2.0), max = Some(7.0)), + attrShort -> ColumnStat(min = Some(s1), max = Some(s4)), + attrLong -> ColumnStat(min = Some(1L), max = Some(6L)), + attrByte -> ColumnStat(min = Some(b1), max = Some(b4)), + attrFloat -> ColumnStat(min = Some(1.1f), max = Some(6.1f)), + attrDecimal -> ColumnStat(min = Some(Decimal(13.5)), max = Some(Decimal(19.9))), + attrDate -> ColumnStat(min = Some(1), max = Some(6)), + attrTimestamp -> ColumnStat(min = Some(1L), max = Some(6L))))) + assert(union.stats === expectedStats) + } + + test("col stats estimation when min max stats not present for one child") { + val sz = Some(BigInt(1024)) + + val attrInt = AttributeReference("cint", IntegerType)() + + val columnInfo: AttributeMap[ColumnStat] = AttributeMap( Review comment: nit: `val columnInfo = AttributeMap(` ########## File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/BasicStatsEstimationSuite.scala ########## @@ -163,6 +244,41 @@ class BasicStatsEstimationSuite extends PlanTest with StatsEstimationTestBase { expectedStatsCboOff = Statistics(sizeInBytes = sizeInBytes)) } + test("row size and column stats estimation for sort") { + val columnInfo: AttributeMap[ColumnStat] = AttributeMap( Review comment: nit: `val columnInfo = AttributeMap(` ########## File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/UnionEstimationSuite.scala ########## @@ -0,0 +1,194 @@ +/* + * 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.catalyst.statsEstimation + +import org.apache.spark.sql.catalyst.expressions.{AttributeMap, AttributeReference} +import org.apache.spark.sql.catalyst.plans.logical +import org.apache.spark.sql.catalyst.plans.logical.{ColumnStat, Union} +import org.apache.spark.sql.types.{ByteType, DateType, Decimal, DecimalType, DoubleType, FloatType, IntegerType, LongType, ShortType, TimestampType} Review comment: `import org.apache.spark.sql.types._` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
