org.apache.spark.sql.catalyst.analysis.UnresolvedException Scala Examples
The following examples show how to use org.apache.spark.sql.catalyst.analysis.UnresolvedException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: AnnotationFilter.scala From HANAVora-Extensions with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.catalyst.expressions import org.apache.spark.sql.catalyst.analysis.{UnresolvedException, UnresolvedAttribute} import org.apache.spark.sql.catalyst.expressions.codegen.CodegenFallback import org.apache.spark.sql.catalyst.{InternalRow, trees} import org.apache.spark.sql.types._ case class AnnotationFilter(child: Expression)( val filters: Set[String] = Set.empty, val exprId: ExprId = NamedExpression.newExprId) extends UnaryExpression with NamedExpression with CodegenFallback { override def name: String = child match { case e:NamedExpression => e.name case _ => throw new UnresolvedException(this, "name of AnnotationFilter with non-named child") } override lazy val resolved = childrenResolved override def toAttribute: Attribute = { if (resolved) { child.transform ({ case a:Alias => a.copy(a.child, a.name)(a.exprId, qualifiers = a.qualifiers, explicitMetadata = Some(MetadataAccessor.filterMetadata(a.metadata, filters))) case a:AttributeReference => a.copy(a.name, a.dataType, a.nullable, metadata = MetadataAccessor.filterMetadata(a.metadata, filters))(a.exprId, a.qualifiers) case p => p }) match { case e: NamedExpression => e.toAttribute case _ => throw new UnresolvedException(this, "toAttribute of AnnotationFilter with " + "no-named child") } } else { UnresolvedAttribute(name) } } override def equals(other: Any): Boolean = other match { case aa: AnnotationFilter => child == aa.child && filters == aa.filters && exprId == aa.exprId case _ => false } // scalastyle:off magic.number override def hashCode:Int = { List[Int](child.hashCode, filters.hashCode, exprId.hashCode) .foldLeft(17)((l, r) => 31 * l + r) } override def metadata: Metadata = { child match { case named: NamedExpression => MetadataAccessor.filterMetadata(named.metadata, filters) case _ => Metadata.empty } } override def qualifiers: Seq[String] = Nil override def eval(input: InternalRow): Any = child.eval(input) override def nullable: Boolean = child.nullable override def dataType: DataType = child.dataType override protected final def otherCopyArgs: Seq[AnyRef] = filters :: exprId :: Nil }
Example 2
Source File: nullFunctions.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.catalyst.expressions import org.apache.spark.sql.catalyst.trees import org.apache.spark.sql.catalyst.analysis.UnresolvedException import org.apache.spark.sql.types.DataType case class Coalesce(children: Seq[Expression]) extends Expression { type EvaluatedType = Any case class AtLeastNNonNulls(n: Int, children: Seq[Expression]) extends Predicate { override def nullable: Boolean = false override def foldable: Boolean = false override def toString: String = s"AtLeastNNulls(n, ${children.mkString(",")})" private[this] val childrenArray = children.toArray override def eval(input: Row): Boolean = { var numNonNulls = 0 var i = 0 while (i < childrenArray.length && numNonNulls < n) { if (childrenArray(i).eval(input) != null) { numNonNulls += 1 } i += 1 } numNonNulls >= n } }