我已经编写了使用SparkSQL访问Hive表的代码。下面是代码:如何将Spark Row的数据集转换为字符串?
SparkSession spark = SparkSession
.builder()
.appName("Java Spark Hive Example")
.master("local[*]")
.config("hive.metastore.uris", "thrift://localhost:9083")
.enableHiveSupport()
.getOrCreate();
Dataset<Row> df = spark.sql("select survey_response_value from health").toDF();
df.show();
我想知道我怎么能完整的输出转换为字符串或字符串数组?正如我正在尝试与另一个模块,只有我可以传递字符串或字符串类型数组值。
我已经尝试其他方法,如.toString
或类型转换为字符串值。但没有为我工作。
请让我知道如何将DataSet值转换为String?
请你解释一下这个'行'在程序中是什么?你的代码看起来非常适合我。 –
“row”是java 8的lambda参数。请检查http://www.developer.com/java/start-using-java-lambda-expressions.html – abaghel
它的完美。谢谢。 –