Skip to content
Snippets Groups Projects
Commit 0f307db5 authored by Weiqing Yang's avatar Weiqing Yang Committed by Sean Owen
Browse files

[SPARK-15707][SQL] Make Code Neat - Use map instead of if check.

## What changes were proposed in this pull request?
In forType function of object RandomDataGenerator, the code following:
if (maybeSqlTypeGenerator.isDefined){
  ....
  Some(generator)
} else{
 None
}
will be changed. Instead, maybeSqlTypeGenerator.map will be used.

## How was this patch tested?
All of the current unit tests passed.

Author: Weiqing Yang <yangweiqing001@gmail.com>

Closes #13448 from Sherry302/master.
parent 091f81e1
No related branches found
No related tags found
No related merge requests found
......@@ -236,9 +236,8 @@ object RandomDataGenerator {
// convert it to catalyst value to call udt's deserialize.
val toCatalystType = CatalystTypeConverters.createToCatalystConverter(udt.sqlType)
if (maybeSqlTypeGenerator.isDefined) {
val sqlTypeGenerator = maybeSqlTypeGenerator.get
val generator = () => {
maybeSqlTypeGenerator.map { sqlTypeGenerator =>
() => {
val generatedScalaValue = sqlTypeGenerator.apply()
if (generatedScalaValue == null) {
null
......@@ -246,9 +245,6 @@ object RandomDataGenerator {
udt.deserialize(toCatalystType(generatedScalaValue))
}
}
Some(generator)
} else {
None
}
case unsupportedType => None
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment