Yaoxuan Wu created SPARK-62223:
----------------------------------

             Summary: Spark Connect createDataFrame with TimeType(p) for p < 6 
fails with INVALID_COLUMN_OR_FIELD_DATA_TYPE (TIME(6) required to be TIME(p)) 
on master
                 Key: SPARK-62223
                 URL: https://issues.apache.org/jira/browse/SPARK-62223
             Project: Spark
          Issue Type: Bug
          Components: Connect, PySpark
    Affects Versions: 5.0.0
            Reporter: Yaoxuan Wu


On master, creating a DataFrame through Spark Connect with a TIME column of 
precision below 6 fails at analysis. Classic mode on master works, and so do 
classic and Connect on 4.2.0.

{code:python}
import datetime
from pyspark.sql import SparkSession
from pyspark.sql.types import StructType, StructField, TimeType, IntegerType

spark = SparkSession.builder.remote("local[2]").getOrCreate()      # Spark 
Connect
schema = StructType([StructField("t", TimeType(0)), StructField("k", 
IntegerType())])
spark.createDataFrame([[datetime.time(6, 9, 29), 1]], schema=schema).collect()
# expected: [Row(t=datetime.time(6, 9, 29), k=1)]   (as on 4.2.0, and in 
classic mode on master)
# actual:   AnalysisException: [INVALID_COLUMN_OR_FIELD_DATA_TYPE] Column or 
field `col_0` is of type
#           "TIME(6)" while it's required to be "TIME(0)". SQLSTATE: 42000
{code}

{noformat}
org.apache.spark.sql.AnalysisException: [INVALID_COLUMN_OR_FIELD_DATA_TYPE] 
Column or field `col_0` is of type "TIME(6)" while it's required to be 
"TIME(0)".
        at 
org.apache.spark.sql.errors.QueryCompilationErrors$.invalidColumnOrFieldDataTypeError(QueryCompilationErrors.scala:4451)
        at 
org.apache.spark.sql.catalyst.plans.logical.Project$.reconcileColumnType(basicLogicalOperators.scala:189)
        at 
org.apache.spark.sql.catalyst.plans.logical.Project$.$anonfun$reorderFields$1(basicLogicalOperators.scala:260)
{noformat}

* TimeType(3) fails the same way ("TIME(6)" required to be "TIME(3)"). 
TimeType(6) works.
* Master here is 5.0.0-SNAPSHOT at commit 4056f98 (2026-11-17), with the JVM 
and the Python client both built from that commit. Not reproducible on 4.2.0.
* The local relation seems to reach the server as TIME(6), apparently because 
the Arrow time type carries no precision. The projection to the declared schema 
then rejects TIME(6) -> TIME(p) instead of casting it, as 4.2.0 does. I have 
not bisected the change.

Related: SPARK-60547 (createDataFrame with TimeType(p) keeps more than p 
fractional digits).




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

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

Reply via email to