cassandra icon indicating copy to clipboard operation
cassandra copied to clipboard

CASSANDRA-19947: Add constraints framework

Open bbotella opened this issue 1 year ago • 1 comments

Add new Constraints framework as described in CEP-42. This initial Jira ticket includes the core constraints length and numeric. Follow up tickets will include the rest of the constraints described in the CEP.

patch by Bernardo Botella; reviewed by <Reviewers> for CASSANDRA-19947

The Cassandra Jira

bbotella avatar Sep 23 '24 18:09 bbotella

My feedback on parser.g. https://github.com/yifan-c/cassandra/commit/1d78e80f364f7dd70d5c76298def125f478afe95

  • removed some redundant definitions
  • permit using check and length as column names

yifan-c avatar Oct 01 '24 22:10 yifan-c

Great work on this patch everyone; very impressed with it. I had a few follow up thoughts / questions after my 1st pass at review that I didn't add in the review comments:

  1. in-jvm dtest: Mixed version clusters (some nodes older w/out feature, some with)
  2. in-jvm dtest: Mixed feature enabled clusters (some nodes with feature / constraints enabled, some without). i.e. a case where schema didn't propagate on a change or raced w/someone altering a table w/constraints. This one might not be necessary in a post-TCM world actually; happy to learn if so. :)
  3. I don't recall seeing logic when I reviewed the patch to defer to a Guardrail being set in the event you tried to add a Constraint on that existing table. Did I miss that, or did we drop that (believe that was in the CEP)
  4. Was there unit testing around the unprepared json additions for constraint checking and I missed that?

jmckenzie-dev avatar Jan 16 '25 20:01 jmckenzie-dev

Thanks everyone for the feedback and comments @jmckenzie-dev @Maxwell-Guo @smiklosovic ! I think I addressed all the comments that were left on the code.

As per @jmckenzie-dev questions, let's go one by one.

  1. That's interesting! Can you point me to other part of the code where we are doing such tests? I'd like to take a look at them as an example to have something that covers this scenario.
  2. So, I don't think this feature will go out there in a release that won't come up with TCM as well right? Should we defer this scenario?
  3. The CEP mentions interaction with currently preexisting guardrails. I don't think it proposes having the feature hidden behind a guardrail?
  4. Json is covered with the integration tests in testConstraintWithJsonInsert.

bbotella avatar Jan 17 '25 15:01 bbotella

hello, @bbotella , do you think we need to add some test for DescribeStatementTest to see if the out put of the describe table is what we need ? Besides, Do we need cqlsh to support the ability to automatically complete the corresponding keywords for constraints and add the corresponding unit test? like here . @smiklosovic @jmckenzie-dev WDYT ?

Maxwell-Guo avatar Jan 20 '25 06:01 Maxwell-Guo

@Maxwell-Guo There is already tests covering the describe statement in the CreateTableWithColumnCqlConstraintValidationTest test class. Here:

https://github.com/apache/cassandra/pull/3562/files#diff-bb537e06c36f3dc9cfb0d52cfcbd75b609b51f5696c13f93f467a4b9fc79f483R50

I like the suggestion for the autocompletion. I will look into it.

bbotella avatar Jan 20 '25 07:01 bbotella

hello, @bbotella , do you think we need to add some test for DescribeStatementTest to see if the out put of the describe table is what we need ? Besides, Do we need cqlsh to support the ability to automatically complete the corresponding keywords for constraints and add the corresponding unit test? like here . @smiklosovic @jmckenzie-dev WDYT ?

I know there's some on the project that would advocate for adding a test to ensure the output of DESCRIBE TABLE meets some very ultra-specific string output for every given new feature or change. I've never been too convinced of the necessity of that, but adding something to DescribeStatementTest.java to cover the constraint output case would cover it if you want to.

Honestly, we probably should do things like that and this is something I just need to come around on. I find those kinds of tests a real slog to both write and to debug (just annoying nit-picky string formatting stuff that snapshots the state of things at a moment in time, etc)

jmckenzie-dev avatar Jan 24 '25 19:01 jmckenzie-dev

+1 from me.

jmckenzie-dev avatar Jan 24 '25 19:01 jmckenzie-dev

I will take another pass, since there are considerable amount of changes since my last review.

yifan-c avatar Jan 24 '25 19:01 yifan-c

+1 on green ci

Maxwell-Guo avatar Jan 27 '25 15:01 Maxwell-Guo

+1 from me to merge.

jmckenzie-dev avatar Jan 30 '25 14:01 jmckenzie-dev

+1 from me to merge.

jmckenzie-dev avatar Jan 30 '25 14:01 jmckenzie-dev