雪花显示错误的日期

发布于 2025-01-13 06:15:20 字数 221 浏览 1 评论 0原文

我正在尝试将日期列从 python 数据帧写入雪花。 但是,雪花在表中显示错误的值/年。

示例:

我尝试插入: 2010-10-15T00:00:00.000Z

雪花显示的内容: 40788570-09-06 17:00:00.000

当传递相同内容时在字符串数据类型中,它正确显示日期时间。 有人可以指导一下吗,谢谢。

I'm trying to write date column from my python dataframe to snowflake.
However, snowflake is displaying wrong values/year in the table.

Example:

I try to insert: 2010-10-15T00:00:00.000Z

What snowflake displays: 40788570-09-06 17:00:00.000

When the same is passed in String datatype, it displays the datetime correctly.
Can someone please guide, Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

染柒℉ 2025-01-20 06:15:21

Snowflake 有多种方法来解析纪元时间戳,我不熟悉 panda/python 方面如何让它快乐,但可以向您展示正在发生的事情。

SELECT '2010-10-15T00:00:00.000Z'::timestamp as t1,
    '40788570-09-06 17:00:00.000'::timestamp as t2,
    date_part(epoch_second, t1) as e1,
    date_part(epoch_second, t2) as e2,
    to_timestamp(e1) as tt1,
    to_timestamp(e2, 6) as tt2;
T1T2E1E2TT1TT2
2010-10-15 00:00:00.000无效日期1,287,100,8001,287,100,799,974,800 2010-10-15 00:00:00.0002010-10-14 23:59:59.974

基本上你的Python日期是纪元微秒,默认转换将其视为纪元秒,因此当使用正确的级别解析它时,它或多或少是正确的(这里是错误的,因为将未来的日期隐藏为 s 然后读到这是我们)。

Snowflake has a number of ways to parse epoch timestamps, I am not familiar with the panda/python side how to make it happy, but can show you what is happening.

SELECT '2010-10-15T00:00:00.000Z'::timestamp as t1,
    '40788570-09-06 17:00:00.000'::timestamp as t2,
    date_part(epoch_second, t1) as e1,
    date_part(epoch_second, t2) as e2,
    to_timestamp(e1) as tt1,
    to_timestamp(e2, 6) as tt2;
T1T2E1E2TT1TT2
2010-10-15 00:00:00.000Invalid date1,287,100,8001,287,100,799,974,800 2010-10-15 00:00:00.0002010-10-14 23:59:59.974

basically you python date is epoch_microsecond, and the default transform is treating it as epoch seconds, so when it's parsed with the correct level it's more or less correct (it's wrong here due to coverting the wildly future date to s and then read that is us)..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文