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

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.

主站蜘蛛池模板: 定结县| 宁化县| 黔西县| 贡山| 墨玉县| 盐山县| 获嘉县| 安化县| 丹凤县| 名山县| 平顶山市| 淄博市| 青海省| 西安市| 石渠县| 砀山县| 石柱| 延长县| 临邑县| 土默特右旗| 和林格尔县| 靖边县| 常宁市| 霍州市| 广水市| 清水县| 德安县| 镇江市| 上高县| 普格县| 乌恰县| 晋江市| 和静县| 奉贤区| 廉江市| 哈巴河县| 日照市| 梅州市| 长宁区| 邵阳市| 宜宾县|