use of org.apache.spark.sql.catalyst.expressions.GenericRow in project zeppelin by apache.
the class Spark2Shims method getAsDataFrame.
@Override
public Dataset<Row> getAsDataFrame(String value) {
String[] lines = value.split("\\n");
String head = lines[0];
String[] columns = head.split("\t");
StructType schema = new StructType();
for (String column : columns) {
schema = schema.add(column, "String");
}
List<Row> rows = new ArrayList<>();
for (int i = 1; i < lines.length; ++i) {
String[] tokens = lines[i].split("\t");
Row row = new GenericRow(tokens);
rows.add(row);
}
return sparkSession.createDataFrame(rows, schema);
}
use of org.apache.spark.sql.catalyst.expressions.GenericRow in project zeppelin by apache.
the class Spark3Shims method getAsDataFrame.
@Override
public Dataset<Row> getAsDataFrame(String value) {
String[] lines = value.split("\\n");
String head = lines[0];
String[] columns = head.split("\t");
StructType schema = new StructType();
for (String column : columns) {
schema = schema.add(column, "String");
}
List<Row> rows = new ArrayList<>();
for (int i = 1; i < lines.length; ++i) {
String[] tokens = lines[i].split("\t");
Row row = new GenericRow(tokens);
rows.add(row);
}
return sparkSession.createDataFrame(rows, schema);
}
Aggregations