コード例 #1
0
ファイル: Query.java プロジェクト: hyunsik/incubator-tajo
      @Override
      public void execute(
          QueryMaster.QueryMasterContext context,
          QueryContext queryContext,
          Query query,
          ExecutionBlockId finalExecBlockId,
          Path finalOutputDir)
          throws Exception {
        CatalogService catalog = context.getWorkerContext().getCatalog();
        SubQuery lastStage = query.getSubQuery(finalExecBlockId);
        TableMeta meta = lastStage.getTableMeta();
        TableStats stats = lastStage.getTableStat();

        CreateTableNode createTableNode = (CreateTableNode) lastStage.getBlock().getPlan();

        TableDesc tableDescTobeCreated =
            new TableDesc(
                createTableNode.getTableName(),
                createTableNode.getTableSchema(),
                meta,
                finalOutputDir);

        if (createTableNode.hasPartition()) {
          tableDescTobeCreated.setPartitionMethod(createTableNode.getPartitionMethod());
        }

        stats.setNumBytes(getTableVolume(query.systemConf, finalOutputDir));
        tableDescTobeCreated.setStats(stats);
        query.setResultDesc(tableDescTobeCreated);

        catalog.addTable(tableDescTobeCreated);
      }
コード例 #2
0
ファイル: Query.java プロジェクト: hyunsik/incubator-tajo
      @Override
      public void execute(
          QueryMaster.QueryMasterContext context,
          QueryContext queryContext,
          Query query,
          ExecutionBlockId finalExecBlockId,
          Path finalOutputDir)
          throws Exception {

        CatalogService catalog = context.getWorkerContext().getCatalog();
        SubQuery lastStage = query.getSubQuery(finalExecBlockId);
        TableMeta meta = lastStage.getTableMeta();
        TableStats stats = lastStage.getTableStat();

        InsertNode insertNode = (InsertNode) lastStage.getBlock().getPlan();

        TableDesc finalTable;
        if (insertNode.hasTargetTable()) {
          String tableName = insertNode.getTableName();
          finalTable = catalog.getTableDesc(tableName);
        } else {
          String tableName = query.getId().toString();
          finalTable = new TableDesc(tableName, lastStage.getSchema(), meta, finalOutputDir);
        }

        long volume = getTableVolume(query.systemConf, finalOutputDir);
        stats.setNumBytes(volume);
        finalTable.setStats(stats);

        if (insertNode.hasTargetTable()) {
          catalog.deleteTable(insertNode.getTableName());
          catalog.addTable(finalTable);
        }

        query.setResultDesc(finalTable);
      }