[
https://issues.apache.org/jira/browse/PHOENIX-3186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15423699#comment-15423699
]
James Taylor commented on PHOENIX-3186:
---------------------------------------
I'm having a hard time reproducing this. It may only occur for the
SYSTEM.CATALOG which isn't as important as it's under our control. Here's some
tests 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}
> Properties set in CREATE TABLE should be set on the HTableDescriptor, not the
> HColumnDescriptor
> -----------------------------------------------------------------------------------------------
>
> Key: PHOENIX-3186
> URL: https://issues.apache.org/jira/browse/PHOENIX-3186
> Project: Phoenix
> Issue Type: Bug
> Reporter: James Taylor
> Assignee: Samarth Jain
>
> Unless they're qualified with a column family, properties set in CREATE TABLE
> should be set on the HTableDescriptor, not the HColumnDescriptor. See this[1]
> comment in PHOENIX-3167.
> [1]
> https://issues.apache.org/jira/browse/PHOENIX-3167?focusedCommentId=15423596&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15423596
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)