fix countifs function

copied from https://issues.apache.org/bugzilla/show_bug.cgi?id=56822