Skip to content

Commit

Permalink
fix-15171, remove the references to deprecated method registerTempTable
Browse files Browse the repository at this point in the history
  • Loading branch information
clockfly committed May 13, 2016
1 parent 53aa395 commit 5842188
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
20 changes: 10 additions & 10 deletions docs/sql-programming-guide.md
Expand Up @@ -703,7 +703,7 @@ val rowRDD = people.map(_.split(",")).map(p => Row(p(0), p(1).trim))
// Apply the schema to the RDD.
val peopleDataFrame = sqlContext.createDataFrame(rowRDD, schema)

// Register the DataFrames as a table.
// Creates a temporary view.
peopleDataFrame.createOrReplaceTempView("people")

// SQL statements can be run by using the sql methods provided by sqlContext.
Expand Down Expand Up @@ -771,10 +771,10 @@ JavaRDD<Row> rowRDD = people.map(
// Apply the schema to the RDD.
DataFrame peopleDataFrame = sqlContext.createDataFrame(rowRDD, schema);

// Register the DataFrame as a table.
// Creates a temporary view.
peopleDataFrame.createOrReplaceTempView("people");

// SQL can be run over RDDs that have been registered as tables.
// SQL can be run over a temporary view.
DataFrame results = sqlContext.sql("SELECT name FROM people");

// The results of SQL queries are DataFrames and support all the normal RDD operations.
Expand Down Expand Up @@ -824,7 +824,7 @@ schema = StructType(fields)
# Apply the schema to the RDD.
schemaPeople = sqlContext.createDataFrame(people, schema)

# Register the DataFrame as a table.
# Creates a temporary view
schemaPeople.createOrReplaceTempView("people")

# SQL can be run over DataFrames that have been registered as a table.
Expand Down Expand Up @@ -1072,7 +1072,7 @@ people.write.parquet("people.parquet")
// The result of loading a Parquet file is also a DataFrame.
val parquetFile = sqlContext.read.parquet("people.parquet")

//Parquet files can also be registered as tables and then used in SQL statements.
//Parquet files can also be used to create a temporary view and then used in SQL statements.
parquetFile.createOrReplaceTempView("parquetFile")
val teenagers = sqlContext.sql("SELECT name FROM parquetFile WHERE age >= 13 AND age <= 19")
teenagers.map(t => "Name: " + t(0)).collect().foreach(println)
Expand All @@ -1094,7 +1094,7 @@ schemaPeople.write().parquet("people.parquet");
// The result of loading a parquet file is also a DataFrame.
DataFrame parquetFile = sqlContext.read().parquet("people.parquet");

// Parquet files can also be registered as tables and then used in SQL statements.
// Parquet files can also be used to create a temporary view and then used in SQL statements.
parquetFile.createOrReplaceTempView("parquetFile");
DataFrame teenagers = sqlContext.sql("SELECT name FROM parquetFile WHERE age >= 13 AND age <= 19");
List<String> teenagerNames = teenagers.javaRDD().map(new Function<Row, String>() {
Expand All @@ -1120,7 +1120,7 @@ schemaPeople.write.parquet("people.parquet")
# The result of loading a parquet file is also a DataFrame.
parquetFile = sqlContext.read.parquet("people.parquet")

# Parquet files can also be registered as tables and then used in SQL statements.
# Parquet files can also be used to create a temporary view and then used in SQL statements.
parquetFile.createOrReplaceTempView("parquetFile");
teenagers = sqlContext.sql("SELECT name FROM parquetFile WHERE age >= 13 AND age <= 19")
teenNames = teenagers.map(lambda p: "Name: " + p.name)
Expand All @@ -1144,7 +1144,7 @@ write.parquet(schemaPeople, "people.parquet")
# The result of loading a parquet file is also a DataFrame.
parquetFile <- read.parquet(sqlContext, "people.parquet")

# Parquet files can also be registered as tables and then used in SQL statements.
# Parquet files can also be used to create a temporary view and then used in SQL statements.
registerTempTable(parquetFile, "parquetFile")
teenagers <- sql(sqlContext, "SELECT name FROM parquetFile WHERE age >= 13 AND age <= 19")
schema <- structType(structField("name", "string"))
Expand Down Expand Up @@ -1544,7 +1544,7 @@ people.printSchema();
// |-- age: long (nullable = true)
// |-- name: string (nullable = true)

// Register this DataFrame as a table.
// Creates a temporary view
people.createOrReplaceTempView("people");

// SQL statements can be run by using the sql methods provided by sqlContext.
Expand Down Expand Up @@ -1582,7 +1582,7 @@ people.printSchema()
# |-- age: long (nullable = true)
# |-- name: string (nullable = true)

# Register this DataFrame as a table.
# Creates a temporary view.
people.createOrReplaceTempView("people")

# SQL statements can be run by using the sql methods provided by `sqlContext`.
Expand Down
4 changes: 2 additions & 2 deletions docs/streaming-programming-guide.md
Expand Up @@ -1606,7 +1606,7 @@ words.foreachRDD(
});
DataFrame wordsDataFrame = sqlContext.createDataFrame(rowRDD, JavaRow.class);

// Register as table
// Creates a temporary view
wordsDataFrame.createOrReplaceTempView("words");

// Do word count on table using SQL and print it
Expand Down Expand Up @@ -1646,7 +1646,7 @@ def process(time, rdd):
rowRdd = rdd.map(lambda w: Row(word=w))
wordsDataFrame = sqlContext.createDataFrame(rowRdd)

# Register as table
# Creates a temporary view
wordsDataFrame.createOrReplaceTempView("words")

# Do word count on table using SQL and print it
Expand Down
Expand Up @@ -73,11 +73,11 @@ public Person call(String line) {
}
});

