Hi Noam,
The reason you can't set a non primary key column as NOT NULL is
because Phoenix can't enforce it. When data is upsert, Phoenix doesn't
know if you're modifying existing data or inserting new data, as it
doesn't read the data before writing it. Phoenix can enforce a NOT
NULL constraint with a row key column because it always has the full
row key when we upsert.

For example, let's say that we allowed V2 to be declared as NOT NULL
and had the following UPSERT statement. We wouldn't know if you're
inserting new data (in which case it'd be invalid since V2 was not
supplied and is NOT NULL) or updating existing data (in which case
it'd be valid, as V2 would have been set when you inserted the data):

CREATE TABLE T (
    K VARCHAR PRIMARY KEY,
    V1 VARCHAR,
    V2 VARCHAR);
UPSERT INTO T(K,V1) VALUES('a','b');

Once transactions are implemented, we'll be able to support NOT NULL
on non pk columns, as well as be able to have INSERT and UPDATE
statements.

Thanks,
James

On Tue, Dec 16, 2014 at 9:39 PM, Bulvik, Noam <[email protected]> wrote:
> Hi,
>
>
>
> Any idea why it is not valid to set not null on a column that is not part of
> the primary key. Trying to set it will generate the error ERROR 517 (42895):
> Invalid not null constraint on non primary key column
>
>
>
> It make sense that some column that are not part of the primary key but
> still should not have null values
>
>
>
> Regards,
>
> Noam
>
> Information in this e-mail and its attachments is confidential and
> privileged under the TEOCO confidentiality terms that can be reviewed here.

Reply via email to