private String removeOptionalTableReference(String name,QueryState state){
  if (name.contains(".")) {
    String head=name.split("\\.")[0];
    for (    QuerySource tr : state.getSources()) {
      if (tr.getAlias() != null && head.equals(tr.getAlias())) {
        return name.substring(name.indexOf('.') + 1);
      }
 else       if (head.equals(tr.getSource())) {
        return name.substring(name.indexOf('.') + 1);
      }
    }
  }
  return name;
}

private String removeOptionalTableReference ( String name , QueryState state ) { if ( name . contains ( "." ) ) { String head = name . split ( "\\." ) [ 0 ] ; for ( QuerySource tr : state . getSources ( ) ) { if ( tr . getAlias ( ) != null && head . equals ( tr . getAlias ( ) ) ) { return name . substring ( name . indexOf ( '.' ) + 1 ) ; } else if ( head . equals ( tr . getSource ( ) ) ) { return name . substring ( name . indexOf ( '.' ) + 1 ) ; } } } return name ; }
removes any field references which have an index prefix such as index . field1 . field2 which will become field1 . field2
