Allow custom types in CLI's assume command

patch by xedin; reviewed by slebresne for CASSANDRA-4081
This commit is contained in:
Sylvain Lebresne 2012-03-30 10:33:29 +02:00
parent b85d44a25b
commit 7326ba8879
3 changed files with 17 additions and 8 deletions

View File

@ -14,6 +14,7 @@
* ensure that directory is selected for compaction for user-defined
tasks and upgradesstables (CASSANDRA-3985)
* fix NPE on invalid CQL delete command (CASSANDRA-3755)
* allow custom types in CLI's assume command (CASSANDRA-4081)
1.0.8

View File

@ -301,8 +301,8 @@ truncateStatement
;
assumeStatement
: ASSUME columnFamily assumptionElement=Identifier 'AS' defaultType=Identifier
-> ^(NODE_ASSUME columnFamily $assumptionElement $defaultType)
: ASSUME columnFamily assumptionElement=Identifier 'AS' entityName
-> ^(NODE_ASSUME columnFamily $assumptionElement entityName)
;
consistencyLevelStatement

View File

@ -1491,17 +1491,25 @@ public class CliClient
AbstractType comparator;
// Could be UTF8Type, IntegerType, LexicalUUIDType etc.
String defaultType = statement.getChild(2).getText();
String defaultType = CliUtils.unescapeSQLString(statement.getChild(2).getText());
try
{
comparator = Function.valueOf(defaultType.toUpperCase()).getValidator();
comparator = TypeParser.parse(defaultType);
}
catch (Exception e)
catch (ConfigurationException e)
{
String functions = Function.getFunctionNames();
sessionState.out.println("Type '" + defaultType + "' was not found. Available: " + functions);
return;
try
{
comparator = Function.valueOf(defaultType.toUpperCase()).getValidator();
}
catch (Exception ne)
{
String functions = Function.getFunctionNames();
sessionState.out.println("Type '" + defaultType + "' was not found. Available: " + functions
+ " Or any class which extends o.a.c.db.marshal.AbstractType.");
return;
}
}
// making string representation look property e.g. o.a.c.db.marshal.UTF8Type