Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[SPARK-22191] [SQL] Add hive serde example with serde properties
  • Loading branch information
Lalam committed Oct 6, 2017
commit 27e7963716c41978726348e16d77bbd0320eb801
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public static void main(String[] args) {
// $example off:spark_hive$

// Hive serde's are also supported with serde properties.
String sqlQuery = "CREATE TABLE src_serde(key decimal(38,18), value int) USING hive"
+ " OPTIONS (SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe', input.regex '([^ ]*) ([^ ]*)')";
String sqlQuery = "CREATE TABLE src_serde(key decimal(38,18), value int) USING hive" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation here doesn't match the rest of the function.

" OPTIONS (SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe', input.regex '([^ ]*) ([^ ]*)')";
spark.sql(sqlQuery);
spark.sql("LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv7.txt' INTO TABLE src_serde");
// Executed the data with the specified serde properties.
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/sql/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@

# Hive serde's are also supported with serde properties.
sqlQuery = """CREATE TABLE src_serde(key decimal(38,18), value int) USING hive
OPTIONS (SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe', input.regex '([^ ]*) ([^ ]*)')"""
OPTIONS (SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe', input.regex '([^ ]*) ([^ ]*)')"""
spark.sql(sqlQuery)
spark.sql("LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv7.txt' INTO TABLE src_serde")
# Executed the data with the specified serde properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ object SparkHiveExample {
sql("LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv7.txt' INTO TABLE src_serde")
// Executed the data with the specified serde properties.
sql("SELECT key, value FROM src_serde ORDER BY key, value").show()

spark.stop()
}
}