Beispiel #1
0
 @Override
 public void visit(DerivedColumn obj) {
   if (obj.getExpression() instanceof Function) {
     visitNode(obj.getExpression());
   } else {
     ColumnReference column = (ColumnReference) obj.getExpression();
     this.selectedColumns.add(column.getMetadataObject().getName());
   }
 }
Beispiel #2
0
  public ObjectExecution(
      Select query,
      @SuppressWarnings("unused") RuntimeMetadata metadata,
      ObjectExecutionFactory factory,
      ObjectConnection connection,
      ExecutionContext executionContext)
      throws TranslatorException {
    this.factory = factory;
    this.query = query;
    this.connection = connection;
    this.executionContext = executionContext;

    projects = new ArrayList<CompiledScript>(query.getDerivedColumns().size());
    for (DerivedColumn dc : query.getDerivedColumns()) {
      ColumnReference cr = (ColumnReference) dc.getExpression();
      String name = null;
      if (cr.getMetadataObject() != null) {
        Column c = cr.getMetadataObject();
        name = getNameInSource(c);
      } else {
        name = cr.getName();
      }
      if (name.equalsIgnoreCase("this")) { // $NON-NLS-1$
        projects.add(null);
      } else {
        try {
          projects.add(scriptEngine.compile(OBJECT_NAME + "." + name)); // $NON-NLS-1$
        } catch (ScriptException e) {
          throw new TranslatorException(e);
        }
      }
    }
  }
  @Override
  public void visit(DerivedColumn obj) {
    this.currentAlias = buildAlias(obj.getAlias());
    visitNode(obj.getExpression());

    Column column = (Column) this.onGoingExpression.pop();

    String CF = column.getProperty(AccumuloMetadataProcessor.CF, false);
    String CQ = column.getProperty(AccumuloMetadataProcessor.CQ, false);
    if (CQ != null) {
      this.keybasedColumnMap.put(CF + "/" + CQ, column); // $NON-NLS-1$
    } else {
      this.keybasedColumnMap.put(CF, column);
    }

    // no expressions in select are allowed.
    this.selectColumns.add(column);
  }