Skip to content

Commit

Permalink
Address matei's comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
marmbrus committed Apr 2, 2014
1 parent 33a1b1a commit f531eb1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions docs/sql-programming-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Expand Down Expand Up @@ -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 %}

</div>
Expand Down Expand Up @@ -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 %}

Expand Down
14 changes: 7 additions & 7 deletions sql/core/src/main/scala/org/apache/spark/sql/api/java/Row.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f531eb1

Please sign in to comment.