@Override public DDF removeColumns(List<String> columnNames) throws DDFException { if (columnNames == null || columnNames.isEmpty()) throw new DDFException("columnNames must be specified"); List<String> currentColumnNames = this.getDDF().getColumnNames(); for(String columnName: columnNames) { if(!currentColumnNames.contains(columnName)) { throw new DDFException(String.format("Column %s does not exists", columnName)); } } List<String> columns = this.getDDF().getColumnNames(); for (String columnName : columnNames) { for (Iterator<String> it = columns.iterator();it.hasNext();) { if (it.next().equals(columnName)) { it.remove(); } } } DDF newddf = this.project(columns); if(this.getDDF().isMutable()) { this.getDDF().updateInplace(newddf); return this.getDDF(); } else { newddf.getMetaDataHandler().copyFactor(this.getDDF()); return newddf; } }
public DDF transformUDF(List<String> RExps, List<String> columns) throws DDFException { String sqlCmd = String.format("SELECT %s FROM %s", RToSqlUdf(RExps, columns, this.getDDF().getSchema().getColumns()), "{1}"); DDF newddf = this.getManager().sql2ddf(sqlCmd, new SQLDataSourceDescriptor(sqlCmd, null, null, null, this.getDDF() .getUUID().toString())); if (this.getDDF().isMutable()) { return this.getDDF().updateInplace(newddf); } else { newddf.getMetaDataHandler().copyFactor(this.getDDF()); return newddf; } }