Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit823e739

Browse files
committed
Test GROUP BY matching of join columns that are type-coerced by USING.
If we have, say, an int column that is left-joined to a bigint columnwith USING, the merged column is the int column promoted to bigint.GROUP BY's tests for whether grouping on the merged column allows areference to the underlying column, or vice versa, should know aboutthat relationship --- and they do. But I nearly broke this case withan ill-advised optimization, so the lack of any test coverage for itseems like a bad idea.
1 parentc5f3b53 commit823e739

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

‎src/test/regress/expected/aggregates.out

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,32 @@ drop table t2;
11941194
drop table t3;
11951195
drop table p_t1;
11961196
--
1197+
-- Test GROUP BY matching of join columns that are type-coerced due to USING
1198+
--
1199+
create temp table t1(f1 int, f2 bigint);
1200+
create temp table t2(f1 bigint, f22 bigint);
1201+
select f1 from t1 left join t2 using (f1) group by f1;
1202+
f1
1203+
----
1204+
(0 rows)
1205+
1206+
select f1 from t1 left join t2 using (f1) group by t1.f1;
1207+
f1
1208+
----
1209+
(0 rows)
1210+
1211+
select t1.f1 from t1 left join t2 using (f1) group by t1.f1;
1212+
f1
1213+
----
1214+
(0 rows)
1215+
1216+
-- only this one should fail:
1217+
select t1.f1 from t1 left join t2 using (f1) group by f1;
1218+
ERROR: column "t1.f1" must appear in the GROUP BY clause or be used in an aggregate function
1219+
LINE 1: select t1.f1 from t1 left join t2 using (f1) group by f1;
1220+
^
1221+
drop table t1, t2;
1222+
--
11971223
-- Test combinations of DISTINCT and/or ORDER BY
11981224
--
11991225
select array_agg(a order by b)

‎src/test/regress/sql/aggregates.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,21 @@ drop table t2;
432432
droptable t3;
433433
droptable p_t1;
434434

435+
--
436+
-- Test GROUP BY matching of join columns that are type-coerced due to USING
437+
--
438+
439+
create temp table t1(f1int, f2bigint);
440+
create temp table t2(f1bigint, f22bigint);
441+
442+
select f1from t1left join t2 using (f1)group by f1;
443+
select f1from t1left join t2 using (f1)group byt1.f1;
444+
selectt1.f1from t1left join t2 using (f1)group byt1.f1;
445+
-- only this one should fail:
446+
selectt1.f1from t1left join t2 using (f1)group by f1;
447+
448+
droptable t1, t2;
449+
435450
--
436451
-- Test combinations of DISTINCT and/or ORDER BY
437452
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp