Examples of TableReference


Examples of com.google.api.services.bigquery.model.TableReference

  }

  public static Table createTable(String projectId, String datasetId, String tableId, TableSchema schema, Bigquery bigquery) throws IOException {
    Table table = new Table();

    TableReference tableRef = new TableReference();
    tableRef.setDatasetId(datasetId);
    tableRef.setProjectId(projectId);
    tableRef.setTableId(tableId);
    table.setTableReference(tableRef);
    table.setFriendlyName(tableId);
    table.setSchema(schema);

    try {
View Full Code Here

Examples of com.google.api.services.bigquery.model.TableReference

      loadConfig.setSourceUris(Arrays.asList(gsUrl));
      loadConfig.set("sourceFormat", "DATASTORE_BACKUP");
      loadConfig.set("allowQuotedNewlines", true);

      TableReference table = new TableReference();
      table.setProjectId(exporterConfig.getBigqueryProjectId());
      table.setDatasetId(exporterConfig.getBigqueryDatasetId());
      table.setTableId(kind + datatableSuffix);
      loadConfig.setDestinationTable(table);

      config.setLoad(loadConfig);
      job.setConfiguration(config);
      Insert insert = bigquery.jobs().insert(exporterConfig.getBigqueryProjectId(), job);
View Full Code Here

Examples of com.google.api.services.bigquery.model.TableReference

      sources.add(getFileUri(file));
    }

    loadConfig.setSourceUris(sources);

    TableReference tableRef = new TableReference();
    tableRef.setDatasetId(dataset);
    tableRef.setTableId(tableName);
    tableRef.setProjectId(projectId);
    loadConfig.setDestinationTable(tableRef);
    loadConfig.setSchema(schema.getValue());
    return job;
  }
View Full Code Here

Examples of org.apache.ws.jaxme.sqls.TableReference

   public boolean equals(Object o) {
      if (o == null  ||  !(o instanceof TableReference)) {
         return false;
      }
      TableReference ref = (TableReference) o;
      return ref.getStatement().equals(getStatement())  &&
             ref.getTable().equals(getTable());
   }
View Full Code Here

