Spark Dataframe UDF的一个很好的解决方案,我曾经获得过Bytes长度,这对于我的情况来说更好:
static UDF1 BytesSize = new UDF1<String, Integer>() { public Integer call(final String line) throws Exception { return line.getBytes().length; }};private void saveIt(){sparkSession.udf().register("BytesSize",BytesSize,DataTypes.IntegerType); dfToWrite.withColumn("fullLineBytesSize",callUDF("BytesSize",functions.concat_ws( ",",columns)) ).write().partitionBy(hivePartitionColumn) .option("header", "true") .mode(SaveMode.Append).format(storageFormat).save(pathTowrite);}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)