官术网_书友最值得收藏!

Using SQL

After using the previous Scala example to create a data frame from a JSON input file on HDFS, we can now define a temporary table based on the data frame and run SQL against it.

The following example shows you the temporary table called washing_flat being defined and a row count being created using count(*):

The schema for this data was created on the fly (inferred). This is a very nice function of the Apache Spark DataSource API that has been used when reading the JSON file from HDFS using the SparkSession object. However, if you want to specify the schema on your own, you can do so.

主站蜘蛛池模板: 宣武区| 松原市| 浦江县| 翁牛特旗| 阿合奇县| 甘南县| 孟村| 桐城市| 靖安县| 卫辉市| 江北区| 石阡县| 望城县| 龙井市| 湖南省| 宜阳县| 丰都县| 石棉县| 绥宁县| 宜都市| 武胜县| 庆云县| 黔东| 山阴县| 乌恰县| 泗洪县| 崇左市| 榆中县| 广德县| 蛟河市| 靖宇县| 新竹县| 彭水| 收藏| 富蕴县| 北海市| 格尔木市| 澜沧| 博客| 丰城市| 淮阳县|