/** * It transforms table definition elements to schema. * * @param elements to be transformed * @return schema transformed from table definition elements */ private static Collection<Field> convertTableElementsSchema(ColumnDefinition[] elements) { ImmutableList.Builder<Field> list = ImmutableList.builder(); for (ColumnDefinition colDef : elements) { list.add(FieldConverter.convert(convertColumn(colDef))); } return list.build(); }
@Override public LogicalNode visitAlterTable(PlanContext context, Stack<Expr> stack, AlterTable alterTable) { AlterTableNode alterTableNode = context.queryBlock.getNodeFromExpr(alterTable); alterTableNode.setTableName(alterTable.getTableName()); alterTableNode.setNewTableName(alterTable.getNewTableName()); alterTableNode.setColumnName(alterTable.getColumnName()); alterTableNode.setNewColumnName(alterTable.getNewColumnName()); alterTableNode.setProperties(new KeyValueSet(alterTable.getParams())); List<String> propertyKeys = alterTable.getUnsetPropertyKeys(); if (null != propertyKeys) { alterTableNode.setUnsetPropertyKeys(propertyKeys.toArray(new String[propertyKeys.size()])); } if (null != alterTable.getAddNewColumn()) { alterTableNode.setAddNewColumn(convertColumn(alterTable.getAddNewColumn())); } if (alterTable.getColumns() != null) { alterTableNode.setPartitionColumns(convertColumnsToStrings(alterTable.getColumns())); } if (alterTable.getValues() != null) { alterTableNode.setPartitionValues(convertExprsToPartitionTableStringValues(alterTable.getValues())); } if (alterTable.getLocation() != null) { alterTableNode.setLocation(alterTable.getLocation()); } alterTableNode.setPurge(alterTable.isPurge()); alterTableNode.setIfNotExists(alterTable.isIfNotExists()); alterTableNode.setIfExists(alterTable.isIfExists()); alterTableNode.setAlterTableOpType(alterTable.getAlterTableOpType()); return alterTableNode; }
@Override public LogicalNode visitAlterTable(PlanContext context, Stack<Expr> stack, AlterTable alterTable) { AlterTableNode alterTableNode = context.queryBlock.getNodeFromExpr(alterTable); alterTableNode.setTableName(alterTable.getTableName()); alterTableNode.setNewTableName(alterTable.getNewTableName()); alterTableNode.setColumnName(alterTable.getColumnName()); alterTableNode.setNewColumnName(alterTable.getNewColumnName()); alterTableNode.setProperties(new KeyValueSet(alterTable.getParams())); if (null != alterTable.getAddNewColumn()) { alterTableNode.setAddNewColumn(convertColumn(alterTable.getAddNewColumn())); } if (alterTable.getColumns() != null) { alterTableNode.setPartitionColumns(convertColumnsToStrings(alterTable.getColumns())); } if (alterTable.getValues() != null) { alterTableNode.setPartitionValues(convertExprsToPartitionTableStringValues(alterTable.getValues())); } if (alterTable.getLocation() != null) { alterTableNode.setLocation(alterTable.getLocation()); } alterTableNode.setPurge(alterTable.isPurge()); alterTableNode.setIfNotExists(alterTable.isIfNotExists()); alterTableNode.setIfExists(alterTable.isIfExists()); alterTableNode.setAlterTableOpType(alterTable.getAlterTableOpType()); return alterTableNode; }
/** * It transforms table definition elements to schema. * * @param elements to be transformed * @return schema transformed from table definition elements */ private Schema convertColumnsToSchema(ColumnDefinition[] elements) { Schema schema = new Schema(); for (ColumnDefinition columnDefinition: elements) { schema.addColumn(convertColumn(columnDefinition)); } return schema; }
/** * It transforms table definition elements to schema. * * @param elements to be transformed * @return schema transformed from table definition elements */ private static Schema convertTableElementsSchema(ColumnDefinition[] elements) { Schema schema = new Schema(); for (ColumnDefinition columnDefinition: elements) { schema.addColumn(convertColumn(columnDefinition)); } return schema; }