本文整理了Java中com.datastax.driver.core.querybuilder.Select.getQueryString()
方法的一些代码示例,展示了Select.getQueryString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Select.getQueryString()
方法的具体详情如下:
包路径:com.datastax.driver.core.querybuilder.Select
类名称:Select
方法名:getQueryString
暂无
代码示例来源:origin: prestodb/presto
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns)
{
CassandraSplit cassandraSplit = (CassandraSplit) split;
List<CassandraColumnHandle> cassandraColumns = columns.stream()
.map(column -> (CassandraColumnHandle) column)
.collect(toList());
String selectCql = CassandraCqlUtils.selectFrom(cassandraSplit.getCassandraTableHandle(), cassandraColumns).getQueryString();
StringBuilder sb = new StringBuilder(selectCql);
if (sb.charAt(sb.length() - 1) == ';') {
sb.setLength(sb.length() - 1);
}
sb.append(cassandraSplit.getWhereClause());
String cql = sb.toString();
log.debug("Creating record set: %s", cql);
return new CassandraRecordSet(cassandraSession, cql, cassandraColumns);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/** @jira_ticket JAVA-1312 */
@Test(groups = "unit")
public void should_not_append_last_column_twice() throws Exception {
Select.SelectionOrAlias select = select().column("a").column("b");
Select fromUsers1 = select.from("users");
Select fromUsers2 = select.from("users");
assertThat(fromUsers1.getQueryString())
.isEqualTo(fromUsers2.getQueryString())
.isEqualTo("SELECT a,b FROM users;");
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* @test_category queries:builder
* @jira_ticket JAVA-1286
* @jira_ticket CASSANDRA-7423
*/
@Test(groups = "unit")
public void should_handle_retrieving_udt_fields() throws Exception {
assertThat(select().path("a", Metadata.quote("B")).raw("c.\"D\"").from("tbl").getQueryString())
.isEqualTo("SELECT a.\"B\",c.\"D\" FROM tbl;");
}
代码示例来源:origin: prestosql/presto
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns)
{
CassandraSplit cassandraSplit = (CassandraSplit) split;
List<CassandraColumnHandle> cassandraColumns = columns.stream()
.map(column -> (CassandraColumnHandle) column)
.collect(toList());
String selectCql = CassandraCqlUtils.selectFrom(cassandraSplit.getCassandraTableHandle(), cassandraColumns).getQueryString();
StringBuilder sb = new StringBuilder(selectCql);
if (sb.charAt(sb.length() - 1) == ';') {
sb.setLength(sb.length() - 1);
}
sb.append(cassandraSplit.getWhereClause());
String cql = sb.toString();
log.debug("Creating record set: %s", cql);
return new CassandraRecordSet(cassandraSession, cql, cassandraColumns);
}
代码示例来源:origin: com.facebook.presto/presto-cassandra
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns)
{
CassandraSplit cassandraSplit = (CassandraSplit) split;
List<CassandraColumnHandle> cassandraColumns = columns.stream()
.map(column -> (CassandraColumnHandle) column)
.collect(toList());
String selectCql = CassandraCqlUtils.selectFrom(cassandraSplit.getCassandraTableHandle(), cassandraColumns).getQueryString();
StringBuilder sb = new StringBuilder(selectCql);
if (sb.charAt(sb.length() - 1) == ';') {
sb.setLength(sb.length() - 1);
}
sb.append(cassandraSplit.getWhereClause());
String cql = sb.toString();
log.debug("Creating record set: %s", cql);
return new CassandraRecordSet(cassandraSession, cql, cassandraColumns);
}
代码示例来源:origin: scalar-labs/scalardb
@Override
@Nonnull
protected PreparedStatement prepare(Operation operation) {
checkArgument(operation, Get.class, Scan.class);
Select select = null;
if (operation instanceof Get) {
select = prepare((Get) operation);
} else {
select = prepare((Scan) operation);
}
return prepare(select.getQueryString());
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
.perPartitionLimit(bindMarker())
.limit(3)
.getQueryString(),
2))
.hasSize(3);
.perPartitionLimit(bindMarker())
.limit(3)
.getQueryString(),
2))
.hasSize(3);
.where(eq("a", bindMarker()))
.perPartitionLimit(bindMarker())
.getQueryString(),
2,
3))
.orderBy(desc("b"))
.perPartitionLimit(bindMarker())
.getQueryString(),
2,
3))
.perPartitionLimit(bindMarker())
.allowFiltering()
.getQueryString(),
2,
0,
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
/** @jira_ticket JAVA-1312 */
@Test(groups = "unit")
public void should_not_append_last_column_twice() throws Exception {
Select.SelectionOrAlias select = select().column("a").column("b");
Select fromUsers1 = select.from("users");
Select fromUsers2 = select.from("users");
assertThat(fromUsers1.getQueryString())
.isEqualTo(fromUsers2.getQueryString())
.isEqualTo("SELECT a,b FROM users;");
}
代码示例来源:origin: apache/streams
private String getSelectStatement() {
return QueryBuilder.select().all()
.from(config.getKeyspace(), config.getTable())
.getQueryString();
}
代码示例来源:origin: apifest/apifest-oauth20
@Override
public List<Scope> getAllScopes() {
List<Scope> list = new ArrayList<Scope>();
Select stmt = QueryBuilder.select().from(KEYSPACE_NAME, SCOPE_TABLE_NAME);
try {
ResultSet rs = session.execute(stmt);
for (Row row : rs) {
Scope scope = new Scope();
scope.setScope(row.getString("scope"));
scope.setDescription(row.getString("description"));
scope.setCcExpiresIn(row.getInt("cc_expires_in"));
scope.setPassExpiresIn(row.getInt("pass_expires_in"));
scope.setRefreshExpiresIn(row.getInt("refresh_expires_in"));
list.add(scope);
}
} catch (NoHostAvailableException e) {
log.error("No host in the %s cluster can be contacted to execute the query.\n",
session.getCluster());
} catch (QueryExecutionException e) {
log.error("An exception was thrown by Cassandra because it cannot " +
"successfully execute the query with the specified consistency level.");
} catch (QueryValidationException e) {
log.error(String.format("The query %s \nis not valid, for example, incorrect syntax.\n",
stmt.getQueryString()));
} catch (IllegalStateException e) {
log.error("The BoundStatement is not ready.");
}
return list;
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
/**
* @test_category queries:builder
* @jira_ticket JAVA-1286
* @jira_ticket CASSANDRA-7423
*/
@Test(groups = "unit")
public void should_handle_retrieving_udt_fields() throws Exception {
assertThat(select().path("a", Metadata.quote("B")).raw("c.\"D\"").from("tbl").getQueryString())
.isEqualTo("SELECT a.\"B\",c.\"D\" FROM tbl;");
}
代码示例来源:origin: apifest/apifest-oauth20
} catch (QueryValidationException e) {
log.error(String.format("The query %s \nis not valid, for example, incorrect syntax.\n",
stmt.getQueryString()));
} catch (IllegalStateException e) {
log.error("The BoundStatement is not ready.");
代码示例来源:origin: com.moz.fiji.schema/fiji-schema-cassandra
/**
* Prepare the statement for reading from the hash table.
*
* @param admin The Cassandra cluster connection.
* @param schemaHashTable The table name.
* @return A read statement for the hash table.
*/
private PreparedStatement prepareQueryReadHashTable(
final CassandraAdmin admin,
final CassandraTableName schemaHashTable
) {
final Select select =
QueryBuilder
.select(SCHEMA_COLUMN_VALUE)
.from(schemaHashTable.getKeyspace(), schemaHashTable.getTable())
.where(eq(SCHEMA_COLUMN_HASH_KEY, bindMarker()))
.orderBy(desc(SCHEMA_COLUMN_TIME))
.limit(1);
return admin.getPreparedStatement(select.getQueryString());
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
.perPartitionLimit(bindMarker())
.limit(3)
.getQueryString(),
2))
.hasSize(3);
.perPartitionLimit(bindMarker())
.limit(3)
.getQueryString(),
2))
.hasSize(3);
.where(eq("a", bindMarker()))
.perPartitionLimit(bindMarker())
.getQueryString(),
2,
3))
.orderBy(desc("b"))
.perPartitionLimit(bindMarker())
.getQueryString(),
2,
3))
.perPartitionLimit(bindMarker())
.allowFiltering()
.getQueryString(),
2,
0,
内容来源于网络,如有侵权,请联系作者删除!