diff --git a/docs/sql-programming-guide.md b/docs/sql-programming-guide.md index a3fb79ea40d30..a8db82faad985 100644 --- a/docs/sql-programming-guide.md +++ b/docs/sql-programming-guide.md @@ -15,7 +15,7 @@ title: Spark SQL Programming Guide Spark SQL allows relational queries expressed in SQL, HiveQL, or Scala to be executed using Spark. At the core of this component is a new type of RDD, [SchemaRDD](api/sql/core/index.html#org.apache.spark.sql.SchemaRDD). SchemaRDDs are composed -[Row](api/sql/core/index.html#org.apache.spark.sql.api.java.Row) objects along with +[Row](api/sql/catalyst/index.html#org.apache.spark.sql.catalyst.expressions.Row) objects along with a schema that describes the data types of each column in the row. A SchemaRDD is similar to a table in a traditional relational database. A SchemaRDD can be created from an existing RDD, parquet file, or by running HiveQL against data stored in [Apache Hive](http://hive.apache.org/). @@ -63,8 +63,8 @@ The entry point into all relational functionality in Spark is the of its decendents. To create a basic JavaSQLContext, all you need is a JavaSparkContext. {% highlight java %} -JavaSparkContext ctx // An existing JavaSparkContext. -JavaSQLContext sqlCtx = new org.apache.spark.sql.api.java.JavaSQLContext(ctx) +JavaSparkContext ctx = ...; // An existing JavaSparkContext. +JavaSQLContext sqlCtx = new org.apache.spark.sql.api.java.JavaSQLContext(ctx); {% endhighlight %} @@ -302,14 +302,14 @@ the `sql` method a `JavaHiveContext` also provides an `hql` methods, which allow expressed in HiveQL. {% highlight java %} -JavaSparkContext ctx // An existing JavaSparkContext. -JavaHiveContext hiveCtx = new org.apache.spark.sql.hive.api.java.HiveContext(ctx) +JavaSparkContext ctx = ...; // An existing JavaSparkContext. +JavaHiveContext hiveCtx = new org.apache.spark.sql.hive.api.java.HiveContext(ctx); -hiveCtx.hql("CREATE TABLE IF NOT EXISTS src (key INT, value STRING)") -hiveCtx.hql("LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv1.txt' INTO TABLE src") +hiveCtx.hql("CREATE TABLE IF NOT EXISTS src (key INT, value STRING)"); +hiveCtx.hql("LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv1.txt' INTO TABLE src"); -// Queries are expressed in HiveQL -hiveCtx.hql("FROM src SELECT key, value").collect().foreach(println) +// Queries are expressed in HiveQL. +Row[] results = hiveCtx.hql("FROM src SELECT key, value").collect(); {% endhighlight %} diff --git a/sql/core/src/main/scala/org/apache/spark/sql/api/java/Row.scala b/sql/core/src/main/scala/org/apache/spark/sql/api/java/Row.scala index dce24eb6b6e74..362fe769581d7 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/api/java/Row.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/api/java/Row.scala @@ -43,49 +43,49 @@ class Row(row: ScalaRow) extends Serializable { /** * Returns the value of column `i` as a long. This function will throw an exception if the value - * is at `i` is not an integer, or if it is null. + * is at `i` is not a long, or if it is null. */ def getLong(i: Int): Long = row.getLong(i) /** * Returns the value of column `i` as a double. This function will throw an exception if the - * value is at `i` is not an integer, or if it is null. + * value is at `i` is not a double, or if it is null. */ def getDouble(i: Int): Double = row.getDouble(i) /** * Returns the value of column `i` as a bool. This function will throw an exception if the value - * is at `i` is not an integer, or if it is null. + * is at `i` is not a boolean, or if it is null. */ def getBoolean(i: Int): Boolean = row.getBoolean(i) /** * Returns the value of column `i` as a short. This function will throw an exception if the value - * is at `i` is not an integer, or if it is null. + * is at `i` is not a short, or if it is null. */ def getShort(i: Int): Short = row.getShort(i) /** * Returns the value of column `i` as a byte. This function will throw an exception if the value - * is at `i` is not an integer, or if it is null. + * is at `i` is not a byte, or if it is null. */ def getByte(i: Int): Byte = row.getByte(i) /** * Returns the value of column `i` as a float. This function will throw an exception if the value - * is at `i` is not an integer, or if it is null. + * is at `i` is not a float, or if it is null. */ def getFloat(i: Int): Float = row.getFloat(i) /** * Returns the value of column `i` as a String. This function will throw an exception if the - * value is at `i` is not an integer, or if it is null. + * value is at `i` is not a String. */ def getString(i: Int): String = row.getString(i)