[ https://issues.apache.org/jira/browse/PHOENIX-6215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
张嘉昊 updated PHOENIX-6215: ------------------------- Description: this is my sql: {code:java} //代码占位符 CREATE TABLE TEST4PHOENIX.MYTEST ( tag_id varchar(200) not null, user_id varchar(200) not null , tag_name varchar(200) null, is_delete tinyint default 0, CONSTRAINT pk PRIMARY KEY (tag_id, user_id) ) SALT_BUCKETS = 10 ; upsert into TEST4PHOENIX.MYTEST values('LB_001', '10077110', 'test', 0); upsert into TEST4PHOENIX.MYTEST values('LB_002', '10077110', 'test', 1); create local index MYTEST_INDEX on TEST4PHOENIX.MYTEST("TAG_NAME", "IS_DELETE");{code} I set column `is_delete` default 0. After I create a local index, I don't know if this is a bug, I find this below. select * from TEST4PHOENIX.MYTEST; ||TAG_ID||USER_ID||TAG_NAME||IS_DELETE|| |LB_001|10077110| test|0| |LB_002|10077110| test|1| select * from TEST4PHOENIX.MYTEST_INDEX; ||0:TAG_NAME||0:IS_DELETE||:TAG_ID||:USER_ID|| |test|0| |LB_00210077110| |test|0| |LB_00210077110| First, `is_delete` has 2 different values, but `MYTEST_INDEX` only shows 0, which is default value; Second, we can find that in `MYTEST_INDEX` column ''TAG_ID" and "USER_ID" values have been changed. If query sql uses index, then we may return wrong data. *While column value in `MYTEST` is right* Actually after I tried many times, I found that if I create a local index , including a column which may be `tinyint` or `integer` and has been set a dafault value, then the data in the index table will be wrong. Is this a bug or I make a mistake? was: this is my create table sql: ``` CREATE TABLE MODEL_GROUP_RULE_ACCOUNT.EMPLOYEE_LABEL_TRANSPOSITION_H ( tag_id varchar(200) not null, tag_name varchar(20000) null, user_id varchar(200) not null , user_name varchar(20000) null, tag_value varchar(1000) null, tag_type INTEGER null, version INTEGER not null default 1, create_time varchar(50) null, update_time varchar(50) null, ttl INTEGER null , sync2icome tinyint default 0, isdelete tinyint default 0, CONSTRAINT pk PRIMARY KEY (tag_id, user_id, version) ) SALT_BUCKETS = 10 ; ``` I set column `version` default 1, `sync2icome` default 0, `isdelete` default 0. After I create a local index, I don't know if this is a bug, I find this below. !image-2020-11-05-17-32-00-661.png|width=551,height=299! If I create local index on 2 columns, which are not set default value, that's ok; but if there is a column which has been set default value, then I select * from index_table , I find the data has been changed. Is this a bug or I make a mistake? Summary: Failed to create local index if I set column type is tinyint with default value (was: Failed to create local index if I set column default value ) > Failed to create local index if I set column type is tinyint with default > value > -------------------------------------------------------------------------------- > > Key: PHOENIX-6215 > URL: https://issues.apache.org/jira/browse/PHOENIX-6215 > Project: Phoenix > Issue Type: Bug > Components: core > Affects Versions: 5.0.0 > Environment: phoenix-5.0.0-cdh6.2.0 > Reporter: 张嘉昊 > Priority: Major > Attachments: image-2020-11-05-17-32-00-661.png > > > this is my sql: > {code:java} > //代码占位符 > CREATE TABLE TEST4PHOENIX.MYTEST ( > tag_id varchar(200) not null, > user_id varchar(200) not null , > tag_name varchar(200) null, > is_delete tinyint default 0, > CONSTRAINT pk PRIMARY KEY (tag_id, user_id) ) SALT_BUCKETS = 10 ; > > upsert into TEST4PHOENIX.MYTEST values('LB_001', '10077110', 'test', 0); > upsert into TEST4PHOENIX.MYTEST values('LB_002', '10077110', 'test', 1); > create local index MYTEST_INDEX on TEST4PHOENIX.MYTEST("TAG_NAME", > "IS_DELETE");{code} > I set column `is_delete` default 0. > After I create a local index, I don't know if this is a bug, I find this > below. > > select * from TEST4PHOENIX.MYTEST; > ||TAG_ID||USER_ID||TAG_NAME||IS_DELETE|| > |LB_001|10077110| test|0| > |LB_002|10077110| test|1| > > select * from TEST4PHOENIX.MYTEST_INDEX; > ||0:TAG_NAME||0:IS_DELETE||:TAG_ID||:USER_ID|| > |test|0| |LB_00210077110| > |test|0| |LB_00210077110| > > First, `is_delete` has 2 different values, but `MYTEST_INDEX` only shows 0, > which is default value; > Second, we can find that in `MYTEST_INDEX` column ''TAG_ID" and "USER_ID" > values have been changed. If query sql uses index, then we may return wrong > data. *While column value in `MYTEST` is right* > Actually after I tried many times, I found that if I create a local index , > including a column which may be `tinyint` or `integer` and has been set a > dafault value, then the data in the index table will be wrong. > > Is this a bug or I make a mistake? > -- This message was sent by Atlassian Jira (v8.3.4#803005)