You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by "Daniel Wong (JIRA)" <ji...@apache.org> on 2019/04/27 00:36:00 UTC
[jira] [Commented] (PHOENIX-5262) Wrong Result on Salted table with
Varbinary PK
[ https://issues.apache.org/jira/browse/PHOENIX-5262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16827392#comment-16827392 ]
Daniel Wong commented on PHOENIX-5262:
--------------------------------------
The following E2E test shows a case I found while investigating a bug in our stats branch work. There is an incorrectly constructed scan upper range for the case of a Salted Table with a Varbinary PK. The is because ScanUtil does not properly check that this is the last PK column since the slotSpan is > 0 for this case.
{code:java}
@Test
public void testSaltedVarbinaryUpperBoundQuery() throws Exception {
String tableName = generateUniqueName();
String ddl = "CREATE TABLE " + tableName + " ( k VARBINARY PRIMARY KEY, a INTEGER ) SALT_BUCKETS = 3";
String dml = "UPSERT INTO " + tableName + " values (?, ?)";
String sql = "SELECT * FROM " + tableName ;
//Weird this actually makes a server rowkey filter to handle this rather than resolve constants client side =(
//String sql2 = "SELECT * FROM " + tableName + " WHERE k = CAST('2' AS VARBINARY)";
String sql2 = "SELECT * FROM " + tableName + " WHERE k = ?";
try (Connection conn = DriverManager.getConnection(getUrl())) {
conn.createStatement().execute(ddl);
PreparedStatement stmt = conn.prepareStatement(dml);
stmt.setInt(2,1);
stmt.setBytes(1,new byte[]{5});
stmt.executeUpdate();
stmt.setBytes(1,new byte[]{5,0});
stmt.executeUpdate();
stmt.setBytes(1,new byte[]{5,1});
stmt.executeUpdate();
conn.commit();
ResultSet rs = conn.createStatement().executeQuery(sql);
while(rs.next()){
System.out.println(String.format(" k = %s, a = %s",
Arrays.toString(rs.getBytes(1)),Integer.toString(rs.getInt(2))));
}
stmt = conn.prepareStatement(sql2);
stmt.setBytes(1, new byte[]{5});
rs = stmt.executeQuery();
while(rs.next()){
System.out.println(String.format(" k = %s, a = %s",
Arrays.toString(rs.getBytes(1)),Integer.toString(rs.getInt(2))));
}
//assertTrue(rs.next());
//assertFalse(rs.next());
}
}{code}
> Wrong Result on Salted table with Varbinary PK
> ----------------------------------------------
>
> Key: PHOENIX-5262
> URL: https://issues.apache.org/jira/browse/PHOENIX-5262
> Project: Phoenix
> Issue Type: Bug
> Reporter: Daniel Wong
> Assignee: Daniel Wong
> Priority: Major
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)