HyukjinKwon commented on code in PR #43369: URL: https://github.com/apache/spark/pull/43369#discussion_r1390507455
########## python/docs/source/user_guide/sql/type_conversions.rst: ########## @@ -0,0 +1,248 @@ +.. Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + +.. http://www.apache.org/licenses/LICENSE-2.0 + +.. Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +================================ +Python to Spark Type Conversions +================================ + +.. TODO: Add additional information on conversions when Arrow is enabled. +.. TODO: Add in-depth explanation and table for type conversions (SPARK-44734). + +.. currentmodule:: pyspark.sql.types + +When working with PySpark, you will often need to consider the conversions between Python-native +objects to their Spark equivalents. For instance, when working with user-defined functions, the +function return type will be cast by Spark to an appropriate Spark SQL type. Or, when creating a +``DataFrame``, you may supply ``numpy`` or ``pandas`` objects as the inputted data. This guide will cover +the various conversions between Python and Spark SQL types. + +Browsing Type Conversions +------------------------- + +Though this document provides a comprehensive list of type conversions, you may find it easier to +interactively check the conversion behavior of Spark. To do so, you can test small examples of +user-defined functions, and use the ``spark.createDataFrame`` interface. + +All data types of Spark SQL are located in the package of ``pyspark.sql.types``. +You can access them by doing: + +.. code-block:: python + + from pyspark.sql.types import * Review Comment: Let's avoid wildcards. It's discouraged according to PEP 8. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
