You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the current Apache Cassandra/CQL wire protocol, when an error occurs to a batch request, only a single error code can be returned.
To avoid extending the wire protocol and the client drivers, we should allow errors to be returned as a result row like how a conditional DML does when the condition is not satisfied.
For example, one possible syntax to flag the return status (success/failure) of a statement in "row" format would be:
INSERT INTO t (k, c) VALUES (2, 2) RETURNS STATUS AS ROW;
[applied] | [message] | k | c
-----------+--------------------------------------------+---+---
false | Duplicate value disallowed by unique index | 1 | 2
| k.t_unique_c | |
That way, if there's a batch of 10 such INSERT statements, we will get back 10 result rows:
for the successful ones [applied] column would be true and the other columns will be null;
for the failed ones the [applied] column would be false, and [message] provides the additional information on what the failure was due to (such as violation of a unique index constraint).
While this enhancement is primarily useful for batch operations, for symmetry, we should apply same logic for single statement (non-batch operations as well).
So, if an INSERT where going to cause an unique index violation, then an INSERT of the form:
INSERT INTO t (k, c) VALUES (2, 2)
would raise an error:
InvalidRequest: Error from server: code=2200 [Invalid query] message="SQL error: Execution Error. Duplicate value disallowed by unique index k.t_unique_c
whereas an INSERT of the form:
INSERT INTO t (k, c) VALUES (2, 2) RETURNS STATUS AS ROW;
would return a row result back (like Cassandra already does when IF NOT EXISTS clause is used).
[applied] | [message] | k | c
-----------+--------------------------------------------+---+---
false | Duplicate value disallowed by unique index | 1 | 2
| k.t_unique_c | |
The text was updated successfully, but these errors were encountered:
…ained errors
Summary:
- Add 'RETURNS STATUS AS ROW' clause for DML statements cause them to return an applied status
and report execution errors in a message column.
- Allow conditional DML statements in batches in case they all return status.
- Some fixes to error checking and inter-dependency logic for batches.
- Some grammar cleanup and fixes (remove redundant cases that could cause ambiguity/fatals).
Test Plan: jenkins, TestReturnsClause.java
Reviewers: neil, pritam.damania, robert
Reviewed By: robert
Subscribers: kannan, yql
Differential Revision: https://phabricator.dev.yugabyte.com/D5116
In the current Apache Cassandra/CQL wire protocol, when an error occurs to a batch request, only a single error code can be returned.
To avoid extending the wire protocol and the client drivers, we should allow errors to be returned as a result row like how a conditional DML does when the condition is not satisfied.
For example, one possible syntax to flag the return status (success/failure) of a statement in "row" format would be:
That way, if there's a batch of 10 such INSERT statements, we will get back 10 result rows:
While this enhancement is primarily useful for batch operations, for symmetry, we should apply same logic for single statement (non-batch operations as well).
So, if an INSERT where going to cause an unique index violation, then an INSERT of the form:
would raise an error:
whereas an INSERT of the form:
would return a row result back (like Cassandra already does when IF NOT EXISTS clause is used).
The text was updated successfully, but these errors were encountered: