phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Samarth Jain (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (PHOENIX-3454) ON DUPLICATE KEY construct doesn't work correctly when using lower case column names
Date Fri, 04 Nov 2016 20:34:58 GMT

     [ https://issues.apache.org/jira/browse/PHOENIX-3454?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Samarth Jain updated PHOENIX-3454:
----------------------------------
    Attachment: Screen Shot 2016-11-04 at 1.29.43 PM.png

See the attached debugger screenshot for PhoenixIndexBuilder.executeAtomicOp(). The reason
is because the the mutations returned by PRowImpl.toRowMutations() isn't returning a sorted
list of mutations. The code in PhoenixIndexBuilder.executeAtomicOp() inherently expects the
mutations to be sorted wrt column qualifier cells since it is doing the following:

{code}
for (Mutation source : mutations) {
                    flattenCells(source, flattenedCells);
                }
                tuple.setKeyValues(flattenedCells);
{code}

One option would be to sort the list of flattened cells over in PhoenixIndexBuilder before
setting in the tuple. But then PRowImpl.toRowMutations() is called in other places too. 

I ended up discovering this as part of my work for encoding column qualifiers where we use
the column qualifier "0" instead of "_0" for the empty key value column. 


> ON DUPLICATE KEY construct doesn't work correctly when using lower case column names
> ------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-3454
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3454
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Samarth Jain
>         Attachments: Screen Shot 2016-11-04 at 1.29.43 PM.png
>
>
> See this test case for a repro:
> {code}
> @Test
>     public void testDeleteOnSingleLowerCaseVarcharColumn() throws Exception {
>         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
>         Connection conn = DriverManager.getConnection(getUrl(), props);
>         conn.setAutoCommit(false);
>         String tableName = generateUniqueName();
>         String ddl = " create table " + tableName + "(pk varchar primary key, \"counter1\"
varchar, \"counter2\" smallint)";
>         conn.createStatement().execute(ddl);
>         String dml = "UPSERT INTO " + tableName + " VALUES('a','b') ON DUPLICATE KEY
UPDATE \"counter1\" = null";
>         conn.createStatement().execute(dml);
>         conn.createStatement().execute(dml);
>         conn.commit();
>         ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + tableName);
>         assertTrue(rs.next());
>         assertEquals("a",rs.getString(1));
>         assertEquals(null,rs.getString(2));
>         assertFalse(rs.next());
>         
>         dml = "UPSERT INTO " + tableName + " VALUES('a','b',0)";
>         conn.createStatement().execute(dml);
>         dml = "UPSERT INTO " + tableName + " VALUES('a','b', 0) ON DUPLICATE KEY UPDATE
\"counter1\" = null, \"counter2\" = \"counter2\" + 1";
>         conn.createStatement().execute(dml);
>         dml = "UPSERT INTO " + tableName + " VALUES('a','b', 0) ON DUPLICATE KEY UPDATE
\"counter1\" = 'c', \"counter2\" = \"counter2\" + 1";
>         conn.createStatement().execute(dml);
>         conn.commit();
>         rs = conn.createStatement().executeQuery("SELECT * FROM " + tableName);
>         assertTrue(rs.next());
>         assertEquals("a",rs.getString(1));
>         assertEquals("c",rs.getString(2));
>         assertEquals(2,rs.getInt(3));
>         assertFalse(rs.next());
>         conn.close();
>     }
> {code}
> After changing the column names to upper case (or removing the quotes), the test passes.
> FYI, [~jamestaylor]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message