Index: src/test/org/apache/hcatalog/listener/TestNotificationListener.java =================================================================== --- src/test/org/apache/hcatalog/listener/TestNotificationListener.java (revision 1140347) +++ src/test/org/apache/hcatalog/listener/TestNotificationListener.java (working copy) @@ -130,7 +130,7 @@ } else if(event.equals(HCatConstants.HCAT_ADD_TABLE_EVENT)){ - assertEquals("topic://HCAT.mydb",msg.getJMSDestination().toString()); + assertEquals("topic://hcat.mydb",msg.getJMSDestination().toString()); Table tbl = (Table)(((ObjectMessage)msg).getObject()); assertEquals("mytbl", tbl.getTableName()); assertEquals("mydb", tbl.getDbName()); @@ -138,7 +138,7 @@ } else if(event.equals(HCatConstants.HCAT_ADD_PARTITION_EVENT)){ - assertEquals("topic://HCAT.mydb.mytbl",msg.getJMSDestination().toString()); + assertEquals("topic://hcat.mydb.mytbl",msg.getJMSDestination().toString()); Partition part = (Partition)(((ObjectMessage)msg).getObject()); assertEquals("mytbl", part.getTableName()); assertEquals("mydb", part.getDbName()); @@ -148,7 +148,7 @@ } else if(event.equals(HCatConstants.HCAT_DROP_PARTITION_EVENT)){ - assertEquals("topic://HCAT.mydb.mytbl",msg.getJMSDestination().toString()); + assertEquals("topic://hcat.mydb.mytbl",msg.getJMSDestination().toString()); Partition part = (Partition)(((ObjectMessage)msg).getObject()); assertEquals("mytbl", part.getTableName()); assertEquals("mydb", part.getDbName()); @@ -158,7 +158,7 @@ } else if(event.equals(HCatConstants.HCAT_DROP_TABLE_EVENT)){ - assertEquals("topic://HCAT.mydb",msg.getJMSDestination().toString()); + assertEquals("topic://hcat.mydb",msg.getJMSDestination().toString()); Table tbl = (Table)(((ObjectMessage)msg).getObject()); assertEquals("mytbl", tbl.getTableName()); assertEquals("mydb", tbl.getDbName()); @@ -170,7 +170,7 @@ assertEquals("mydb", ((Database) ((ObjectMessage)msg).getObject()).getName()); } else if (event.equals(HCatConstants.HCAT_PARTITION_DONE_EVENT)) { - assertEquals("topic://HCAT.mydb.mytbl",msg.getJMSDestination().toString()); + assertEquals("topic://hcat.mydb.mytbl",msg.getJMSDestination().toString()); MapMessage mapMsg = (MapMessage)msg; assert mapMsg.getString("b").equals("2011"); } else Index: src/test/org/apache/hcatalog/cli/TestSemanticAnalysis.java =================================================================== --- src/test/org/apache/hcatalog/cli/TestSemanticAnalysis.java (revision 1140347) +++ src/test/org/apache/hcatalog/cli/TestSemanticAnalysis.java (working copy) @@ -44,6 +44,7 @@ import org.apache.hadoop.mapred.TextInputFormat; import org.apache.hcatalog.cli.SemanticAnalysis.HCatSemanticAnalyzer; import org.apache.hcatalog.common.HCatConstants; +import org.apache.hcatalog.listener.NotificationListener; import org.apache.hcatalog.rcfile.RCFileInputDriver; import org.apache.hcatalog.rcfile.RCFileOutputDriver; import org.apache.thrift.TException; @@ -57,6 +58,7 @@ @Override protected void setUp() throws Exception { + System.setProperty(ConfVars.METASTORE_EVENT_LISTENERS.varname, NotificationListener.class.getName()); HiveConf hcatConf = new HiveConf(this.getClass()); hcatConf.set(ConfVars.PREEXECHOOKS.varname, ""); hcatConf.set(ConfVars.POSTEXECHOOKS.varname, ""); @@ -64,7 +66,7 @@ HiveConf hiveConf = new HiveConf(hcatConf,this.getClass()); hiveDriver = new Driver(hiveConf); - + hcatConf.set(ConfVars.SEMANTIC_ANALYZER_HOOK.varname, HCatSemanticAnalyzer.class.getName()); hcatDriver = new Driver(hcatConf); @@ -75,6 +77,16 @@ String query; private final String tblName = "junit_sem_analysis"; + public void testCreateTblWithLowerCasePartNames() throws CommandNeedRetryException, MetaException, TException, NoSuchObjectException{ + hiveDriver.run("drop table junit_sem_analysis"); + CommandProcessorResponse resp = hiveDriver.run("create table junit_sem_analysis (a int) partitioned by (B string) stored as TEXTFILE"); + assertEquals(resp.getResponseCode(), 0); + assertEquals(null, resp.getErrorMessage()); + Table tbl = msc.getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName); + assertEquals("Partition key name case problem", "b" , tbl.getPartitionKeys().get(0).getName()); + hiveDriver.run("drop table junit_sem_analysis"); + } + public void testAlterTblFFpart() throws MetaException, TException, NoSuchObjectException, CommandNeedRetryException { hiveDriver.run("drop table junit_sem_analysis"); Index: src/java/org/apache/hcatalog/listener/NotificationListener.java =================================================================== --- src/java/org/apache/hcatalog/listener/NotificationListener.java (revision 1140347) +++ src/java/org/apache/hcatalog/listener/NotificationListener.java (working copy) @@ -33,7 +33,6 @@ import javax.jms.MapMessage; import javax.jms.Message; import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; import javax.jms.Session; import javax.naming.Context; import javax.naming.InitialContext; @@ -157,23 +156,28 @@ // by listening on a topic named "HCAT" and message selector string // as "HCAT_EVENT = HCAT_ADD_TABLE" if(tableEvent.getStatus()){ - if(tableEvent.getStatus()){ - Table tbl = tableEvent.getTable(); - Table newTbl = tbl.deepCopy(); - HMSHandler handler = tableEvent.getHandler(); - HiveConf conf = handler.getHiveConf(); + Table tbl = tableEvent.getTable(); + HMSHandler handler = tableEvent.getHandler(); + HiveConf conf = handler.getHiveConf(); + Table newTbl; + try { + newTbl = handler.get_table(tbl.getDbName(), tbl.getTableName()).deepCopy(); newTbl.getParameters().put(HCatConstants.HCAT_MSGBUS_TOPIC_NAME, - getTopicPrefix(conf) + "." + tbl.getDbName() +"." + tbl.getTableName()); - try { - handler.alter_table(tbl.getDbName(), tbl.getTableName(), newTbl); - } catch (InvalidOperationException e) { - throw new MetaException(e.toString()); - } - send(tableEvent.getTable(),getTopicPrefix(conf)+ "."+ tbl.getDbName(), HCatConstants.HCAT_ADD_TABLE_EVENT); + getTopicPrefix(conf) + "." + newTbl.getDbName() +"." + newTbl.getTableName()); + handler.alter_table(newTbl.getDbName(), newTbl.getTableName(), newTbl); + } catch (InvalidOperationException e) { + MetaException me = new MetaException(e.toString()); + me.initCause(e); + throw me; + } catch (NoSuchObjectException e) { + MetaException me = new MetaException(e.toString()); + me.initCause(e); + throw me; } - } + send(newTbl,getTopicPrefix(conf)+ "."+ newTbl.getDbName().toLowerCase(), HCatConstants.HCAT_ADD_TABLE_EVENT); + } } - + private String getTopicPrefix(HiveConf conf){ return conf.get(HCatConstants.HCAT_MSGBUS_TOPIC_PREFIX,HCatConstants.HCAT_DEFAULT_TOPIC_PREFIX); } @@ -194,7 +198,7 @@ sd.setSortCols(new ArrayList()); sd.setParameters(new HashMap()); sd.getSerdeInfo().setParameters(new HashMap()); - send(table,getTopicPrefix(tableEvent.getHandler().getHiveConf())+"."+table.getDbName(), HCatConstants.HCAT_DROP_TABLE_EVENT); + send(table,getTopicPrefix(tableEvent.getHandler().getHiveConf())+"."+table.getDbName().toLowerCase(), HCatConstants.HCAT_DROP_TABLE_EVENT); } } Index: src/java/org/apache/hcatalog/common/HCatConstants.java =================================================================== --- src/java/org/apache/hcatalog/common/HCatConstants.java (revision 1140347) +++ src/java/org/apache/hcatalog/common/HCatConstants.java (working copy) @@ -73,7 +73,7 @@ public static final String HCAT_MSGBUS_TOPIC_PREFIX = "hcat.msgbus.topic.prefix"; // Message Bus related properties. - public static final String HCAT_DEFAULT_TOPIC_PREFIX = "HCAT"; + public static final String HCAT_DEFAULT_TOPIC_PREFIX = "hcat"; public static final String HCAT_EVENT = "HCAT_EVENT"; public static final String HCAT_ADD_PARTITION_EVENT = "HCAT_ADD_PARTITION"; public static final String HCAT_DROP_PARTITION_EVENT = "HCAT_DROP_PARTITION";