很搞笑的在打麻将 2021-08-23 16:30 采纳率: 33.3%
浏览 46

cassandraTemplate 执行sql语句不能同时使用in 和 order by

在业务上我们要做一个根据markId分组并且按照collect_time 拿到最后一条数据
cassandraTemplate 执行sql

select mark_id, collect_time from temp_his where mark_id in (1,2,3) group by mark_id order by collect_time desc

提示报错
Cannot page queries with both ORDER BY and a IN restriction on the partition key; you must either remove the ORDER BY or the IN and sort client side, or disable paging for this query; nested exception is com.datastax.driver.core.exceptions.InvalidQueryException: Cannot page queries with both ORDER BY and a IN restriction on the partition key; you must either remove the ORDER BY or the IN and sort client side, or disable paging for this query

提示不能同时使用in 和 order by

  • 写回答

2条回答 默认 最新

  • CSDN专家-sinJack 2021-08-23 16:39
    关注

    无法对分区键同时使用ORDER BY和IN限制进行分页查询;您必须删除ORDER BY或IN并对客户端进行排序,或禁用此查询的分页;嵌套异常是com.datastax.driver.core.exceptions.InvalidQueryException:不能在分区键上同时使用ORDER BY和IN限制分页查询;您必须删除ORDER BY或IN并对客户端进行排序,或者禁用此查询的分页
    in 和 order by一起使用是肯定没问题的,只是你使用过程中违背了规则。

    评论

报告相同问题?

问题事件

  • 修改了问题 8月24日
  • 修改了问题 8月23日
  • 修改了问题 8月23日
  • 创建了问题 8月23日