private TableWriterNode.WriterTarget createWriterTarget(TableWriterNode.WriterTarget target) { // TODO: begin these operations in pre-execution step, not here // TODO: we shouldn't need to store the schemaTableName in the handles, but there isn't a good way to pass this around with the current architecture if (target instanceof TableWriterNode.CreateName) { TableWriterNode.CreateName create = (TableWriterNode.CreateName) target; return new TableWriterNode.CreateHandle(metadata.beginCreateTable(session, create.getCatalog(), create.getTableMetadata(), create.getLayout()), create.getTableMetadata().getTable()); } if (target instanceof TableWriterNode.InsertReference) { TableWriterNode.InsertReference insert = (TableWriterNode.InsertReference) target; return new TableWriterNode.InsertHandle(metadata.beginInsert(session, insert.getHandle()), metadata.getTableMetadata(session, insert.getHandle()).getTable()); } if (target instanceof TableWriterNode.DeleteHandle) { TableWriterNode.DeleteHandle delete = (TableWriterNode.DeleteHandle) target; return new TableWriterNode.DeleteHandle(metadata.beginDelete(session, delete.getHandle()), delete.getSchemaTableName()); } throw new IllegalArgumentException("Unhandled target type: " + target.getClass().getSimpleName()); }
private TableWriterNode.WriterTarget createWriterTarget(TableWriterNode.WriterTarget target) { // TODO: begin these operations in pre-execution step, not here // TODO: we shouldn't need to store the schemaTableName in the handles, but there isn't a good way to pass this around with the current architecture if (target instanceof TableWriterNode.CreateName) { TableWriterNode.CreateName create = (TableWriterNode.CreateName) target; return new TableWriterNode.CreateHandle(metadata.beginCreateTable(session, create.getCatalog(), create.getTableMetadata(), create.getLayout()), create.getTableMetadata().getTable()); } if (target instanceof TableWriterNode.InsertReference) { TableWriterNode.InsertReference insert = (TableWriterNode.InsertReference) target; return new TableWriterNode.InsertHandle(metadata.beginInsert(session, insert.getHandle()), metadata.getTableMetadata(session, insert.getHandle()).getTable()); } if (target instanceof TableWriterNode.DeleteHandle) { TableWriterNode.DeleteHandle delete = (TableWriterNode.DeleteHandle) target; return new TableWriterNode.DeleteHandle(metadata.beginDelete(session, delete.getHandle()), delete.getSchemaTableName()); } throw new IllegalArgumentException("Unhandled target type: " + target.getClass().getSimpleName()); }
private HiveInsertTableHandle getHiveInsertTableHandle(Session session, String tableName) { Metadata metadata = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getMetadata(); return transaction(getQueryRunner().getTransactionManager(), getQueryRunner().getAccessControl()) .execute(session, transactionSession -> { QualifiedObjectName objectName = new QualifiedObjectName(catalog, TPCH_SCHEMA, tableName); Optional<TableHandle> handle = metadata.getTableHandle(transactionSession, objectName); InsertTableHandle insertTableHandle = metadata.beginInsert(transactionSession, handle.get()); HiveInsertTableHandle hiveInsertTableHandle = (HiveInsertTableHandle) insertTableHandle.getConnectorHandle(); metadata.finishInsert(transactionSession, insertTableHandle, ImmutableList.of(), ImmutableList.of()); return hiveInsertTableHandle; }); }
private HiveInsertTableHandle getHiveInsertTableHandle(Session session, String tableName) { Metadata metadata = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getMetadata(); return transaction(getQueryRunner().getTransactionManager(), getQueryRunner().getAccessControl()) .execute(session, transactionSession -> { QualifiedObjectName objectName = new QualifiedObjectName(catalog, TPCH_SCHEMA, tableName); Optional<TableHandle> handle = metadata.getTableHandle(transactionSession, objectName); InsertTableHandle insertTableHandle = metadata.beginInsert(transactionSession, handle.get()); HiveInsertTableHandle hiveInsertTableHandle = (HiveInsertTableHandle) insertTableHandle.getConnectorHandle(); metadata.finishInsert(transactionSession, insertTableHandle, ImmutableList.of(), ImmutableList.of()); return hiveInsertTableHandle; }); }