You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "holdenk (JIRA)" <ji...@apache.org> on 2016/11/25 13:56:58 UTC
[jira] [Commented] (SPARK-18541) Add
pyspark.sql.Column.aliasWithMetadata to allow dynamic metadata management
in pyspark SQL API
[ https://issues.apache.org/jira/browse/SPARK-18541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15695922#comment-15695922 ]
holdenk commented on SPARK-18541:
---------------------------------
Making it easier for PySpark SQL users to specify metadata sounds interesting/useful. I'd probably try and choose something closer to the scala API (e.g. implement `as` instead of `aliasWithMetadata`). What do [~davies] / [~marmbrus] think?
> Add pyspark.sql.Column.aliasWithMetadata to allow dynamic metadata management in pyspark SQL API
> ------------------------------------------------------------------------------------------------
>
> Key: SPARK-18541
> URL: https://issues.apache.org/jira/browse/SPARK-18541
> Project: Spark
> Issue Type: Improvement
> Components: PySpark, SQL
> Affects Versions: 2.0.2
> Environment: all
> Reporter: Shea Parkes
> Priority: Minor
> Labels: newbie
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> In the Scala SQL API, you can pass in new metadata when you alias a field. That functionality is not available in the Python API. Right now, you have to painfully utilize {{SparkSession.createDataFrame}} to manipulate the metadata for even a single column. I would propose to add the following method to {{pyspark.sql.Column}}:
> {code}
> def aliasWithMetadata(self, name, metadata):
> """
> Make a new Column that has the provided alias and metadata.
> Metadata will be processed with json.dumps()
> """
> _context = pyspark.SparkContext._active_spark_context
> _metadata_str = json.dumps(metadata)
> _metadata_jvm = _context._jvm.org.apache.spark.sql.types.Metadata.fromJson(_metadata_str)
> _new_java_column = getattr(self._jc, 'as')(name, _metadata_jvm)
> return Column(_new_java_column)
> {code}
> I can likely complete this request myself if there is any interest for it. Just have to dust off my knowledge of doctest and the location of the python tests.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org