Fix use of CQL3 functions with descending clustering order

patch by slebresne; reviewed by iamaleksey for CASSANDRA-5472
This commit is contained in:
Sylvain Lebresne 2013-04-29 09:29:22 +02:00
parent 9851b73fc3
commit 7eae57aeac
2 changed files with 38 additions and 7 deletions

View File

@ -13,9 +13,10 @@
* Fix shutdown of binary protocol server (CASSANDRA-5507)
* Fix repair -snapshot not working (CASSANDRA-5512)
* Set isRunning flag later in binary protocol server (CASSANDRA-5467)
* Fix use of CQL3 functions with descencind clustering order (CASSANDRA-5472)
Merged from 1.1
* Add retry mechanism to OTC for non-droppable_verbs (CASSANDRA-5393)
* Use allocator information to improve memtable memory usage estimate
* Use allocator information to improve memtable memory usage estimate
(CASSANDRA-5497)
* Fix trying to load deleted row into row cache on startup (CASSANDRA-4463)

View File

@ -92,7 +92,7 @@ public abstract class Selection
throw new InvalidRequestException(String.format("Undefined name %s in selection clause", raw));
if (metadata != null)
metadata.add(name);
return new SimpleSelector(addAndGetIndex(name, names), name.type);
return new SimpleSelector(name.toString(), addAndGetIndex(name, names), name.type);
}
else if (raw instanceof RawSelector.WritetimeOrTTL)
{
@ -107,7 +107,7 @@ public abstract class Selection
if (metadata != null)
metadata.add(makeWritetimeOrTTLSpec(cfDef, tot));
return new WritetimeOrTTLSelector(addAndGetIndex(name, names), tot.isWritetime);
return new WritetimeOrTTLSelector(name.toString(), addAndGetIndex(name, names), tot.isWritetime);
}
else
{
@ -313,11 +313,13 @@ public abstract class Selection
private static class SimpleSelector implements Selector
{
private final String columnName;
private final int idx;
private final AbstractType<?> type;
public SimpleSelector(int idx, AbstractType<?> type)
public SimpleSelector(String columnName, int idx, AbstractType<?> type)
{
this.columnName = columnName;
this.idx = idx;
this.type = type;
}
@ -329,7 +331,13 @@ public abstract class Selection
public boolean isAssignableTo(ColumnSpecification receiver)
{
return type.equals(receiver.type);
return type.asCQL3Type().equals(receiver.type.asCQL3Type());
}
@Override
public String toString()
{
return columnName;
}
}
@ -355,17 +363,33 @@ public abstract class Selection
public boolean isAssignableTo(ColumnSpecification receiver)
{
return fun.returnType().equals(receiver.type);
return fun.returnType().asCQL3Type().equals(receiver.type.asCQL3Type());
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append(fun.name()).append("(");
for (int i = 0; i < argSelectors.size(); i++)
{
if (i > 0)
sb.append(", ");
sb.append(argSelectors.get(i));
}
return sb.append(")").toString();
}
}
private static class WritetimeOrTTLSelector implements Selector
{
private final String columnName;
private final int idx;
private final boolean isWritetime;
public WritetimeOrTTLSelector(int idx, boolean isWritetime)
public WritetimeOrTTLSelector(String columnName, int idx, boolean isWritetime)
{
this.columnName = columnName;
this.idx = idx;
this.isWritetime = isWritetime;
}
@ -386,6 +410,12 @@ public abstract class Selection
{
return receiver.type.asCQL3Type().equals(isWritetime ? CQL3Type.Native.BIGINT : CQL3Type.Native.INT);
}
@Override
public String toString()
{
return columnName;
}
}
private static class SelectionWithFunctions extends Selection