【问题标题】:Cassandra - How to get the Day of week from the timestamp column?Cassandra - 如何从时间戳列中获取星期几?
【发布时间】:2017-03-30 23:09:31
【问题描述】:

我在Cassandra table 中有一个timestamp 列,如何使用cql 从时间戳列中获取day of week

【问题讨论】:

  • 你不能在 cql 中做到这一点。您必须使用 java 或其他编程语言来执行此操作

标签: cassandra dayofweek


【解决方案1】:

没有开箱即用的支持,但是

如果必须使用 CQL,您可以查看用户定义函数:

http://cassandra.apache.org/doc/latest/cql/functions.html

http://www.datastax.com/dev/blog/user-defined-functions-in-cassandra-3-0

http://docs.datastax.com/en//cql/latest/cql/cql_using/useCreateUDF.html

那么你可以使用如下简单的东西:

How to determine day of week by passing specific date?

甚至是类似的东西

Aggregation with Group By date in Spark SQL

然后你有一个 UDF,当你处理日期时,它会为你提供一周中的哪一天。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    • 2014-04-10
    • 2014-07-10
    • 1970-01-01
    • 1970-01-01
    • 2017-04-08
    • 2017-02-18
    相关资源
    最近更新 更多