-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-30184][SQL] Implement a helper method for aliasing functions #26808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
29fdaba
7d5f4be
7ba7802
759262d
5ec101f
f210bb9
cc234b9
7617ec3
92e381b
a2d75de
3ef62af
87c6ea3
9480532
5c540fc
d780dfc
85d9597
a71e8a7
dd2d85d
c1b3afb
e7a4e90
ca886f0
125cfac
4ca20f4
aecdd8a
bbd4397
9146913
8e9e42b
36418e2
ce8ea17
4b536dd
737f33a
1920940
700a84d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,7 +198,8 @@ object RewriteDistinctAggregates extends Rule[LogicalPlan] { | |
|
|
||
| // Select the result of the first aggregate in the last aggregate. | ||
| val result = AggregateExpression( | ||
| aggregate.First(evalWithinGroup(regularGroupId, operator.toAttribute), Literal(true)), | ||
| aggregate.First("first", | ||
| evalWithinGroup(regularGroupId, operator.toAttribute), Literal(true)), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a bit verbose to always set "first" for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| mode = Complete, | ||
| isDistinct = false) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -254,7 +254,8 @@ object StatFunctions extends Logging { | |
| stats.toLowerCase(Locale.ROOT) match { | ||
| case "count" => (child: Expression) => Count(child).toAggregateExpression() | ||
| case "mean" => (child: Expression) => Average(child).toAggregateExpression() | ||
| case "stddev" => (child: Expression) => StddevSamp(child).toAggregateExpression() | ||
| case "stddev" => (child: Expression) => | ||
| StddevSamp("stddev_samp", child).toAggregateExpression() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall we use |
||
| case "min" => (child: Expression) => Min(child).toAggregateExpression() | ||
| case "max" => (child: Expression) => Max(child).toAggregateExpression() | ||
| case _ => throw new IllegalArgumentException(s"$stats is not a recognised statistic") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -431,7 +431,7 @@ object functions { | |
| * @since 2.0.0 | ||
| */ | ||
| def first(e: Column, ignoreNulls: Boolean): Column = withAggregateFunction { | ||
| new First(e.expr, Literal(ignoreNulls)) | ||
| new First("first", e.expr, Literal(ignoreNulls)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can add a constructor to provide a default name.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -556,7 +556,7 @@ object functions { | |
| * @since 2.0.0 | ||
| */ | ||
| def last(e: Column, ignoreNulls: Boolean): Column = withAggregateFunction { | ||
| new Last(e.expr, Literal(ignoreNulls)) | ||
| new Last("last", e.expr, Literal(ignoreNulls)) | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -675,7 +675,7 @@ object functions { | |
| * @group agg_funcs | ||
| * @since 1.6.0 | ||
| */ | ||
| def stddev(e: Column): Column = withAggregateFunction { StddevSamp(e.expr) } | ||
| def stddev(e: Column): Column = withAggregateFunction { StddevSamp("stddev", e.expr) } | ||
|
|
||
| /** | ||
| * Aggregate function: alias for `stddev_samp`. | ||
|
|
@@ -692,7 +692,7 @@ object functions { | |
| * @group agg_funcs | ||
| * @since 1.6.0 | ||
| */ | ||
| def stddev_samp(e: Column): Column = withAggregateFunction { StddevSamp(e.expr) } | ||
| def stddev_samp(e: Column): Column = withAggregateFunction { StddevSamp("stddev_samp", e.expr) } | ||
|
|
||
| /** | ||
| * Aggregate function: returns the sample standard deviation of | ||
|
|
@@ -759,7 +759,7 @@ object functions { | |
| * @group agg_funcs | ||
| * @since 1.6.0 | ||
| */ | ||
| def variance(e: Column): Column = withAggregateFunction { VarianceSamp(e.expr) } | ||
| def variance(e: Column): Column = withAggregateFunction { VarianceSamp("variance", e.expr) } | ||
|
|
||
| /** | ||
| * Aggregate function: alias for `var_samp`. | ||
|
|
@@ -775,7 +775,7 @@ object functions { | |
| * @group agg_funcs | ||
| * @since 1.6.0 | ||
| */ | ||
| def var_samp(e: Column): Column = withAggregateFunction { VarianceSamp(e.expr) } | ||
| def var_samp(e: Column): Column = withAggregateFunction { VarianceSamp("var_samp", e.expr) } | ||
|
|
||
| /** | ||
| * Aggregate function: returns the unbiased variance of the values in a group. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.