【问题标题】:What's the format of timestamp to write parquet file in go在go中写入parquet文件的时间戳格式是什么
【发布时间】:2019-06-10 22:08:18
【问题描述】:

我正在尝试在 Parquet 文件中编写 Go 结构并上传到 S3。我为结构中的时间戳参数指定什么格式和类型,以便雅典娜在从镶木地板文件读取时显示正确的时间戳。

type example struct {
     ID              int64  `parquet:"name=id, type=INT64"`
     CreatedAt       int64  `parquet:"name=created_at,type=TIMESTAMP_MILLIS"`
}

ex := example{}
ex.ID = int64(10)
ex.CreatedAt = time.Now().Unix()

fw, err := ParquetFile.NewLocalFileWriter("new.parquet")
pw, err := ParquetWriter.NewParquetWriter(fw, new(example), 1)
pw.Write(ex)

Upload the file new.parquet to S3

参考 - https://github.com/xitongsys/parquet-go。我在 Athena 中创建了一个带有 int 和时间戳字段的表,并尝试查询该表。日期显示类似于 - 1970-01-18 21:54:23.751。 与当前时间戳不匹配的位置。

【问题讨论】:

    标签: go parquet amazon-athena


    【解决方案1】:

    例如,

    package main
    
    import (
        "fmt"
        "time"
    )
    
    func main() {
        type example struct {
            CreatedAt int64 `parquet:"name=created_at,type=TIMESTAMP_MILLIS"`
        }
    
        ex := example{}
        ex.CreatedAt = time.Now().UnixNano() / int64(time.Millisecond)
        fmt.Println(ex.CreatedAt)
    }
    

    游乐场:https://play.golang.org/p/ePOlUKiT6fD

    输出:

    1257894000000
    

    【讨论】:

      猜你喜欢
      • 2019-10-19
      • 2013-12-25
      • 2013-05-11
      • 2018-11-15
      • 1970-01-01
      • 2022-10-07
      • 1970-01-01
      • 1970-01-01
      • 2012-09-27
      相关资源
      最近更新 更多