本文整理了Java中com.datastax.driver.core.querybuilder.Select.groupBy()
方法的一些代码示例,展示了Select.groupBy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Select.groupBy()
方法的具体详情如下:
包路径:com.datastax.driver.core.querybuilder.Select
类名称:Select
方法名:groupBy
[英]Adds a GROUP BY clause to this statement.
Note: support for GROUP BY clause is only available from Cassandra 3.10 onwards.
[中]将GROUP BY子句添加到此语句中。
注:对GROUP BY子句的支持仅在Cassandra 3.10之后提供。
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Adds a {@code GROUP BY} clause to this statement.
*
* <p>Note: support for {@code GROUP BY} clause is only available from Cassandra 3.10 onwards.
*
* @param columns the columns to group by.
* @return the {@code SELECT} statement this {@code WHERE} clause is part of.
* @throws IllegalStateException if a {@code GROUP BY} clause has already been provided.
*/
public Select groupBy(Object... columns) {
return statement.groupBy(columns);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
assertThat(select().all().from("foo").groupBy("c1", column("c2"), raw("c3")).toString())
.isEqualTo("SELECT * FROM foo GROUP BY c1,c2,c3;");
assertThat(
.all()
.from("foo")
.groupBy("c1", column("c2"), raw("c3"))
.orderBy(asc("c1"))
.toString())
.isEqualTo("SELECT * FROM foo WHERE x=42 GROUP BY c1,c2,c3 ORDER BY c1 ASC;");
try {
select().all().from("foo").groupBy("foo").groupBy("bar");
fail("Should not allow GROUP BY twice");
} catch (IllegalStateException e) {
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
select("a", "b", "e", count("b"), max("e"))
.from(table)
.groupBy("a", "b")
.limit(2)))
.containsExactly(row(1, 2, 6, 2L, 12), row(1, 4, 12, 2L, 24));
select("a", "b", "e", count("b"), max("e"))
.from(table)
.groupBy("a", "b")
.perPartitionLimit(1)))
.containsExactly(row(1, 2, 6, 2L, 12), row(2, 2, 6, 1L, 6), row(4, 8, 24, 1L, 24));
select("a", "b", "e", count("b"), max("e"))
.from(table)
.groupBy("a", "b")
.perPartitionLimit(1)
.limit(2)))
assertThat(session().execute(select("a", count("a")).distinct().from(table).groupBy("a")))
.containsExactly(row(1, 1L), row(2, 1L), row(4, 1L));
session().execute(select("a", count("a")).distinct().from(table).groupBy("a").limit(2)))
.containsExactly(row(1, 1L), row(2, 1L));
session().execute(select().column("a").column("b").max("d").from(table).groupBy("a"));
fail("Expecting IQE");
} catch (InvalidQueryException e) {
assertThat(session().execute(select("a", "b", max("d")).from(table).groupBy("a", "b")))
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
assertThat(select().all().from("foo").groupBy("c1", column("c2"), raw("c3")).toString())
.isEqualTo("SELECT * FROM foo GROUP BY c1,c2,c3;");
assertThat(
.all()
.from("foo")
.groupBy("c1", column("c2"), raw("c3"))
.orderBy(asc("c1"))
.toString())
.isEqualTo("SELECT * FROM foo WHERE x=42 GROUP BY c1,c2,c3 ORDER BY c1 ASC;");
try {
select().all().from("foo").groupBy("foo").groupBy("bar");
fail("Should not allow GROUP BY twice");
} catch (IllegalStateException e) {
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
select("a", "b", "e", count("b"), max("e"))
.from(table)
.groupBy("a", "b")
.limit(2)))
.containsExactly(row(1, 2, 6, 2L, 12), row(1, 4, 12, 2L, 24));
select("a", "b", "e", count("b"), max("e"))
.from(table)
.groupBy("a", "b")
.perPartitionLimit(1)))
.containsExactly(row(1, 2, 6, 2L, 12), row(2, 2, 6, 1L, 6), row(4, 8, 24, 1L, 24));
select("a", "b", "e", count("b"), max("e"))
.from(table)
.groupBy("a", "b")
.perPartitionLimit(1)
.limit(2)))
assertThat(session().execute(select("a", count("a")).distinct().from(table).groupBy("a")))
.containsExactly(row(1, 1L), row(2, 1L), row(4, 1L));
session().execute(select("a", count("a")).distinct().from(table).groupBy("a").limit(2)))
.containsExactly(row(1, 1L), row(2, 1L));
session().execute(select().column("a").column("b").max("d").from(table).groupBy("a"));
fail("Expecting IQE");
} catch (InvalidQueryException e) {
assertThat(session().execute(select("a", "b", max("d")).from(table).groupBy("a", "b")))
内容来源于网络,如有侵权,请联系作者删除!