Skip to content
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

Revert "sql: add support for max/min aggregates on collated strings" #46693

Merged
merged 1 commit into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions docs/generated/sql/aggregates.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@
</span></td></tr>
<tr><td><a name="max"></a><code>max(arg1: <a href="uuid.html">uuid</a>) &rarr; <a href="uuid.html">uuid</a></code></td><td><span class="funcdesc"><p>Identifies the maximum selected value.</p>
</span></td></tr>
<tr><td><a name="max"></a><code>max(arg1: collatedstring{*}) &rarr; collatedstring{*}</code></td><td><span class="funcdesc"><p>Identifies the maximum selected value.</p>
</span></td></tr>
<tr><td><a name="max"></a><code>max(arg1: jsonb) &rarr; jsonb</code></td><td><span class="funcdesc"><p>Identifies the maximum selected value.</p>
</span></td></tr>
<tr><td><a name="max"></a><code>max(arg1: oid) &rarr; oid</code></td><td><span class="funcdesc"><p>Identifies the maximum selected value.</p>
Expand Down Expand Up @@ -133,8 +131,6 @@
</span></td></tr>
<tr><td><a name="min"></a><code>min(arg1: <a href="uuid.html">uuid</a>) &rarr; <a href="uuid.html">uuid</a></code></td><td><span class="funcdesc"><p>Identifies the minimum selected value.</p>
</span></td></tr>
<tr><td><a name="min"></a><code>min(arg1: collatedstring{*}) &rarr; collatedstring{*}</code></td><td><span class="funcdesc"><p>Identifies the minimum selected value.</p>
</span></td></tr>
<tr><td><a name="min"></a><code>min(arg1: jsonb) &rarr; jsonb</code></td><td><span class="funcdesc"><p>Identifies the minimum selected value.</p>
</span></td></tr>
<tr><td><a name="min"></a><code>min(arg1: oid) &rarr; oid</code></td><td><span class="funcdesc"><p>Identifies the minimum selected value.</p>
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/execinfra/server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ import (
//
// ATTENTION: When updating these fields, add to version_history.txt explaining
// what changed.
const Version execinfrapb.DistSQLVersion = 29
const Version execinfrapb.DistSQLVersion = 28

// MinAcceptedVersion is the oldest version that the server is
// compatible with; see above.
const MinAcceptedVersion execinfrapb.DistSQLVersion = 29
const MinAcceptedVersion execinfrapb.DistSQLVersion = 27

// SettingUseTempStorageJoins is a cluster setting that configures whether
// joins are allowed to spill to disk.
Expand Down
10 changes: 0 additions & 10 deletions pkg/sql/logictest/testdata/logic_test/collatedstring
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,3 @@ CREATE TABLE t46570(c0 BOOL, c1 STRING COLLATE en);
CREATE INDEX ON t46570(rowid, c1 DESC);
INSERT INTO t46570(c1, rowid) VALUES('' COLLATE en, 0);
UPSERT INTO t46570(rowid) VALUES (0), (1)

query T
SELECT max(x) FROM (VALUES ('foo' COLLATE en), ('bar' COLLATE en)) t(x)
----
foo

query T
SELECT min(x) FROM (VALUES ('foo' COLLATE en), ('bar' COLLATE en)) t(x)
----
bar
3 changes: 0 additions & 3 deletions pkg/sql/rowexec/version_history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,3 @@
- The CORR aggregate function has been added which will not be recognized
by older nodes. However, new nodes can process plans from older nodes,
so MinAcceptedVersion is unchanged.
- Version: 29 (MinAcceptedVersion: 29)
- The Max and Min aggregate functions have been extended to support collated
strings. Old nodes won't have this ability, so we bump the version.
11 changes: 2 additions & 9 deletions pkg/sql/sem/builtins/aggregate_builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ func aggPropsNullableArgs() tree.FunctionProperties {
return f
}

// allMaxMinAggregateTypes contains extra types that aren't in
// types.Scalar that the max/min aggregate functions are defined on.
var allMaxMinAggregateTypes = append(
[]*types.T{types.AnyCollatedString},
types.Scalar...,
)

// aggregates are a special class of builtin functions that are wrapped
// at execution in a bucketing layer to combine (aggregate) the result
// of the function being run over many rows.
Expand Down Expand Up @@ -204,13 +197,13 @@ var aggregates = map[string]builtinDefinition{
"Calculates the boolean value of `AND`ing all selected values."),
),

"max": collectOverloads(aggProps(), allMaxMinAggregateTypes,
"max": collectOverloads(aggProps(), types.Scalar,
func(t *types.T) tree.Overload {
return makeAggOverload([]*types.T{t}, t, newMaxAggregate,
"Identifies the maximum selected value.")
}),

"min": collectOverloads(aggProps(), allMaxMinAggregateTypes,
"min": collectOverloads(aggProps(), types.Scalar,
func(t *types.T) tree.Overload {
return makeAggOverload([]*types.T{t}, t, newMinAggregate,
"Identifies the minimum selected value.")
Expand Down