// Apply a schema to an RDD of Java Beans and register it as a table.
// Apply a schema to an RDD of Java Beans and create a temporary view
Dataset<Row> schemaPeople = spark.createDataFrame(people, Person.class);
schemaPeople.createOrReplaceTempView("people");

// SQL can be run over RDDs that have been registered as tables.
// SQL can be run over RDDs which backs a temporary view.
Dataset<Row> teenagers = spark.sql("SELECT name FROM people WHERE age >= 13 AND age <= 19");

// The results of SQL queries are DataFrames and support all the normal RDD operations.
Expand All @@ -101,7 +101,7 @@ public String call(Row row) {
// The result of loading a parquet file is also a DataFrame.
Dataset<Row> parquetFile = spark.read().parquet("people.parquet");

//Parquet files can also be registered as tables and then used in SQL statements.
// A temporary view can be created by using Parquet files and then used in SQL statements.
parquetFile.createOrReplaceTempView("parquetFile");
Dataset<Row> teenagers2 =
spark.sql("SELECT name FROM parquetFile WHERE age >= 13 AND age <= 19");
Expand Down Expand Up @@ -130,7 +130,7 @@ public String call(Row row) {
// |-- age: IntegerType
// |-- name: StringType

// Register this DataFrame as a table.
// Creates a temporary view
peopleFromJsonFile.createOrReplaceTempView("people");

// SQL statements can be run by using the sql methods provided by `spark`
Expand Down
Expand Up @@ -94,7 +94,7 @@ public JavaRecord call(String word) {
});
Dataset<Row> wordsDataFrame = spark.createDataFrame(rowRDD, JavaRecord.class);

// Register as table
// Creates a temporary view
wordsDataFrame.createOrReplaceTempView("words");

// Do word count on table using SQL and print it
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/sql.py
Expand Up @@ -66,7 +66,7 @@
# |-- age: long (nullable = true)
# |-- name: string (nullable = true)

# Register this DataFrame as a temporary table.
# Creates a temporary view.
people.createOrReplaceTempView("people")

# SQL statements can be run by using the sql methods provided by `spark`
Expand Down
Expand Up @@ -70,7 +70,7 @@ def process(time, rdd):
rowRdd = rdd.map(lambda w: Row(word=w))
wordsDataFrame = spark.createDataFrame(rowRdd)

# Register as table
# Creates a temporary view
wordsDataFrame.createOrReplaceTempView("words")

# Do word count on table using SQL and print it
Expand Down
Expand Up @@ -35,8 +35,8 @@ object RDDRelation {
import spark.implicits._

val df = spark.createDataFrame((1 to 100).map(i => Record(i, s"val_$i")))
// Any RDD containing case classes can be registered as a table. The schema of the table is
// automatically inferred using scala reflection.
// Any RDD containing case classes can be used to create a temporary view. The schema of the
// view is automatically inferred using scala reflection.
df.createOrReplaceTempView("records")

// Once tables have been registered, you can run SQL queries over them.
Expand Down Expand Up @@ -66,7 +66,7 @@ object RDDRelation {
// Queries can be run using the DSL on parquet files just like the original RDD.
parquetFile.where($"key" === 1).select($"value".as("a")).collect().foreach(println)

// These files can also be registered as tables.
// These files can also be used to create a temporary view.
parquetFile.createOrReplaceTempView("parquetFile")
spark.sql("SELECT * FROM parquetFile").collect().foreach(println)

Expand Down
Expand Up @@ -66,7 +66,7 @@ object SqlNetworkWordCount {
// Convert RDD[String] to RDD[case class] to DataFrame
val wordsDataFrame = rdd.map(w => Record(w)).toDF()

// Register as table
// Creates a temporary view
wordsDataFrame.createOrReplaceTempView("words")

// Do word count on table using SQL and print it
Expand Down
Expand Up @@ -1912,7 +1912,7 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
Row(1, 1, 1, 1) :: Row(1, 2, 2, 1) :: Row(2, 1, 1, 2) :: Row(2, 2, 2, 2) ::
Row(3, 1, 1, 3) :: Row(3, 2, 2, 3) :: Nil)

// Try with a registered table.
// Try with a temporary view
sql("select struct(a, b) as record from testData2").createOrReplaceTempView("structTable")
checkAnswer(
sql("SELECT record.* FROM structTable"),
Expand Down Expand Up @@ -1977,7 +1977,7 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
nestedStructData.select($"record.r1.*"),
Row(1, 1) :: Row(1, 2) :: Row(2, 1) :: Row(2, 2) :: Row(3, 1) :: Row(3, 2) :: Nil)

// Try with a registered table
// Try with a temporary view
withTempTable("nestedStructTable") {
nestedStructData.createOrReplaceTempView("nestedStructTable")
checkAnswer(
Expand Down
Expand Up @@ -685,7 +685,7 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
createQueryTest("case sensitivity when query Hive table",
"SELECT srcalias.KEY, SRCALIAS.value FROM sRc SrCAlias WHERE SrCAlias.kEy < 15")

test("case sensitivity: registered table") {
test("case sensitivity: created temporary view") {
val testData =
TestHive.sparkContext.parallelize(
TestData(1, "str1") ::
Expand Down

0 comments on commit 5842188

Please sign in to comment.