machielg commented on a change in pull request #25496:  [PYTHON][WIP] pyspark 
schema.toDDL() and DataType.fromDDL(ddl)
URL: https://github.com/apache/spark/pull/25496#discussion_r345157665
 
 

 ##########
 File path: python/pyspark/sql/types.py
 ##########
 @@ -92,6 +92,23 @@ def fromInternal(self, obj):
         """
         return obj
 
+    @Since(3.0)
+    def toDDL(self):
+        """
+        Returns a string containing a schema in DDL format.
+        """
+        sc = SparkContext._active_spark_context
+        dt = 
sc._jvm.__getattr__("org.apache.spark.sql.types.DataType$").__getattr__("MODULE$")
+        json = self.json()
+        return dt.fromJson(json).toDDL()
 
 Review comment:
   An alternative approach would be to call self._jdf.schema().toDDL(), similar 
to dataframe.printSchema(). This would diverge the APIs of Scala/Python but 
keep the implementation in Scala.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to