-
Notifications
You must be signed in to change notification settings - Fork 227
Support declaration of DEFAULT in CREATE statement #345
Comments
One complication is that a default value might be a constant expression, like CURRENT_DATE() which forces us to evaluate later. So we'll want to
|
I made little progress and would like few clarifications. column_def returns [ColumnDef ret] if(node instanceof LiteralParseNode){ c) Since the default values for a column need to be stored in SYSTEM.TABLE, how do we plan to support function definitions like CURRENT_DATE() . Though this is easy for LiteralExpressions, FunctionExpressions need a special look. d) Should we allow adding default values to dynamic columns also? |
This should cause the default value to be used when a column resolves to null. There are likely some edge cases for UPSERT SELECT and DELETE when they're executed on the server side that we'll have to work though, but hopefully this is enough to get you started. |
Hi James, |
Good point, @mravi. We'll need to treat these differently, evaluating them at UPSERT time and storing them. This will include CURRENT_DATE() and NEXT VALUE FOR (i.e. CurrentDateParseNode and NextSequenceValueParseNode). Need to come up with a way of differentiating these from constants - I'll give this some thought. |
@mravi - I've added an Expression.isDeterministic() for this case, and renamed isConstant() to be isStateless(). Note that ParseNode also has an isStateless() method, but doesn't need an isDeterministic method. An expression must be stateless in order to be a default expression. If a default expression for a KeyValue column is stateless and deterministic, then we can use the trick I mentioned about not storing the KeyValue with every row. If, however it is stateless and non deterministic, then we need to evaluate it upfront and store the value in the KeyValue at creation time. Thanks again for recognizing that we need to differentiate these cases! |
Support the declaration of a default value in the CREATE TABLE/VIEW statement like this:
To implement this, we'd need to:
The text was updated successfully, but these errors were encountered: