[ 
https://issues.apache.org/jira/browse/PHOENIX-5865?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17419119#comment-17419119
 ] 

ASF GitHub Bot commented on PHOENIX-5865:
-----------------------------------------

richardantal commented on a change in pull request #1321:
URL: https://github.com/apache/phoenix/pull/1321#discussion_r714669709



##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
##########
@@ -1641,9 +1641,6 @@ public MutationState createIndex(CreateIndexStatement 
statement, byte[][] splits
                     String columnFamilyName = column.getFamilyName()!=null ? 
column.getFamilyName().getString() : null;
                     colName = 
ColumnName.caseSensitiveColumnName(IndexUtil.getIndexColumnName(columnFamilyName,
 column.getName().getString()));
                     isRowTimestamp = column.isRowTimestamp();
-                    if (colRef.getColumn().getExpressionStr() != null) {
-                        expressionStr = colRef.getColumn().getExpressionStr();

Review comment:
       getExpressionStr() != null means we have a default value set for the 
column.
   We use this expressionStr to generate the indexExpressions later. 
https://github.com/apache/phoenix/blob/8c68fe435d0cc7d8bc69ccb05bc6536ba5647113/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java#L504-L506
   In case of a column that has default value, lets say 0 a LiteralExpression 
was created and it always returned 0. (instead of DefaultValueExpression)
   Because of this, in the index we wrote the default value always.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


> column that has default value can not be correctly indexed
> ----------------------------------------------------------
>
>                 Key: PHOENIX-5865
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-5865
>             Project: Phoenix
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 5.0.0
>            Reporter: junfei liang
>            Assignee: Richárd Antal
>            Priority: Major
>         Attachments: IndexWithDefaultIT.patch
>
>
> # create a table  with a column has default value
>       create table data_table(
>  pk VARCHAR, +
> c VARCHAR default '0',
> CONSTRAINT my_pk PRIMARY KEY (pk)
>       2.  insert data into it
>        upsert into data_table values('1','1')
>       3.  create an index  on the column
>         CREATE INDEX idx_data_table ON data_table(pk, c)
>       4.  check index table ,found data is wrong
>         select * from idx_data_table
>          found  0:c  column value is '0' , but it should be 1.
>  see attachment for details.  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to