private static TableDesc createTableDesc(InsertNode insertNode) { TableMeta meta = new TableMeta(insertNode.getStorageType(), insertNode.getOptions()); TableDesc tableDescTobeCreated = new TableDesc( insertNode.getTableName(), insertNode.getTableSchema(), meta, insertNode.getUri() != null ? insertNode.getUri() : null); if (insertNode.hasPartition()) { tableDescTobeCreated.setPartitionMethod(insertNode.getPartitionMethod()); } return tableDescTobeCreated; }
private static TableDesc createTableDesc(InsertNode insertNode) { TableMeta meta = new TableMeta(insertNode.getStorageType(), insertNode.getOptions()); TableDesc tableDescTobeCreated = new TableDesc( insertNode.getTableName(), insertNode.getTableSchema(), meta, insertNode.getUri() != null ? insertNode.getUri() : null); if (insertNode.hasPartition()) { tableDescTobeCreated.setPartitionMethod(insertNode.getPartitionMethod()); } return tableDescTobeCreated; }
public static TableDesc getTableDesc(CatalogService catalog, LogicalNode node) throws UndefinedTableException { if (node.getType() == NodeType.ROOT) { node = ((LogicalRootNode)node).getChild(); } if (node.getType() == NodeType.CREATE_TABLE) { return createTableDesc((CreateTableNode)node); } String tableName = null; InsertNode insertNode = null; if (node.getType() == NodeType.INSERT) { insertNode = (InsertNode)node; tableName = insertNode.getTableName(); } else { return null; } if (tableName != null) { String[] tableTokens = tableName.split("\\."); if (tableTokens.length >= 2) { if (catalog.existsTable(tableTokens[0], tableTokens[1])) { return catalog.getTableDesc(tableTokens[0], tableTokens[1]); } } } else { if (insertNode.getUri() != null) { //insert ... location return createTableDesc(insertNode); } } return null; }
public static TableDesc getTableDesc(CatalogService catalog, LogicalNode node) throws UndefinedTableException { if (node.getType() == NodeType.ROOT) { node = ((LogicalRootNode)node).getChild(); } if (node.getType() == NodeType.CREATE_TABLE) { return createTableDesc((CreateTableNode)node); } String tableName = null; InsertNode insertNode = null; if (node.getType() == NodeType.INSERT) { insertNode = (InsertNode)node; tableName = insertNode.getTableName(); } else { return null; } if (tableName != null) { String[] tableTokens = tableName.split("\\."); if (tableTokens.length >= 2) { if (catalog.existsTable(tableTokens[0], tableTokens[1])) { return catalog.getTableDesc(tableTokens[0], tableTokens[1]); } } } else { if (insertNode.getUri() != null) { //insert ... location return createTableDesc(insertNode); } } return null; }
InsertNode insertNode, SubmitQueryResponse.Builder responseBuilder) { try { String nodeUniqName = insertNode.getTableName() == null ? new Path(insertNode.getUri()).getName() : insertNode.getTableName(); String queryId = nodeUniqName + "_" + System.currentTimeMillis(); URI finalOutputUri = insertNode.getUri(); Tablespace space = TablespaceManager.get(finalOutputUri); TableMeta tableMeta = new TableMeta(insertNode.getStorageType(), insertNode.getOptions());
@Override public void hook(QueryContext queryContext, LogicalPlan plan) throws Exception { queryContext.setInsert(); InsertNode insertNode = plan.getRootBlock().getNode(NodeType.INSERT); // Set QueryContext settings, such as output table name and output path. // It also remove data files if overwrite is true. if (insertNode.hasTargetTable()) { // INSERT INTO [TB_NAME] queryContext.setOutputTable(insertNode.getTableName()); if (insertNode.hasPartition()) { queryContext.setPartitionMethod(insertNode.getPartitionMethod()); } } else { // INSERT INTO LOCATION ... // When INSERT INTO LOCATION, must not set output table. queryContext.setFileOutput(); } // Set the final output table uri queryContext.setOutputPath(insertNode.getUri()); if (insertNode.isOverwrite()) { queryContext.setOutputOverwrite(); } } }
InsertNode insertNode, SubmitQueryResponse.Builder responseBuilder) { try { String nodeUniqName = insertNode.getTableName() == null ? new Path(insertNode.getUri()).getName() : insertNode.getTableName(); String queryId = nodeUniqName + "_" + System.currentTimeMillis(); URI finalOutputUri = insertNode.getUri(); Tablespace space = TablespaceManager.get(finalOutputUri); TableMeta tableMeta = new TableMeta(insertNode.getStorageType(), insertNode.getOptions());
@Override public void hook(QueryContext queryContext, LogicalPlan plan) throws Exception { queryContext.setInsert(); InsertNode insertNode = plan.getRootBlock().getNode(NodeType.INSERT); // Set QueryContext settings, such as output table name and output path. // It also remove data files if overwrite is true. if (insertNode.hasTargetTable()) { // INSERT INTO [TB_NAME] queryContext.setOutputTable(insertNode.getTableName()); if (insertNode.hasPartition()) { queryContext.setPartitionMethod(insertNode.getPartitionMethod()); } } else { // INSERT INTO LOCATION ... // When INSERT INTO LOCATION, must not set output table. queryContext.setFileOutput(); } // Set the final output table uri queryContext.setOutputPath(insertNode.getUri()); if (insertNode.isOverwrite()) { queryContext.setOutputOverwrite(); } } }