-
Notifications
You must be signed in to change notification settings - Fork 74
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
Constraints blog post #286
Open
bbotella
wants to merge
3
commits into
apache:trunk
Choose a base branch
from
bbotella:constraints-blog-post
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
site-content/source/modules/ROOT/pages/blog/Introducing-constraints-framework.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
= Upcoming Features: Constraints Framework | ||
:page-layout: single-post | ||
:page-role: blog-post | ||
:page-post-date: February 3, 2025 | ||
:page-post-author: Bernardo Botella Corbi | ||
:description: The Apache Cassandra Community | ||
:keywords: | ||
|
||
Cassandra has had limited tools to handle value limits and rules when writing data to tables. The Constraints Framework positions itself as a centerpiece, providing an easy approach to define rules that give flexibility to both Cassandra users and operators by adding a framework for generic checks at write time. | ||
|
||
Up until now, Cassandra users have relied on limited tools to manage value limits and enforce rules during data writing. Now, with the introduction of the Constraints Framework, Cassandra is able to offer users and operators unprecedented flexibility and control. Here’s everything you need to know about this groundbreaking feature. | ||
|
||
== What is the Constraints Framework? | ||
|
||
The Constraints Framework, introduced through https://cwiki.apache.org/confluence/display/CASSANDRA/CEP-42:+Constraints+Framework[CEP-42,window=_blank], is designed to allow Cassandra users to define rules that validate data at write time. By incorporating these checks, operators can gain: | ||
|
||
* Improved Data Governance: Better control and reasoning about data quality. | ||
* Predictable Performance: Easier tuning for performance and maintenance due to predictable partition sizes. | ||
* Future-Ready Extensibility: The framework lays the groundwork for advanced validations in the future. | ||
* Enhanced Storage Efficiency: Potential for smarter decisions in the storage engine based on data size. | ||
|
||
If you want to know more details, please follow the https://lists.apache.org/thread/xc2phmxgsc7t3y9b23079vbflrhyyywj[dev thread,window=_blank]. | ||
|
||
== What's new? | ||
|
||
Cassandra Query Language (CQL) now includes syntax for defining, altering, and dropping constraints directly within column definitions. Here are some examples: | ||
|
||
---- | ||
CREATE TABLE keyspace.table ( | ||
name text, | ||
i int CHECK (condition) | ||
..., | ||
); | ||
---- | ||
|
||
Altering Existing Constraints: | ||
---- | ||
ALTER TABLE [IF EXISTS] <table> ALTER [IF EXISTS] <column> CHECK <condition>; | ||
---- | ||
Dropping Constraints: | ||
---- | ||
ALTER TABLE [IF EXISTS] <table> ALTER [IF EXISTS] <column> DROP CHECK; | ||
---- | ||
|
||
== Built-in Constraints | ||
|
||
This initial rollout introduces two powerful constraints. | ||
|
||
=== Scalar Constraint | ||
This Constraint defines comparison against a numeric type input by the Cassandra user. For example, if the table schema was defined with: | ||
---- | ||
i int CHECK i < 1000 | ||
---- | ||
A Cassandra user trying to write a row with a value for “i” bigger or equal than 1000 would fail. All the regular comparisons between numeric types are supported out of the box. | ||
|
||
=== Length Constraint | ||
Length Constraint allows the owner of the Cassandra schema to define a condition for the length of a field of any text or binary type. For example: | ||
---- | ||
n text CHECK LENGTH(n) < 256 | ||
---- | ||
Would prevent any Cassandra user from writing a value for “n” which is equal or bigger than 256 characters, allowing schema owners to limit the row sizes being written to the database. | ||
|
||
== Why it matters | ||
The introduction of constraints addresses several long-standing gaps in Cassandra’s feature set. By embedding these validations at the database level, users can reduce application-level checks, streamline operations, and enjoy a smoother experience when managing data integrity. Moreover, it aligns Cassandra closer to other database solutions that already offer such capabilities. | ||
|
||
== Conclusion | ||
|
||
The Constraints Framework is a new addition to Cassandra, empowering users and operators with the tools they need to maintain healthy, efficient, and reliable databases. Whether you’re tuning performance, enforcing data quality, or preparing for future needs, this new feature offers the flexibility Cassandra users should expect. | ||
For more details, check out the link:++https://cwiki.apache.org/confluence/display/CASSANDRA/CEP-42:+Constraints+Framework[CEP-42,window=_blank]++[CEP-42] and the link:++https://lists.apache.org/thread/xc2phmxgsc7t3y9b23079vbflrhyyywj[dev thread,window=_blank]++[discussion thread]. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if these were actual examples. If we only want to show syntax, we should change the sentence to "Here is the syntax on how to use constraints in CQL:". I would prefer an actual example here, with a link to a CQL doc showing syntax.