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

fanartoria commented on PHOENIX-6673:
-------------------------------------

The another question is: how does phoenix generate split keys.

The code is 
[SchemaUtil#processSplit|https://github.com/apache/phoenix/blob/a3015bd1de5acb7fdcbb03572c62fcfcb257d343/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java#L601]

This method wants to extend the length to match the schema. But seems work not 
as expected.
The first case works expecetly
{code:java}
# create table splittest1
create table splittest1(
    c1 varchar not null, 
    c2 integer not null, 
    c3 varchar not null, 
    c4 integer not null, 
    c5 integer,
    constraint pk primary key(c1, c2, c3, c4)
) split on(('10', 10, '10'));
# the split key is 10\x00\x80\x00\x00\x0A10\x00\x00\x00\x00\x00
# the last 5 byte 0: the first is for c3 varchar, others are for c4  integer(4 
bytes)
{code}
The test case may be wrong. Change the data type between c3 and c4.
{code:java}
# create table splittest2
create table splittest2(
    c1 varchar not null, 
    c2 integer not null, 
    c3 integer not null, 
    c4 varchar not null, 
    c5 integer,
    constraint pk primary key(c1, c2, c3, c4)
) split on(('10', 10, 10));
# the split key is 10\x00\x80\x00\x00\x0A\x80\x00\x00\x0A
# There is no extra byte 0 for c4.
{code}
Do we need concat another byte 0 for c4? Is that works as expected?

Maybe we can add some unit test.

> Local indexing broken by manually splitting table at arbitrary point
> --------------------------------------------------------------------
>
>                 Key: PHOENIX-6673
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6673
>             Project: Phoenix
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 5.2.0
>            Reporter: Istvan Toth
>            Priority: Major
>         Attachments: PHOENIX-6673-repro.patch
>
>
> While working on PHOENIX-6587, I found that splitting tables with local 
> indexes on certain points will break the local indexing code, and result in 
> incorrect query results.
> When a table is pre-split by Phoenix, or automatically split by HBase, then 
> split points always have a minimum length that is equal to the possible 
> minimum length of the table rowkey. 
> The automatic split always happens at an existing rowkey, and 
> SchemaUtil.processSplits() has code that approximates the same behaviour for 
> pre-split tables.
> However, it is still possible to split the table manually from HBase at 
> points that do not satisfy the above requirement, which breaks local indexing.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to