Github user anabranch commented on the issue:

    https://github.com/apache/spark/pull/16138
  
    Now that my outputs are correct (in format), there's a new problem. The 
types are *still* wrong.
    
    ```
    scala> /////////// DETAILS
    
    scala> // Schema
    
    scala> spark.range(1).select(to_timestamp(lit("2016-12-31"), 
"yyyy-MM-dd")).schema
    // res4: org.apache.spark.sql.types.StructType = 
StructType(StructField(to_timestamp('2016-12-31', 
'yyyy-MM-dd'),StringType,true))
    
    scala> spark.range(1).select(to_date(lit("2016-12-31"), 
"yyyy-MM-dd")).schema
    // res5: org.apache.spark.sql.types.StructType = 
StructType(StructField(to_date('2016-12-31', 'yyyy-MM-dd'),StringType,true))
    ```
    
    Those should be `DateType` and `TimestampType` respectively.
    
    However if we inspect the expression directly, it seems that we do have the 
correct type.
    
    ```
    scala> import org.apache.spark.sql.catalyst.expressions.ParseToDate
    scala> val x = new ParseToDate(lit("hello").expr, lit("world").expr)
    x: org.apache.spark.sql.catalyst.expressions.ParseToDate = to_date(hello, 
world)
    
    scala> x.dataType
    res9: org.apache.spark.sql.types.DataType = DateType
    ```
    
    It seems to be getting lost somewhere.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to