You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Ben (JIRA)" <ji...@apache.org> on 2017/03/08 15:14:38 UTC

[jira] [Commented] (SPARK-18667) input_file_name function does not work with UDF

    [ https://issues.apache.org/jira/browse/SPARK-18667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15901403#comment-15901403 ] 

Ben commented on SPARK-18667:
-----------------------------

Any news on this? 
The issue is still there, at least wil spark-xml, so I think this issue should be reopened.

> 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.15#6346)

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