【发布时间】:2017-03-30 23:09:31
【问题描述】:
我在Cassandra table 中有一个timestamp 列,如何使用cql 从时间戳列中获取day of week?
【问题讨论】:
-
你不能在 cql 中做到这一点。您必须使用 java 或其他编程语言来执行此操作
我在Cassandra table 中有一个timestamp 列,如何使用cql 从时间戳列中获取day of week?
【问题讨论】:
没有开箱即用的支持,但是
如果必须使用 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,当你处理日期时,它会为你提供一周中的哪一天。
【讨论】: