[ https://issues.apache.org/jira/browse/SPARK-18667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15821188#comment-15821188 ]
Ben edited comment on SPARK-18667 at 1/12/17 3:01 PM: ------------------------------------------------------ OK, I just tried it with a json and it worked. To be honest I was trying it with an XML file, and I didn't think that would matter, but apparently yes. So, the exact same code, but with an XML file through the spark-xml library is not working. Can you confirm this? Would this be a spark-xml issue then, or still a pyspark issue? was (Author: someonehere15): OK, I just tried it with a json and it worked. To be honest I was trying it with an XML file, and I didn't think that would matter, but apparently yes. So, the exact same code, but with an XML file through the spark-xml library is not working. Would this be a spark-xml issue then, or still a pyspark issue? > input_file_name function does not work with UDF > ----------------------------------------------- > > Key: SPARK-18667 > URL: https://issues.apache.org/jira/browse/SPARK-18667 > Project: Spark > Issue Type: Bug > Components: PySpark > Reporter: Hyukjin Kwon > Assignee: Liang-Chi Hsieh > Fix For: 2.1.0 > > > {{input_file_name()}} does not return the file name but empty string instead > when it is used as input for UDF in PySpark as below: > with the data as below: > {code} > {"a": 1} > {code} > with the codes below: > {code} > from pyspark.sql.functions import * > from pyspark.sql.types import * > def filename(path): > return path > sourceFile = udf(filename, StringType()) > spark.read.json("tmp.json").select(sourceFile(input_file_name())).show() > {code} > prints as below: > {code} > +---------------------------+ > |filename(input_file_name())| > +---------------------------+ > | | > +---------------------------+ > {code} > but the codes below: > {code} > spark.read.json("tmp.json").select(input_file_name()).show() > {code} > prints correctly as below: > {code} > +--------------------+ > | input_file_name()| > +--------------------+ > |file:///Users/hyu...| > +--------------------+ > {code} > This seems PySpark specific issue. -- 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