Consider performing the hive version check once and keeping reference to a Function instance which does this work for you. The Function impl is chosen based on result of version check.