private SQLResponse queryWithSqlMassage(SQLRequest sqlRequest) throws Exception { SQLResponse fakeResponse = QueryUtil.tableauIntercept(sqlRequest.getSql()); if (null != fakeResponse) { logger.debug("Return fake response, is exception? " + fakeResponse.getIsException()); return fakeResponse; } String correctedSql = QueryUtil.massageSql(sqlRequest); if (correctedSql.equals(sqlRequest.getSql()) == false) logger.debug("The corrected query: " + correctedSql); // add extra parameters into olap context, like acceptPartial Map<String, String> parameters = new HashMap<String, String>(); parameters.put( OLAPContext.PRM_ACCEPT_PARTIAL_RESULT, String.valueOf(sqlRequest.isAcceptPartial())); OLAPContext.setParameters(parameters); try { BackdoorToggles.setToggles(sqlRequest.getBackdoorToggles()); return execute(correctedSql, sqlRequest); } finally { BackdoorToggles.cleanToggles(); } }
private List<Pair<byte[], byte[]>> buildFuzzyKeys(Map<TblColRef, Set<String>> fuzzyValueSet) { ArrayList<Pair<byte[], byte[]>> result = new ArrayList<Pair<byte[], byte[]>>(); // debug/profiling purpose if (BackdoorToggles.getDisableFuzzyKey()) { logger.info("The execution of this query will not use fuzzy key"); return result; } FuzzyKeyEncoder fuzzyKeyEncoder = new FuzzyKeyEncoder(cubeSeg, cuboid); FuzzyMaskEncoder fuzzyMaskEncoder = new FuzzyMaskEncoder(cubeSeg, cuboid); List<Map<TblColRef, String>> fuzzyValues = FuzzyValueCombination.calculate(fuzzyValueSet, FUZZY_VALUE_CAP); for (Map<TblColRef, String> fuzzyValue : fuzzyValues) { result.add( new Pair<byte[], byte[]>( fuzzyKeyEncoder.encode(fuzzyValue), fuzzyMaskEncoder.encode(fuzzyValue))); } return result; }