コード例 #1
0
 // updates all expression specs which are evaluable
 public void updateEvaluables(String expr, CandidateTable cTable) throws SemanticException {
   String alias = cubeql.getAliasForTableName(cTable.getBaseTable().getName());
   ExpressionContext ec = getExpressionContext(expr, alias);
   if (cTable.getColumns().contains(expr)) {
     // expression is directly materialized in candidate table
     ec.addDirectlyAvailable(cTable);
   }
   for (ExprSpecContext esc : ec.allExprs) {
     if (esc.getTblAliasToColumns().get(alias) == null) {
       log.debug("{} = {} is evaluable in {}", expr, esc, cTable);
       ec.addEvaluable(cubeql, cTable, esc);
     } else {
       Set<String> columns = esc.getTblAliasToColumns().get(alias);
       boolean isEvaluable = true;
       for (String col : columns) {
         if (!cTable.getColumns().contains(col.toLowerCase())) {
           if (!cubeql
               .getDeNormCtx()
               .addRefUsage(cTable, col, cTable.getBaseTable().getName())) {
             // check if it is available as reference, if not expression is not evaluable
             log.debug("{} = {} is not evaluable in {}", expr, esc, cTable);
             isEvaluable = false;
             break;
           }
         }
       }
       if (isEvaluable) {
         log.debug("{} = {} is evaluable in {}", expr, esc, cTable);
         ec.addEvaluable(cubeql, cTable, esc);
       }
     }
   }
 }
コード例 #2
0
 private void pickExpressionsForTable(CandidateTable cTable) {
   for (Map.Entry<String, Set<ExpressionContext>> ecEntry : allExprsQueried.entrySet()) {
     Set<ExpressionContext> ecSet = ecEntry.getValue();
     for (ExpressionContext ec : ecSet) {
       if (ec.getSrcTable().getName().equals(cTable.getBaseTable().getName())) {
         if (!ec.directlyAvailableIn.contains(cTable)) {
           if (ec.evaluableExpressions.get(cTable) != null
               && !ec.evaluableExpressions.get(cTable).isEmpty()) {
             // pick first evaluable expression
             Set<PickedExpression> peSet = pickedExpressions.get(ecEntry.getKey());
             if (peSet == null) {
               peSet = new HashSet<PickedExpression>();
               pickedExpressions.put(ecEntry.getKey(), peSet);
             }
             peSet.add(
                 new PickedExpression(
                     ec.srcAlias, ec.evaluableExpressions.get(cTable).iterator().next()));
           }
         }
       }
     }
   }
 }
コード例 #3
0
 // checks if expr is evaluable
 public boolean isEvaluable(String expr, CandidateTable cTable) {
   ExpressionContext ec =
       getExpressionContext(expr, cubeql.getAliasForTableName(cTable.getBaseTable().getName()));
   return ec.isEvaluable(cTable);
 }