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
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ 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"
Copy link
Member

Choose a reason for hiding this comment

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

Hi, @crlalam.
We use 2-space indentation in general.
FYI, maybe, you can see Scala Coding Style.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @dongjoon-hyun ,
Thanks for the review and pointing me to the coding style. Fixed coding style issues and updated the pull request. Please take a look.

+ " 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.
spark.sql("SELECT key, value FROM src_serde ORDER BY key, value").show();
spark.stop();
}
}
8 changes: 8 additions & 0 deletions examples/src/main/python/sql/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,13 @@
# | 5| val_5| 5| val_5|
# ...
# $example off:spark_hive$

# 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 '([^ ]*) ([^ ]*)')"""
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.
spark.sql("SELECT key, value FROM src_serde ORDER BY key, value").show()

spark.stop()
38 changes: 38 additions & 0 deletions examples/src/main/resources/kv7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-4400 4400
1E+99 0
1E-99 0
0 0
100 100
10 10
1 1
0.1 0
0.01 0
200 200
20 20
2 2
0 0
0.2 0
0.02 0
0.3 0
0.33 0
0.333 0
-0.3 0
-0.33 0
-0.333 0
1.0 1
2 2
3.14 3
-1.12 -1
-1.12 -1
-1.122 -11
1.12 1
1.122 1
124.00 124
125.2 125
-1255.49 -1255
3.14 3
3.14 3
3.140 4
0.9999999999999999999999999 1
-1234567890.1234567890 -1234567890
1234567890.1234567800 1234567890
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ object SparkHiveExample {
// ...
// $example off:spark_hive$

// Hive serde's are also supported with serde properties.
val sqlQuery = "CREATE TABLE src_serde(key decimal(38,18), value int) USING hive" +
" OPTIONS (SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe', input.regex '([^ ]*) ([^ ]*)')"
sql(sqlQuery)
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()
}
}