Skip to content

Commit 62065ac

Browse files
committed
refine code to provide better atomicity
1 parent 19ddd4f commit 62065ac

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,18 +263,22 @@ abstract class Expression extends TreeNode[Expression] {
263263

264264
protected def flatArguments: Iterator[Any] = stringArgs.flatMap {
265265
case t: Iterable[_] => t
266-
case e: Expression => e.argumentString :: Nil
267266
case single => single :: Nil
268267
}
269268

269+
protected def flatArgumentStrings: Iterator[String] = flatArguments.map {
270+
case e: Expression => e.argumentString
271+
case arg: Any => arg.toString
272+
}
273+
270274
// Marks this as final, Expression.verboseString should never be called, and thus shouldn't be
271275
// overridden by concrete classes.
272276
final override def verboseString(maxFields: Int): String = simpleString(maxFields)
273277

274278
override def simpleString(maxFields: Int): String = toString
275279

276280
override def toString: String = prettyName + truncatedString(
277-
flatArguments.toSeq, "(", ", ", ")", SQLConf.get.maxToStringFields)
281+
flatArgumentStrings.toSeq, "(", ", ", ")", SQLConf.get.maxToStringFields)
278282

279283
def argumentString: String = toString
280284

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/interfaces.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ abstract class AggregateFunction extends Expression {
235235
/** String representation used in explain plans. */
236236
def toAggString(isDistinct: Boolean): String = {
237237
val start = if (isDistinct) "(distinct " else "("
238-
prettyName + flatArguments.mkString(start, ", ", ")")
238+
prettyName + flatArgumentStrings.mkString(start, ", ", ")")
239239
}
240240
}
241241

sql/core/src/test/resources/sql-tests/results/explain.sql.out

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Results [2]: [key#x, max#x]
9191

9292
(6) Exchange
9393
Input [2]: [key#x, max#x]
94-
Arguments: hashpartitioning(key#x, 4), true, [id=#x]
94+
Arguments: hashpartitioning(key, 4), true, [id=#x]
9595

9696
(7) HashAggregate [codegen id : 2]
9797
Input [2]: [key#x, max#x]
@@ -158,7 +158,7 @@ Results [2]: [key#x, max#x]
158158

159159
(6) Exchange
160160
Input [2]: [key#x, max#x]
161-
Arguments: hashpartitioning(key#x, 4), true, [id=#x]
161+
Arguments: hashpartitioning(key, 4), true, [id=#x]
162162

163163
(7) HashAggregate [codegen id : 2]
164164
Input [2]: [key#x, max#x]
@@ -246,7 +246,7 @@ Results [2]: [key#x, val#x]
246246

247247
(11) Exchange
248248
Input [2]: [key#x, val#x]
249-
Arguments: hashpartitioning(key#x, val#x, 4), true, [id=#x]
249+
Arguments: hashpartitioning(key, val, 4), true, [id=#x]
250250

251251
(12) HashAggregate [codegen id : 4]
252252
Input [2]: [key#x, val#x]
@@ -832,7 +832,7 @@ Results [2]: [key#x, max#x]
832832

833833
(6) Exchange
834834
Input [2]: [key#x, max#x]
835-
Arguments: hashpartitioning(key#x, 4), true, [id=#x]
835+
Arguments: hashpartitioning(key, 4), true, [id=#x]
836836

837837
(7) HashAggregate [codegen id : 4]
838838
Input [2]: [key#x, max#x]
@@ -917,7 +917,7 @@ Input [2]: [key#x, val#x]
917917
(3) HashAggregate
918918
Input [2]: [key#x, val#x]
919919
Keys: []
920-
Functions [3]: [partial_count(val#x), partial_sum(cast(key#x as bigint)), partial_count(key#x) FILTER (WHERE (val#x > 1))]
920+
Functions [3]: [partial_count(val), partial_sum(cast(key#x as bigint)), partial_count(key) FILTER (WHERE (val#x > 1))]
921921
Aggregate Attributes [3]: [count#xL, sum#xL, count#xL]
922922
Results [3]: [count#xL, sum#xL, count#xL]
923923

@@ -928,9 +928,9 @@ Arguments: SinglePartition, true, [id=#x]
928928
(5) HashAggregate [codegen id : 2]
929929
Input [3]: [count#xL, sum#xL, count#xL]
930930
Keys: []
931-
Functions [3]: [count(val#x), sum(cast(key#x as bigint)), count(key#x)]
932-
Aggregate Attributes [3]: [count(val#x)#xL, sum(cast(key#x as bigint))#xL, count(key#x)#xL]
933-
Results [2]: [(count(val#x)#xL + sum(cast(key#x as bigint))#xL) AS TOTAL#xL, count(key#x)#xL AS count(key) FILTER (WHERE (val > 1))#xL]
931+
Functions [3]: [count(val), sum(cast(key#x as bigint)), count(key)]
932+
Aggregate Attributes [3]: [count(val)#xL, sum(cast(key#x as bigint))#xL, count(key)#xL]
933+
Results [2]: [(count(val)#xL + sum(cast(key#x as bigint))#xL) AS TOTAL#xL, count(key)#xL AS count(key) FILTER (WHERE (val > 1))#xL]
934934

935935

936936
-- !query
@@ -967,7 +967,7 @@ Results [2]: [key#x, buf#x]
967967

968968
(4) Exchange
969969
Input [2]: [key#x, buf#x]
970-
Arguments: hashpartitioning(key#x, 4), true, [id=#x]
970+
Arguments: hashpartitioning(key, 4), true, [id=#x]
971971

972972
(5) ObjectHashAggregate
973973
Input [2]: [key#x, buf#x]
@@ -1017,7 +1017,7 @@ Results [2]: [key#x, min#x]
10171017

10181018
(5) Exchange
10191019
Input [2]: [key#x, min#x]
1020-
Arguments: hashpartitioning(key#x, 4), true, [id=#x]
1020+
Arguments: hashpartitioning(key, 4), true, [id=#x]
10211021

10221022
(6) Sort [codegen id : 2]
10231023
Input [2]: [key#x, min#x]

sql/core/src/test/resources/sql-tests/results/pivot.sql.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ PIVOT (
475475
struct<>
476476
-- !query output
477477
org.apache.spark.sql.AnalysisException
478-
Invalid pivot column 'named_struct(course, course#x, m, m#x)'. Pivot columns must be comparable.;
478+
Invalid pivot column 'named_struct(course, course, m, m)'. Pivot columns must be comparable.;
479479

480480

481481
-- !query

sql/core/src/test/resources/sql-tests/results/udf/udf-pivot.sql.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ PIVOT (
441441
struct<>
442442
-- !query output
443443
org.apache.spark.sql.AnalysisException
444-
Invalid pivot column 'named_struct(course, course#x, m, m#x)'. Pivot columns must be comparable.;
444+
Invalid pivot column 'named_struct(course, course, m, m)'. Pivot columns must be comparable.;
445445

446446

447447
-- !query

0 commit comments

Comments
 (0)