// We need to find out the "FROM" target, and replace it with liveInstances
// / partitions etc
int fromIndex = sql.indexOf("FROM");
if (fromIndex == -1)
{
throw new HelixException("Query must contain FROM target. Query: " + sql);
}
// Per JoSql, select FROM <target> the target must be a object class that
// corresponds to a "table row"
// In out case, the row is always a ZNRecord
int nextSpace = sql.indexOf(" ", fromIndex);
while (sql.charAt(nextSpace) == ' ')
{
nextSpace++;
}
int nextnextSpace = sql.indexOf(" ", nextSpace);
if (nextnextSpace == -1)
{
nextnextSpace = sql.length();
}
String fromTarget = sql.substring(nextSpace, nextnextSpace).trim();
if (fromTarget.length() == 0)
{
throw new HelixException("FROM target in the query cannot be empty. Query: " + sql);
}
return fromTarget;
}