Skip to content
Closed
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 @@ -709,6 +709,8 @@ object ScalaReflection extends ScalaReflection {
def attributesFor[T: TypeTag]: Seq[Attribute] = schemaFor[T] match {
case Schema(s: StructType, _) =>
s.toAttributes
case others =>
throw new UnsupportedOperationException(s"Attributes for type $others is not supported")
}

/** Returns a catalyst DataType and its nullability for the given Scala Type using reflection. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ case class ApproxCountDistinctForIntervals(
}

// Mark as lazy so that endpointsExpression is not evaluated during tree transformation.
lazy val endpoints: Array[Double] =
(endpointsExpression.dataType, endpointsExpression.eval()) match {
case (ArrayType(elementType, _), arrayData: ArrayData) =>
arrayData.toObjectArray(elementType).map(_.toString.toDouble)
}
lazy val endpoints: Array[Double] = {
val endpointsType = endpointsExpression.dataType.asInstanceOf[ArrayType]
val endpoints = endpointsExpression.eval().asInstanceOf[ArrayData]
endpoints.toObjectArray(endpointsType.elementType).map(_.toString.toDouble)
}

override def checkInputDataTypes(): TypeCheckResult = {
val defaultCheck = super.checkInputDataTypes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ class CodegenContext {
case NewFunctionSpec(functionName, None, None) => functionName
case NewFunctionSpec(functionName, Some(_), Some(innerClassInstance)) =>
innerClassInstance + "." + functionName
case _ =>
throw new IllegalArgumentException(s"$funcName is not matched at addNewFunction")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ object ValueInterval {
false
case (n1: NumericValueInterval, n2: NumericValueInterval) =>
n1.min.compareTo(n2.max) <= 0 && n1.max.compareTo(n2.min) >= 0
case _ =>
throw new UnsupportedOperationException(s"Not supported pair: $r1, $r2 at isIntersected()")
}

/**
Expand All @@ -86,6 +88,8 @@ object ValueInterval {
val newMax = if (n1.max <= n2.max) n1.max else n2.max
(Some(EstimationUtils.fromDouble(newMin, dt)),
Some(EstimationUtils.fromDouble(newMax, dt)))
case _ =>
throw new UnsupportedOperationException(s"Not supported pair: $r1, $r2 at intersect()")
}
}
}