Istvan Toth created PHOENIX-6795:
------------------------------------
Summary: Default value evaluation happens in the read path
Key: PHOENIX-6795
URL: https://issues.apache.org/jira/browse/PHOENIX-6795
Project: Phoenix
Issue Type: Bug
Components: core
Affects Versions: 5.2.0
Reporter: Istvan Toth
At least in some cases, the default value for a column is getting evaluated
during read time.
This does not conform to the SQL standard, and results in incorrect behaviour:
{code:java}
create table test id integer primary key, int v1 default 20;
upsert into test (id, v1) values (1,1)
select v1 from test where id = 1;
-- results in 1, correct
upsert into test (id) values (2)
-- v1 is not stored
select v1 from test where id = 2;
-- results 1, correct, because default applied during read time
upsert into test (id, v1) values (3, null)
-- v1 is not stored
select v1 from test where id = 1;
-- results 1, which is INCORRECT, as a default shouldn't override an explicit
NULL value{code}
The correct behaviour would be resolving the default value during upsert, and
not doing any default processing during select queries.
I encountered specifically during testing a DATETIME column:
{noformat}
COLUMN_WITH_DEFAULT DATETIME DEFAULT DATETIME '2011-01-01 01:01:01'
{noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)