private int findVariable(ExprNodeDesc expr) {
    int result = -1;
    List<ExprNodeDesc> children = expr.getChildren();
    for(int i = 0; i < children.size(); ++i) {
      ExprNodeDesc child = children.get(i);
      if (child instanceof ExprNodeColumnDesc) {
        // if we already found a variable, this isn't a sarg
        if (result != -1) {
          return -1;
        } else {
          result = i;
        }
      }
    }
    return result;
  }
Find the variable in the expression.
@param expr the expression to look in
@return the index of the variable or -1 if there is not exactly one
  variable.
ql/src/java/org/apache/hadoop/hive/ql/io/sarg/ConvertAstToSearchArg.java