Examples of org.apache.ws.jaxme.sqls.TableReference

        Object o = iter.next();
        if (o instanceof Value) {
          target.addPart((Value) o);
        } else if (o instanceof ColumnReference) {
           ColumnReference colRef = (ColumnReference) o;
           TableReference tableRef = (TableReference) pMap.get(colRef.getTableReference());
           if (tableRef == null) {
             throw new IllegalStateException("Unknown reference to table " + colRef.getTableReference().getTable().getQName());
           }
           target.addPart(tableRef.newColumnReference(colRef.getColumn()));
        } else {
           throw new IllegalStateException("Unknown part type: " + o.getClass().getName());
        }
      }
    } else {
View Full Code Here

Examples of org.apache.ws.jaxme.sqls.TableReference

   }

   public SelectStatement getSelectStatement() {
      SelectStatement result = getSchema().getSQLFactory().newSelectStatement();
      result.setTable(this);
      TableReference ref = result.getTableReference();
      for (Iterator iter = getColumns();  iter.hasNext()) {
         Column column = (Column) iter.next();
         result.addResultColumn(new ColumnReferenceImpl(ref, column));
      }
      return result;
View Full Code Here

Examples of org.apache.ws.jaxme.sqls.TableReference

   }

  public UpdateStatement getUpdateStatement() {
    UpdateStatement result = getSchema().getSQLFactory().newUpdateStatement();
    result.setTable(this);
    TableReference ref = result.getTableReference();
    boolean hasPrimaryKey = false;
    for (Iterator iter = getColumns();  iter.hasNext()) {
      Column column = (Column) iter.next();
      if (column.isPrimaryKeyPart()) {
        hasPrimaryKey = true;
View Full Code Here

Examples of org.apache.ws.jaxme.sqls.TableReference

     Table otherTable = getForeignKeyTable(table);
     SelectStatement statement = otherTable.getSelectStatement();
     SelectTableReference tableReference = statement.getSelectTableReference();
     JoinReference joinReference = tableReference.join(table);

     TableReference refLocal = tableReference;
     TableReference refRef = tableReference.getRightJoinedTableReference();

     joinReference.getOn().addJoin((ForeignKey) otherTable.getForeignKeys().next(),
                                   refLocal, refRef);
     CombinedConstraint cc = statement.getWhere();
     BooleanConstraint bc = cc.createEQ();
View Full Code Here

Examples of org.apache.ws.jaxme.sqls.TableReference

     if (col.isVirtual()) {
       VirtualColumn virtCol = (VirtualColumn) col;
       return virtCol.getValue() + " AS " + s;
     } else {
       if (isQualifiedColumn(pColumnCounts, pColumn)) {
         TableReference tableReference = pColumn.getTableReference();
         if (tableReference.getAlias() != null) {
           s = tableReference.getAlias().getName() + "." + s;
         } else {
           s = tableReference.getTable().getName() + "." + s;
         }
       }

       if (pColumn.getAlias() != null) {
         s = s + " AS " + pColumn.getAlias().getName();
View Full Code Here

Examples of org.apache.ws.jaxme.sqls.TableReference

      }

      Map aliases = new HashMap();
      List tables = new ArrayList();
      for (Iterator tableIter = pQuery.getSelectTableReferences();  tableIter.hasNext()) {
         TableReference tableReference = (TableReference) tableIter.next();
         Table.Name alias = tableReference.getAlias();
         if (alias != null) {
            if (aliases.containsKey(alias.getName())) {
               throw new NullPointerException("The alias " + alias +
                                               " is used twice for the tables " +
                                               ((TableReference) aliases.get(alias)).getTable().getName() +
                                               " and " + tableReference.getTable().getName());
            }
            aliases.put(alias.getName(), tableReference);
         }
         tables.add(tableReference);
      }
      if (tables.size() > 1) {
         // Make sure that all tables have an alias
         for (Iterator iter = tables.iterator();  iter.hasNext()) {
            TableReference tableReference = (TableReference) iter.next();
            if (tableReference.getAlias() == null) {
               String alias = getUniqueAlias(tableReference.getTable().getName().getName(), aliases);
               aliases.put(alias, tableReference);
               if (!alias.equals(tableReference.getTable().getName().getName())) {
                  tableReference.setAlias(alias);
               }
            }
         }
      }

      // Create a Map of all column names, that may be referenced.
      // maps key is the column name, and the maps value is the
      // number of possible references. In other words: If an entry
      // in the map has a value > 1, then its column name must be
      // qualified, because it is used in multiple tables.
      Map columnNames = new HashMap();
      for (int i = 0;  i < tables.size();  i++) {
        TableReference table = (TableReference) tables.get(i);
        for (Iterator iter = table.getTable().getColumns();  iter.hasNext()) {
          Column col = (Column) iter.next();
          String key = col.getName().toString().toUpperCase();
          Integer num = (Integer) columnNames.get(key);
          if (num == null) {
            num = new Integer(1);
          } else {
            num = new Integer(num.intValue() + 1);
          }
          columnNames.put(key, num);
        }
      }

      Iterator columnIter = pQuery.getResultColumns();
      if (!columnIter.hasNext()) {
         sb.append(" *");
      } else {
         boolean first = true;
         do {
            ColumnReference column = (ColumnReference) columnIter.next();
            if (first) {
               sb.append(" ");
               first = false;
            } else {
               sb.append(", ");
            }
            sb.append(getColumnAlias(columnNames, column));
         } while (columnIter.hasNext());
      }

      if (tables.size() > 0) {
         sb.append(" FROM ");
         for (int i = 0;  i < tables.size();  i++) {
            TableReference table = (TableReference) tables.get(i);
            if (i == 0) {
               sb.append(getTableAlias(table));
            } else {
               sb.append(getJoinAlias(columnNames, (JoinReference) table));              
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.