code: public SelectQuery replaceVariables(final BindingSet bindings) {
  
          if (bindings.size() == 0) {
              return this;
          }
  
          // TODO: check whether the visitor code (taken from BindingAssigner) is enough, especially
          // w.r.t. variables appearing in projection nodes (= SELECT clause).
          final TupleExpr newExpression = this.expression.clone();
          newExpression.visit(new QueryModelVisitorBase<RuntimeException>() {
  
              @Override
              public void meet(final Var var) {
                  if (!var.hasValue() && bindings.hasBinding(var.getName())) {
                      final Value value = bindings.getValue(var.getName());
                      var.setValue(value);
                  }
              }
  
          });
  
          try {
              return from(newExpression, this.dataset);
          } catch (final ParseException ex) {
              throw new Error("Unexpected error - replacing variables made the query invalid (!)",
                      ex);
          }
      }
docs: Replaces some variables of this queries with the constant values specified, returning the
  resulting <tt>SelectQuery</tt> object.
  
  @param bindings
  the bindings to apply
  @return the resulting <tt>SelectQuery</tt> object (possibly <tt>this</tt> if no change is
  required).