本文整理汇总了Java中org.apache.spark.sql.types.StructField.name方法的典型用法代码示例。如果您正苦于以下问题:Java StructField.name方法的具体用法?Java StructField.name怎么用?Java StructField.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.spark.sql.types.StructField
的用法示例。
在下文中一共展示了StructField.name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeDataFrame
import org.apache.spark.sql.types.StructField; //导入方法依赖的package包/类
@Override
public void writeDataFrame(String name, DataFrame df) {
for (StructField field : df.schema().fields()) {
String column = field.name();
// convert booleans to integers to avoid error in Spark 1.6.2
// "Cannot specify a column width on data type bit."
if (field.dataType() == DataTypes.BooleanType) {
df = df.withColumn(column + TMP_SUFFIX, df.col(column).cast(DataTypes.IntegerType))
.drop(column)
.withColumnRenamed(column + TMP_SUFFIX, column);
}
}
super.writeDataFrame(name, df);
}
示例2: carryForwardWhenNull
import org.apache.spark.sql.types.StructField; //导入方法依赖的package包/类
private Row carryForwardWhenNull(Row into, Row from) {
if (!config.hasPath(CARRY_FORWARD_CONFIG_NAME) || !config.getBoolean(CARRY_FORWARD_CONFIG_NAME)) {
return into;
}
for (StructField field : into.schema().fields()) {
String fieldName = field.name();
if (RowUtils.get(into, fieldName) == null && RowUtils.get(from, fieldName) != null) {
into = RowUtils.set(into, fieldName, RowUtils.get(from, fieldName));
}
}
return into;
}
示例3: carryForwardWhenNull
import org.apache.spark.sql.types.StructField; //导入方法依赖的package包/类
private Row carryForwardWhenNull(Row into, Row from) {
if (!doesCarryForward()) {
return into;
}
for (StructField field : into.schema().fields()) {
String fieldName = field.name();
if (get(into, fieldName) == null && get(from, fieldName) != null) {
into = set(into, fieldName, get(from, fieldName));
}
}
return into;
}
示例4: transform
import org.apache.spark.sql.types.StructField; //导入方法依赖的package包/类
@Override
public Dataset<Row> transform(Dataset<?> dataset){
StructType schema = dataset.schema();
StructType structSchema = getStructSchema(schema);
Column structColumn = dataset.apply(DatasetUtil.escapeColumnName(getStructCol()));
Dataset<Row> result = dataset.toDF();
StructField[] fields = structSchema.fields();
for(StructField field : fields){
String name = field.name();
Column fieldColumn = structColumn.getField(DatasetUtil.escapeColumnName(name));
result = result.withColumn(DatasetUtil.escapeColumnName(name), fieldColumn);
}
return result;
}