/** * Check if CTAS is already done * @param rootNode * @return */ private boolean checkIfCtasAlreadyDone(LogicalNode rootNode) { if (rootNode.getChild(0).getType() == NodeType.CREATE_TABLE) { CreateTableNode createTable = (CreateTableNode) rootNode.getChild(0); if (createTable.isIfNotExists() && catalog.existsTable(createTable.getTableName())) { return true; } } return false; }
/** * Check if CTAS is already done * @param rootNode * @return */ private boolean checkIfCtasAlreadyDone(LogicalNode rootNode) { if (rootNode.getChild(0).getType() == NodeType.CREATE_TABLE) { CreateTableNode createTable = (CreateTableNode) rootNode.getChild(0); if (createTable.isIfNotExists() && catalog.existsTable(createTable.getTableName())) { return true; } } return false; }
public static String getStoreTableName(LogicalPlan plan) { LogicalRootNode rootNode = plan.getRootBlock().getRoot(); NodeType nodeType = rootNode.getChild().getType(); if (nodeType == NodeType.CREATE_TABLE) { return ((CreateTableNode)rootNode.getChild()).getTableName(); } else if (nodeType == NodeType.INSERT) { return ((InsertNode)rootNode.getChild()).getTableName(); } else { return null; } }
public static String getStoreTableName(LogicalPlan plan) { LogicalRootNode rootNode = plan.getRootBlock().getRoot(); NodeType nodeType = rootNode.getChild().getType(); if (nodeType == NodeType.CREATE_TABLE) { return ((CreateTableNode)rootNode.getChild()).getTableName(); } else if (nodeType == NodeType.INSERT) { return ((InsertNode)rootNode.getChild()).getTableName(); } else { return null; } }
@Override public void hook(QueryContext queryContext, LogicalPlan plan) throws Exception { LogicalRootNode rootNode = plan.getRootBlock().getRoot(); CreateTableNode createTableNode = rootNode.getChild(); String [] splitted = IdentifierUtil.splitFQTableName(createTableNode.getTableName()); String tableName = splitted[1]; queryContext.setOutputTable(tableName); // set the final output table uri queryContext.setOutputPath(createTableNode.getUri()); if(createTableNode.getPartitionMethod() != null) { queryContext.setPartitionMethod(createTableNode.getPartitionMethod()); } queryContext.setCreateTable(); } }
@Override public void hook(QueryContext queryContext, LogicalPlan plan) throws Exception { LogicalRootNode rootNode = plan.getRootBlock().getRoot(); CreateTableNode createTableNode = rootNode.getChild(); String [] splitted = CatalogUtil.splitFQTableName(createTableNode.getTableName()); String databaseName = splitted[0]; String tableName = splitted[1]; queryContext.setOutputTable(tableName); // set the final output table uri queryContext.setOutputPath(createTableNode.getUri()); if(createTableNode.getPartitionMethod() != null) { queryContext.setPartitionMethod(createTableNode.getPartitionMethod()); } queryContext.setCreateTable(); } }
private static TableDesc createTableDesc(CreateTableNode createTableNode) { TableMeta meta = new TableMeta(createTableNode.getStorageType(), createTableNode.getOptions()); TableDesc tableDescTobeCreated = new TableDesc( createTableNode.getTableName(), createTableNode.getTableSchema(), meta, createTableNode.getUri() != null ? createTableNode.getUri() : null); tableDescTobeCreated.setExternal(createTableNode.isExternal()); if (createTableNode.hasPartition()) { tableDescTobeCreated.setPartitionMethod(createTableNode.getPartitionMethod()); } return tableDescTobeCreated; }
private static TableDesc createTableDesc(CreateTableNode createTableNode) { TableMeta meta = new TableMeta(createTableNode.getStorageType(), createTableNode.getOptions()); TableDesc tableDescTobeCreated = new TableDesc( createTableNode.getTableName(), createTableNode.getTableSchema(), meta, createTableNode.getUri() != null ? createTableNode.getUri() : null); tableDescTobeCreated.setExternal(createTableNode.isExternal()); if (createTableNode.hasPartition()) { tableDescTobeCreated.setPartitionMethod(createTableNode.getPartitionMethod()); } return tableDescTobeCreated; }
public TableDesc create(QueryContext queryContext, CreateTableNode createTable, boolean ifNotExists) throws IOException, TajoException { TableMeta meta; if (createTable.hasOptions()) { meta = CatalogUtil.newTableMeta(createTable.getStorageType(), createTable.getOptions()); } else { meta = CatalogUtil.newTableMeta(createTable.getStorageType(), queryContext.getConf()); } if(PlannerUtil.isFileStorageType(createTable.getStorageType()) && createTable.isExternal()){ Preconditions.checkState(createTable.hasUri(), "ERROR: LOCATION must be given."); } return create( queryContext, createTable.getTableName(), createTable.getTableSpaceName(), createTable.getTableSchema(), meta, createTable.getUri(), createTable.isExternal(), createTable.getPartitionMethod(), ifNotExists); }
public TableDesc create(QueryContext queryContext, CreateTableNode createTable, boolean ifNotExists) throws IOException, TajoException { TableMeta meta; if (createTable.hasOptions()) { meta = CatalogUtil.newTableMeta(createTable.getStorageType(), createTable.getOptions()); } else { meta = CatalogUtil.newTableMeta(createTable.getStorageType(), queryContext.getConf()); } if(PlannerUtil.isFileStorageType(createTable.getStorageType()) && createTable.isExternal()){ Preconditions.checkState(createTable.hasUri(), "ERROR: LOCATION must be given."); } return create( queryContext, createTable.getTableName(), createTable.getTableSpaceName(), createTable.getTableSchema(), meta, createTable.getUri(), createTable.isExternal(), createTable.getPartitionMethod(), ifNotExists); }
@Override public void execute(QueryMaster.QueryMasterContext context, QueryContext queryContext, Query query, ExecutionBlockId finalExecBlockId, Path finalOutputDir) throws Exception { CatalogService catalog = context.getWorkerContext().getCatalog(); Stage lastStage = query.getStage(finalExecBlockId); TableStats stats = lastStage.getResultStats(); CreateTableNode createTableNode = (CreateTableNode) lastStage.getBlock().getPlan(); TableMeta meta = new TableMeta(createTableNode.getStorageType(), createTableNode.getOptions()); TableDesc tableDescTobeCreated = new TableDesc( createTableNode.getTableName(), createTableNode.getTableSchema(), meta, finalOutputDir.toUri()); tableDescTobeCreated.setExternal(createTableNode.isExternal()); if (createTableNode.hasPartition()) { tableDescTobeCreated.setPartitionMethod(createTableNode.getPartitionMethod()); } if (query.hasUnionPlan()) { TableStats aggregated = query.aggregateTableStatsOfTerminalBlock(); tableDescTobeCreated.setStats(aggregated); } else { stats.setNumBytes(getTableVolume(query.systemConf, finalOutputDir)); tableDescTobeCreated.setStats(stats); } query.setResultDesc(tableDescTobeCreated); catalog.createTable(tableDescTobeCreated); } }
@Override public void execute(QueryMaster.QueryMasterContext context, QueryContext queryContext, Query query, ExecutionBlockId finalExecBlockId, Path finalOutputDir) throws Exception { CatalogService catalog = context.getWorkerContext().getCatalog(); Stage lastStage = query.getStage(finalExecBlockId); TableStats stats = lastStage.getResultStats(); CreateTableNode createTableNode = (CreateTableNode) lastStage.getBlock().getPlan(); TableMeta meta = new TableMeta(createTableNode.getStorageType(), createTableNode.getOptions()); TableDesc tableDescTobeCreated = new TableDesc( createTableNode.getTableName(), createTableNode.getTableSchema(), meta, finalOutputDir.toUri()); tableDescTobeCreated.setExternal(createTableNode.isExternal()); if (createTableNode.hasPartition()) { tableDescTobeCreated.setPartitionMethod(createTableNode.getPartitionMethod()); } if (query.hasUnionPlan()) { TableStats aggregated = query.aggregateTableStatsOfTerminalBlock(); tableDescTobeCreated.setStats(aggregated); } else { stats.setNumBytes(getTableVolume(query.systemConf, finalOutputDir)); tableDescTobeCreated.setStats(stats); } query.setResultDesc(tableDescTobeCreated); catalog.createTable(tableDescTobeCreated); } }
schema.setQualifier(createTableNode.getTableName()); createTableNode.setOutSchema(schema); createTableNode.setTableSchema(schema);
schema.setQualifier(createTableNode.getTableName()); createTableNode.setOutSchema(schema); createTableNode.setTableSchema(schema);