xinrong-meng commented on code in PR #46529:
URL: https://github.com/apache/spark/pull/46529#discussion_r1610489176


##########
python/pyspark/sql/connect/session.py:
##########
@@ -561,6 +568,28 @@ def createDataFrame(
                     cast(StructType, _deduplicate_field_names(schema)).names
                 ).cast(arrow_schema)
 
+        elif isinstance(data, pa.Table):
+            prefer_timestamp_ntz = is_timestamp_ntz_preferred()
+
+            (timezone,) = 
self._client.get_configs("spark.sql.session.timeZone")
+
+            # If no schema supplied by user then get the names of columns only
+            if schema is None:
+                _cols = data.column_names
+            if isinstance(schema, (list, tuple)) and cast(int, _num_cols) < 
len(data.columns):

Review Comment:
   nit:
   
   ```
               if isinstance(schema, (list, tuple)) and cast(int, _num_cols) < 
len(data.columns):
                   assert isinstance(_cols, list)
                   _cols.extend([f"_{i + 1}" for i in range(cast(int, 
_num_cols), len(data.columns))])
                   _num_cols = len(_cols)
   ```
   is uneasy to follow and duplicated, shall we extract and reuse, or add a 
comment to both to help understand? Feel free to do it in a separate PR



-- 
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]

Reply via email to