public static SqlOpTable makeSelectOrTable(SqlOpTable node) {

    String alias = aliasGenerator.next();
    SqlOpTable result = new SqlOpTable(node.getSchema(), node.getTableName(), alias);

    return result;
  }
  /**
   * Builds up the one triple that states where the actual data for the target mapping comes from.
   * Such a source can be simply a database table or an SQL query.
   *
   * @param r2rml the target com.hp.hpl.jena.rdf.model.Model
   * @param relation the data source (table name or SQL query)
   * @return the whole Statement stating where the data comes from, e.g. '[] rr:tableName "EMP"'
   */
  private Statement buildLogicalTableTriple(Model r2rml, SqlOpBase relation) {
    // subject (a blank node [])
    Resource logicalTableSubject = ResourceFactory.createResource();
    // predicate (rr:tableName or rr:sqlQuery)
    Property logicalTablePredicate;
    // object (a Literal like "SELECT DEPTNO FROM DEPT WHERE DEPTNO > 23" or
    // simply a table name like "DEPTNO"
    Literal logicalTableObject;

    // it's a table
    if (relation instanceof SqlOpTable) {
      SqlOpTable tbl = (SqlOpTable) relation;
      logicalTablePredicate = ResourceFactory.createProperty(rrNamespace, "tableName");
      logicalTableObject = ResourceFactory.createPlainLiteral(tbl.getTableName());

      // it's a query
    } else if (relation instanceof SqlOpQuery) {
      SqlOpQuery query = (SqlOpQuery) relation;
      logicalTablePredicate = ResourceFactory.createProperty(rrNamespace, "sqlQuery");
      logicalTableObject = ResourceFactory.createPlainLiteral(query.getQueryString());

      // it's not possible
    } else {
      // should never be called since a relation can either be a table
      // or a query
      logicalTablePredicate = ResourceFactory.createProperty("");
      logicalTableObject = ResourceFactory.createPlainLiteral("");
    }

    Statement logicalTblStatement =
        r2rml.createStatement(logicalTableSubject, logicalTablePredicate, logicalTableObject);

    return logicalTblStatement;
  }
  public static SqlOpSelectBlock makeSelect(SqlOpTable node) {

    SqlOpTable opTable = makeSelectOrTable(node);

    SqlOpSelectBlock result = SqlOpSelectBlock.create(opTable);

    for (String columnName : opTable.getSchema().getColumnNames()) {
      result
          .getProjection()
          .put(columnName, new ExprVar(opTable.getAliasName() + "." + columnName));
    }

    return result;
  }