in phoenix5-hive/src/it/java/org/apache/hadoop/hive/ql/QTestUtil.java [735:792]
private boolean checkHadoopVersionExclude(String fileName, String query){
// Look for a hint to not run a test on some Hadoop versions
Pattern pattern = Pattern.compile("-- (EX|IN)CLUDE_HADOOP_MAJOR_VERSIONS\\((.*)\\)");
boolean excludeQuery = false;
boolean includeQuery = false;
Set<String> versionSet = new HashSet<String>();
String hadoopVer = ShimLoader.getMajorVersion();
Matcher matcher = pattern.matcher(query);
// Each qfile may include at most one INCLUDE or EXCLUDE directive.
//
// If a qfile contains an INCLUDE directive, and hadoopVer does
// not appear in the list of versions to include, then the qfile
// is skipped.
//
// If a qfile contains an EXCLUDE directive, and hadoopVer is
// listed in the list of versions to EXCLUDE, then the qfile is
// skipped.
//
// Otherwise, the qfile is included.
if (matcher.find()) {
String prefix = matcher.group(1);
if ("EX".equals(prefix)) {
excludeQuery = true;
} else {
includeQuery = true;
}
String versions = matcher.group(2);
for (String s : versions.split("\\,")) {
s = s.trim();
versionSet.add(s);
}
}
if (matcher.find()) {
//2nd match is not supposed to be there
String message = "QTestUtil: qfile " + fileName
+ " contains more than one reference to (EX|IN)CLUDE_HADOOP_MAJOR_VERSIONS";
throw new UnsupportedOperationException(message);
}
if (excludeQuery && versionSet.contains(hadoopVer)) {
System.out.println("QTestUtil: " + fileName
+ " EXCLUDE list contains Hadoop Version " + hadoopVer + ". Skipping...");
return true;
} else if (includeQuery && !versionSet.contains(hadoopVer)) {
System.out.println("QTestUtil: " + fileName
+ " INCLUDE list does not contain Hadoop Version " + hadoopVer + ". Skipping...");
return true;
}
return false;
}