I have defined following function written in Scala, for finding out whether particular type of nodes(Project,Filter) is contained in a given set or not:
private val operators = Set(Project.getClass,Filter.getClass)
def containsNode(plan: Seq[LogicalPlan]):Boolean=
{
for(p<- plan)
{
if(operators.contains(p.getClass))
true
}
false
}
When running the code I am getting the following error for the above function:
Error:(182, 36) type mismatch; found : Class[T(in value $anonfun)] where type T(in value $anonfun) <: org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
required: Class[_ >: T(in value operators) with T <: Serializable]
if(operators .contains(p.getClass))
I thought p.getClass would give same type of value that set operators expect. But it doesn't seem like it. I am new to Scala and Spark, so I am not sure what exactly is going on here. How can I fix this error?