private RelationPlan createTableWriterPlan(Analysis analysis)
{
QualifiedTableName destination = analysis.getDestination();
TableHandle targetTable;
List<ColumnHandle> targetColumnHandles;
RelationPlan plan;
if (analysis.isDoRefresh()) {
// TODO: some of this should probably move to the analyzer, which should be able to compute the tuple descriptor for the source table from metadata
targetTable = metadata.getTableHandle(destination).get();
QualifiedTableName sourceTable = storageManager.getTableSource((NativeTableHandle) targetTable);
TableHandle sourceTableHandle = metadata.getTableHandle(sourceTable).get();
TableMetadata sourceTableMetadata = metadata.getTableMetadata(sourceTableHandle);
Map<String, ColumnHandle> sourceTableColumns = metadata.getColumnHandles(sourceTableHandle);
Map<String, ColumnHandle> targetTableColumns = metadata.getColumnHandles(targetTable);
ImmutableList.Builder<Symbol> outputSymbolsBuilder = ImmutableList.builder();