ant_nebula created SPARK-8076:
---------------------------------

             Summary: spark sql udtf error
                 Key: SPARK-8076
                 URL: https://issues.apache.org/jira/browse/SPARK-8076
             Project: Spark
          Issue Type: Question
            Reporter: ant_nebula


code:
val conf = new SparkConf().setAppName("UDFTest1")
    val sc = new SparkContext(conf)
    val hiveContext = new HiveContext(sc)

    import hiveContext.implicits._

    val custs = Seq(
      (1, "Widget Co", 120000.00, 0.00, "AZ", "c1/c2/c3", "d1/d2/d3"),
      (2, "Acme Widgets", 410500.00, 500.00, "CA", "c1/c2/c3", "d1/d2/d3")
    )
    val customerRows = sc.parallelize(custs, 4)
    val customerDF = customerRows.toDF("id", "name", "sales", "discount", 
"state", "code", "desc")

    customerDF.printSchema()
    customerDF.registerTempTable("ods_action_log")

    hiveContext.sql("CREATE TEMPORARY FUNCTION split_path_to_tree AS 
'com.duowan.mydemo.udf.GenericUDTFSplitPath'")

    val data1 = hiveContext.sql("select state, code, desc, cur_path, path1, 
path2, path3, parent, is_leaf, long_desc, short_desc " +
      "from ods_action_log " +
      "LATERAL VIEW split_path_to_tree(code, desc, 3) s AS cur_path, path1, 
path2, path3, parent, is_leaf, long_desc, short_desc")
    data1.printSchema()
    data1.show()


error:
Exception in thread "main" java.lang.ClassNotFoundException: split_path_to_tree
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at 
org.apache.spark.sql.hive.HiveFunctionWrapper.createFunction(Shim13.scala:147)
        at 
org.apache.spark.sql.hive.HiveGenericUdtf.function$lzycompute(hiveUdfs.scala:274)
        at 
org.apache.spark.sql.hive.HiveGenericUdtf.function(hiveUdfs.scala:274)
        at 
org.apache.spark.sql.hive.HiveGenericUdtf.outputInspector$lzycompute(hiveUdfs.scala:280)
        at 
org.apache.spark.sql.hive.HiveGenericUdtf.outputInspector(hiveUdfs.scala:280)
        at 
org.apache.spark.sql.hive.HiveGenericUdtf.outputDataTypes$lzycompute(hiveUdfs.scala:285)
        at 
org.apache.spark.sql.hive.HiveGenericUdtf.outputDataTypes(hiveUdfs.scala:285)
        at 
org.apache.spark.sql.hive.HiveGenericUdtf.makeOutput(hiveUdfs.scala:291)
        at 
org.apache.spark.sql.catalyst.expressions.Generator.output(generators.scala:60)
        at 
org.apache.spark.sql.catalyst.plans.logical.Generate$$anonfun$2.apply(basicOperators.scala:60)
        at 
org.apache.spark.sql.catalyst.plans.logical.Generate$$anonfun$2.apply(basicOperators.scala:60)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to