udf No TypeTag available for type string

后端 未结 1 1533
天涯浪人
天涯浪人 2020-12-21 22:46

I don\'t understand a behavior of spark.

I create an udf wich return an Integer like below

import org.apache.spark.sql.SQLContext
import org.apache.         


        
相关标签:
1条回答
  • 2020-12-21 23:43

    Since I can't reproduce the issue copy-pasting just your example code into a new file, I bet that in your real code String is actually shadowed by something else. To verify this theory you can try to change you signature to

    def testString() : scala.Predef.String = {
      return "myString"
    }
    

    or

    def testString() : java.lang.String = {
      return "myString"
    }
    

    If this one compiles, search for "String" to see how you shadowed the standard type. If you use IntelliJ Idea, you can try to use "Ctrl+B" (GoTo) to find it out. The most obvious candidate is that you used String as a name of generic type parameter but there might be some other choices.

    0 讨论(0)
提交回复
热议问题