Java Code Examples for org.apache.spark.sql.types.StructField#metadata()
The following examples show how to use
org.apache.spark.sql.types.StructField#metadata() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SparkCubingJobTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private Integer convertOutSchema(Dataset<Row> layoutDs, String fieldName, org.apache.spark.sql.types.DataType dataType) { StructField[] structFieldList = layoutDs.schema().fields(); String[] columns = layoutDs.columns(); int index = 0; StructField[] outStructFieldList = new StructField[structFieldList.length]; for (int i = 0; i < structFieldList.length; i++) { if (columns[i].equalsIgnoreCase(fieldName)) { index = i; StructField structField = structFieldList[i]; outStructFieldList[i] = new StructField(structField.name(), dataType, false, structField.metadata()); } else { outStructFieldList[i] = structFieldList[i]; } } OUT_SCHEMA = new StructType(outStructFieldList); return index; }
Example 2
Source File: NManualBuildAndQueryCuboidTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private Integer convertOutSchema(Dataset<Row> layoutDs, String fieldName, org.apache.spark.sql.types.DataType dataType) { StructField[] structFieldList = layoutDs.schema().fields(); String[] columns = layoutDs.columns(); int index = 0; StructField[] outStructFieldList = new StructField[structFieldList.length]; for (int i = 0; i < structFieldList.length; i++) { if (columns[i].equalsIgnoreCase(fieldName)) { index = i; StructField structField = structFieldList[i]; outStructFieldList[i] = new StructField(structField.name(), dataType, false, structField.metadata()); } else { outStructFieldList[i] = structFieldList[i]; } } OUT_SCHEMA = new StructType(outStructFieldList); return index; }
Example 3
Source File: ColumnUtils.java From net.jgp.labs.spark with Apache License 2.0 | 5 votes |
public static Metadata getMetadata(Dataset<Row> df, String colName) { StructType schema = df.schema(); StructField[] fields = schema.fields(); for (StructField field : fields) { // TODO check on case if (field.name().compareTo(colName) == 0) { return field.metadata(); } } return null; }