[
https://issues.apache.org/jira/browse/PHOENIX-3167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15423709#comment-15423709
]
James Taylor commented on PHOENIX-3167:
---------------------------------------
I'm not seeing an issue, other than with the way we deal with
KEEP_DELETED_CELLS. Here are some test that all pass:
{code}
@Test
public void testUnqualifiedPropSetOnHTableDesc() throws Exception {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
String tableName = BaseTest.generateRandomString();
conn.createStatement().execute("create table " + tableName + "(k
varchar primary key) MY_PROP='1'");
try (HBaseAdmin admin =
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
HTableDescriptor tableDesc =
admin.getTableDescriptor(TableName.valueOf(tableName));
assertEquals("1", tableDesc.getValue("MY_PROP"));
HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
assertEquals("0", columnFamilies[0].getNameAsString());
assertNull(columnFamilies[0].getValue("MY_PROP"));
}
}
@Test
public void testUnqualifiedPropSetOnHTableDescForAlter() throws Exception {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
String tableName = BaseTest.generateRandomString();
String createTableStmt = "create table " + tableName + "(k varchar
primary key)";
conn.createStatement().execute(createTableStmt);
conn.createStatement().execute("alter table " + tableName + " set
MY_PROP='1'");
try (HBaseAdmin admin =
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
HTableDescriptor tableDesc =
admin.getTableDescriptor(TableName.valueOf(tableName));
assertEquals("1", tableDesc.getValue("MY_PROP"));
HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
assertEquals("0", columnFamilies[0].getNameAsString());
assertNull(columnFamilies[0].getValue("MY_PROP"));
}
}
@Test
public void testUnqualifiedPropSetOnHTableDescForAlterAndCreate() throws
Exception {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
String tableName = BaseTest.generateRandomString();
String createTableStmt = "create table " + tableName + "(k varchar
primary key)";
conn.createStatement().execute(createTableStmt);
conn.createStatement().execute("alter table " + tableName + " set
MY_PROP='1'");
try (HBaseAdmin admin =
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
HTableDescriptor tableDesc =
admin.getTableDescriptor(TableName.valueOf(tableName));
assertEquals("1", tableDesc.getValue("MY_PROP"));
HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
assertEquals("0", columnFamilies[0].getNameAsString());
assertNull(columnFamilies[0].getValue("MY_PROP"));
}
try {
conn.createStatement().execute(createTableStmt);
} catch (TableAlreadyExistsException e) {
}
try (HBaseAdmin admin =
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
HTableDescriptor tableDesc =
admin.getTableDescriptor(TableName.valueOf(tableName));
assertEquals("1", tableDesc.getValue("MY_PROP"));
HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
assertEquals("0", columnFamilies[0].getNameAsString());
assertNull(columnFamilies[0].getValue("MY_PROP"));
}
try {
conn.createStatement().execute(createTableStmt + " MY_PROP='0'");
} catch (TableAlreadyExistsException e) {
}
try (HBaseAdmin admin =
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
HTableDescriptor tableDesc =
admin.getTableDescriptor(TableName.valueOf(tableName));
assertEquals("0", tableDesc.getValue("MY_PROP"));
HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
assertEquals("0", columnFamilies[0].getNameAsString());
assertNull(columnFamilies[0].getValue("MY_PROP"));
}
}
{code}
> CREATE TABLE on an existing table resets the HTableMetadata
> -----------------------------------------------------------
>
> Key: PHOENIX-3167
> URL: https://issues.apache.org/jira/browse/PHOENIX-3167
> Project: Phoenix
> Issue Type: Bug
> Reporter: Samarth Jain
> Assignee: Samarth Jain
> Fix For: 4.8.1
>
> Attachments: PHOENIX-3167.patch
>
>
> {code}
> @Test
> public void testRecreatingExistingTableMaintainsHTableProperties() throws
> Exception {
> Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
> Connection conn = DriverManager.getConnection(getUrl(), props);
> String ddl = "ALTER TABLE SYSTEM.CATALOG SET KEEP_DELETED_CELLS =
> false";
> conn.createStatement().execute(ddl);
> assertDeleteCellsDisabled(conn);
> try {
>
> conn.createStatement().execute(QueryConstants.CREATE_TABLE_METADATA);
> } catch (TableAlreadyExistsException e) {
> }
> assertDeleteCellsDisabled(conn);
> }
>
> private void assertDeleteCellsDisabled(Connection conn) throws
> org.apache.hadoop.hbase.TableNotFoundException,
> IOException, SQLException {
> try (HBaseAdmin admin =
> conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
> HTableDescriptor tableDesc =
> admin.getTableDescriptor(Bytes.toBytes("SYSTEM.CATALOG"));
> HColumnDescriptor[] columnFamilies =
> tableDesc.getColumnFamilies();
> assertEquals("0", columnFamilies[0].getNameAsString());
> assertEquals(KeepDeletedCells.FALSE,
> columnFamilies[0].getKeepDeletedCells());
> }
> }
> {code}
> [~jamestaylor], [~apurtell], [~lhofhansl], [~mujtabachohan] - this is likely
> why we saw that the keep deleted cells property always kept flipping to true
> even though we set it to false in hbase shell.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)