Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21935#discussion_r206985120
  
    --- Diff: 
external/avro/src/main/scala/org/apache/spark/sql/avro/SchemaConverters.scala 
---
    @@ -103,31 +108,48 @@ object SchemaConverters {
           catalystType: DataType,
           nullable: Boolean = false,
           recordName: String = "topLevelRecord",
    -      prevNameSpace: String = ""): Schema = {
    +      prevNameSpace: String = "",
    +      outputTimestampType: String = "TIMESTAMP_MICROS"): Schema = {
         val builder = if (nullable) {
           SchemaBuilder.builder().nullable()
         } else {
           SchemaBuilder.builder()
         }
    +
         catalystType match {
           case BooleanType => builder.booleanType()
           case ByteType | ShortType | IntegerType => builder.intType()
           case LongType => builder.longType()
           case DateType => builder.longType()
    -      case TimestampType => builder.longType()
    +      case TimestampType =>
    +        val timestampType = outputTimestampType match {
    +          case "TIMESTAMP_MILLIS" => LogicalTypes.timestampMillis()
    --- End diff --
    
    don't hardcode the strings, we can write
    ```
    if (outputTimestampType == 
AvroOutputTimestampType.TIMESTAMP_MICROS.toString) ...
    ```


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to