为什么插入和 select 查询的结果集不同
Why is the ResultSet not same for insert and select queries
当我在 cassandra
中使用 session.execute
时,我注意到 ResultSet
的结构对于相同的 table 是不同的。如果我查询 table 以使用 Where
获取记录,则 ResultSet
包含从 table.
获取的数据
val resultSet = session.execute(whereClause)
给予
ResultSet[ exhausted: false, Columns[year(bigint), month(bigint),
creation_time_hour(bigint), creation_time_minute(bigint),
question_id(uuid), question_description(varchar)]]
但如果我使用 Insert
,我会得到完全不同的结果。
ResultSet[ exhausted: false, Columns[[applied](boolean)]]
这是预期的行为吗?有没有办法通过execute
方法返回的ResultSet
中的table中的cassandra
获取数据"inserted"?
通常,INSERT
不会 return 将插入的值返回给用户。例外是触发轻量级事务的插入 - 如果您使用 IF NOT EXISTS
。在这种情况下,它可能 return:
- 单行单列
[applied]
具有 true
值 - 这意味着已插入数据;
cqlsh:test> insert into test.u2(id,u) values(5, {id:1, t1:3}) if not exists;
[applied]
-----------
True
- 具有 table 对应行的所有值的单行,加上具有
false
值的列 [applied]
- 当具有给定主键的行已经存在时会发生这种情况。
cqlsh:test> insert into test.u2(id,u) values(1, {id:1, t1:2});
cqlsh:test> insert into test.u2(id,u) values(1, {id:1, t1:3}) if not exists;
[applied] | id | u
-----------+----+----------------
False | 1 | {id: 1, t1: 2}
当我在 cassandra
中使用 session.execute
时,我注意到 ResultSet
的结构对于相同的 table 是不同的。如果我查询 table 以使用 Where
获取记录,则 ResultSet
包含从 table.
val resultSet = session.execute(whereClause)
给予
ResultSet[ exhausted: false, Columns[year(bigint), month(bigint),
creation_time_hour(bigint), creation_time_minute(bigint),
question_id(uuid), question_description(varchar)]]
但如果我使用 Insert
,我会得到完全不同的结果。
ResultSet[ exhausted: false, Columns[[applied](boolean)]]
这是预期的行为吗?有没有办法通过execute
方法返回的ResultSet
中的table中的cassandra
获取数据"inserted"?
通常,INSERT
不会 return 将插入的值返回给用户。例外是触发轻量级事务的插入 - 如果您使用 IF NOT EXISTS
。在这种情况下,它可能 return:
- 单行单列
[applied]
具有true
值 - 这意味着已插入数据;
cqlsh:test> insert into test.u2(id,u) values(5, {id:1, t1:3}) if not exists;
[applied]
-----------
True
- 具有 table 对应行的所有值的单行,加上具有
false
值的列[applied]
- 当具有给定主键的行已经存在时会发生这种情况。
cqlsh:test> insert into test.u2(id,u) values(1, {id:1, t1:2});
cqlsh:test> insert into test.u2(id,u) values(1, {id:1, t1:3}) if not exists;
[applied] | id | u
-----------+----+----------------
False | 1 | {id: 1, t1: 2}