Skip to content

Commit fcfccee

Browse files
committed
Add function descs, examples in comments, and indentation.
1 parent 584eb9e commit fcfccee

File tree

1 file changed

+27
-6
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions

1 file changed

+27
-6
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/generators.scala

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,23 @@ abstract class ExplodeBase(child: Expression, position: Boolean)
114114
override def elementSchema: StructType = child.dataType match {
115115
case ArrayType(et, containsNull) =>
116116
if (position) {
117-
new StructType().add("pos", IntegerType, false).add("col", et, containsNull)
117+
new StructType()
118+
.add("pos", IntegerType, false)
119+
.add("col", et, containsNull)
118120
} else {
119-
new StructType().add("col", et, containsNull)
121+
new StructType()
122+
.add("col", et, containsNull)
120123
}
121124
case MapType(kt, vt, valueContainsNull) =>
122125
if (position) {
123-
new StructType().add("pos", IntegerType, false).add("key", kt, false)
126+
new StructType()
127+
.add("pos", IntegerType, false)
128+
.add("key", kt, false)
124129
.add("value", vt, valueContainsNull)
125130
} else {
126-
new StructType().add("key", kt, false).add("value", vt, valueContainsNull)
131+
new StructType()
132+
.add("key", kt, false)
133+
.add("value", vt, valueContainsNull)
127134
}
128135
}
129136

@@ -159,21 +166,35 @@ abstract class ExplodeBase(child: Expression, position: Boolean)
159166

160167
/**
161168
* Given an input array produces a sequence of rows for each value in the array.
169+
*
170+
* {{{
171+
* SELECT explode(array(10,20)) ->
172+
* 10
173+
* 20
174+
* }}}
162175
*/
163176
// scalastyle:off line.size.limit
164177
@ExpressionDescription(
165-
usage = "_FUNC_(a) - Separates the elements of array a into multiple rows, or the elements of map a into multiple rows and columns.")
178+
usage = "_FUNC_(a) - Separates the elements of array a into multiple rows, or the elements of map a into multiple rows and columns.",
179+
extended = "> SELECT _FUNC_(array(10,20));\n 10\n 20")
166180
// scalastyle:on line.size.limit
167181
case class Explode(child: Expression)
168182
extends ExplodeBase(child, position = false) with Serializable {
169183
}
170184

171185
/**
172186
* Given an input array produces a sequence of rows for each position and value in the array.
187+
*
188+
* {{{
189+
* SELECT explode(array(10,20)) ->
190+
* 0 10
191+
* 1 20
192+
* }}}
173193
*/
174194
// scalastyle:off line.size.limit
175195
@ExpressionDescription(
176-
usage = "_FUNC_(a) - Separates the elements of array a into multiple rows with positions, or the elements of a map into multiple rows and columns with positions.")
196+
usage = "_FUNC_(a) - Separates the elements of array a into multiple rows with positions, or the elements of a map into multiple rows and columns with positions.",
197+
extended = "> SELECT _FUNC_(array(10,20));\n 0\t10\n 1\t20")
177198
// scalastyle:on line.size.limit
178199
case class PosExplode(child: Expression)
179200
extends ExplodeBase(child, position = true) with Serializable {

0 commit comments

Comments
 (0)