private static Selector makeSelector(CFMetaData cfm, RawSelector raw, List<ColumnDefinition> defs, List<ColumnSpecification> metadata) throws InvalidRequestException
{
if (raw.selectable instanceof ColumnIdentifier)
{
ColumnDefinition def = cfm.getColumnDefinition((ColumnIdentifier)raw.selectable);
if (def == null)
throw new InvalidRequestException(String.format("Undefined name %s in selection clause", raw.selectable));
if (metadata != null)
metadata.add(raw.alias == null ? def : makeAliasSpec(cfm, def.type, raw.alias));
return new SimpleSelector(def.name.toString(), addAndGetIndex(def, defs), def.type);
}
else if (raw.selectable instanceof Selectable.WritetimeOrTTL)
{
Selectable.WritetimeOrTTL tot = (Selectable.WritetimeOrTTL)raw.selectable;
ColumnDefinition def = cfm.getColumnDefinition(tot.id);
if (def == null)
throw new InvalidRequestException(String.format("Undefined name %s in selection clause", tot.id));
if (def.isPrimaryKeyColumn())
throw new InvalidRequestException(String.format("Cannot use selection function %s on PRIMARY KEY part %s", tot.isWritetime ? "writeTime" : "ttl", def.name));
if (def.type.isCollection())
throw new InvalidRequestException(String.format("Cannot use selection function %s on collections", tot.isWritetime ? "writeTime" : "ttl"));
if (metadata != null)