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

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.

主站蜘蛛池模板: 金阳县| 西乌珠穆沁旗| 文山县| 梁河县| 玛曲县| 蓝山县| 大埔县| 南宫市| 乌兰察布市| 陆河县| 商丘市| 枞阳县| 扎兰屯市| 平度市| 濮阳县| 浙江省| 台湾省| 海淀区| 会理县| 仙居县| 当雄县| 石城县| 旬阳县| 崇义县| 婺源县| 康乐县| 新闻| 乌苏市| 石泉县| 宽城| 舒城县| 太保市| 伊吾县| 高密市| 保定市| 柯坪县| 宁乡县| 双辽市| 陕西省| 鹿邑县| 项城市|