You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "smiklosovic (via GitHub)" <gi...@apache.org> on 2025/02/26 20:20:08 UTC

[PR] CASSANDRA-20371 Deduplicate logic for validation of supported column types for constraints [cassandra]

smiklosovic opened a new pull request, #3935:
URL: https://github.com/apache/cassandra/pull/3935

   Thanks for sending a pull request! Here are some tips if you're new here:
    
    * Ensure you have added or run the [appropriate tests](https://cassandra.apache.org/_/development/testing.html) for your PR.
    * Be sure to keep the PR description updated to reflect all changes.
    * Write your PR title to summarize what this PR proposes.
    * If possible, provide a concise example to reproduce the issue for a faster review.
    * Read our [contributor guidelines](https://cassandra.apache.org/_/development/index.html)
    * If you're making a documentation change, see our [guide to documentation contribution](https://cassandra.apache.org/_/development/documentation.html)
    
   Commit messages should follow the following format:
   
   ```
   <One sentence description, usually Jira title or CHANGES.txt summary>
   
   <Optional lengthier description (context on patch)>
   
   patch by <Authors>; reviewed by <Reviewers> for CASSANDRA-#####
   
   Co-authored-by: Name1 <email1>
   Co-authored-by: Name2 <email2>
   
   ```
   
   The [Cassandra Jira](https://issues.apache.org/jira/projects/CASSANDRA/issues/)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20371 Deduplicate logic for validation of supported column types for constraints [cassandra]

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #3935:
URL: https://github.com/apache/cassandra/pull/3935#discussion_r1972362414


##########
src/java/org/apache/cassandra/cql3/constraints/ColumnConstraint.java:
##########
@@ -140,4 +142,37 @@ public void evaluate(AbstractType<?> valueType, ByteBuffer columnValue) throws C
      * @return the Constraint type serializer
      */
     public abstract ConstraintType getConstraintType();
+
+
+    /**
+     * Tells what types of columns are supported by this constraint.
+     * Returning empty list means that all types are supported.
+     *
+     * @return supported types for given constraint
+     */
+    public abstract List<AbstractType<?>> getSupportedTypes();

Review Comment:
   List for same reason as for operators above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20371 Deduplicate logic for validation of supported column types for constraints [cassandra]

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic closed pull request #3935: CASSANDRA-20371 Deduplicate logic for validation of supported column types for constraints
URL: https://github.com/apache/cassandra/pull/3935


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20371 Deduplicate logic for validation of supported column types for constraints [cassandra]

Posted by "bbotella (via GitHub)" <gi...@apache.org>.
bbotella commented on code in PR #3935:
URL: https://github.com/apache/cassandra/pull/3935#discussion_r1972562796


##########
src/java/org/apache/cassandra/cql3/constraints/AbstractFunctionConstraint.java:
##########
@@ -47,7 +47,7 @@ public String term()
         return term;
     }
 
-    public abstract Set<Operator> getSupportedOperators();
+    public abstract List<Operator> getSupportedOperators();

Review Comment:
   What about a middleground like
   https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/LinkedHashSet.html



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20371 Deduplicate logic for validation of supported column types for constraints [cassandra]

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #3935:
URL: https://github.com/apache/cassandra/pull/3935#discussion_r1972362801


##########
src/java/org/apache/cassandra/cql3/constraints/ColumnConstraint.java:
##########
@@ -140,4 +142,37 @@ public void evaluate(AbstractType<?> valueType, ByteBuffer columnValue) throws C
      * @return the Constraint type serializer
      */
     public abstract ConstraintType getConstraintType();
+
+
+    /**
+     * Tells what types of columns are supported by this constraint.
+     * Returning empty list means that all types are supported.
+     *
+     * @return supported types for given constraint
+     */
+    public abstract List<AbstractType<?>> getSupportedTypes();
+
+    protected void validateTypes(ColumnMetadata columnMetadata)
+    {
+        if (getSupportedTypes() == null || getSupportedTypes().isEmpty())

Review Comment:
   nullity check does not hurt, either null or empty



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20371 Deduplicate logic for validation of supported column types for constraints [cassandra]

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #3935:
URL: https://github.com/apache/cassandra/pull/3935#discussion_r1972361766


##########
src/java/org/apache/cassandra/cql3/constraints/AbstractFunctionConstraint.java:
##########
@@ -47,7 +47,7 @@ public String term()
         return term;
     }
 
-    public abstract Set<Operator> getSupportedOperators();
+    public abstract List<Operator> getSupportedOperators();

Review Comment:
   I reworked it to List because Set does not always preservers order and it might show in error messages etc and it is hard to test the exact output then.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Re: [PR] CASSANDRA-20371 Deduplicate logic for validation of supported column types for constraints [cassandra]

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #3935:
URL: https://github.com/apache/cassandra/pull/3935#discussion_r1972361766


##########
src/java/org/apache/cassandra/cql3/constraints/AbstractFunctionConstraint.java:
##########
@@ -47,7 +47,7 @@ public String term()
         return term;
     }
 
-    public abstract Set<Operator> getSupportedOperators();
+    public abstract List<Operator> getSupportedOperators();

Review Comment:
   I reworked it to List because Set does not always preserve order and it might show in error messages etc and it is hard to test the exact output then.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org