课程表

Spark 基础

Spark RDDs

Spark Streaming

Spark SQL

GraphX编程指南

工具箱
速查手册

编写语言集成的相关查询

当前位置:免费教程 » 数据库/运维 » Spark

语言集成的相关查询是实验性的,现在暂时只支持scala。

Spark SQL也支持用领域特定语言编写查询。

  1. // sc is an existing SparkContext.
  2. val sqlContext = new org.apache.spark.sql.SQLContext(sc)
  3. // Importing the SQL context gives access to all the public SQL functions and implicit conversions.
  4. import sqlContext._
  5. val people: RDD[Person] = ... // An RDD of case class objects, from the first example.
  6. // The following is the same as 'SELECT name FROM people WHERE age >= 10 AND age <= 19'
  7. val teenagers = people.where('age >= 10).where('age <= 19).select('name)
  8. teenagers.map(t => "Name: " + t(0)).collect().foreach(println)

DSL使用Scala的符号来表示在潜在表(underlying table)中的列,这些列以前缀(')标示。将这些符号隐式转换成由SQL执行引擎计算的表达式。你可以在ScalaDoc中了解详情。

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号