Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ycql] provide mechanism for batch operations to return finer-grained errors #347

Closed
kmuthukk opened this issue Jun 28, 2018 · 2 comments
Closed
Assignees
Labels
kind/enhancement This is an enhancement of an existing feature

Comments

@kmuthukk
Copy link
Collaborator

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                               |   |
@rao-vasireddy rao-vasireddy added the kind/enhancement This is an enhancement of an existing feature label Jun 28, 2018
yugabyte-ci pushed a commit that referenced this issue Jul 13, 2018
…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
@kmuthukk
Copy link
Collaborator Author

Implemented in: a38624b

@frozenspider
Copy link
Contributor

@kmuthukk , this feature seems to be un-documented

jasonyb pushed a commit that referenced this issue Jun 11, 2024
PG-575: Enable installcheck-world on PG 14 & 15.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement This is an enhancement of an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants