Skip to content

Commit 643b852

Browse files
authored
Merge pull request #3218 from dolthub/angelamayxie-753c4480
[auto-bump] [no-release-notes] dependency by angelamayxie
2 parents 01c2ce0 + 545a703 commit 643b852

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+6182
-5252
lines changed

.github/workflows/test.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,31 @@ jobs:
1818
uses: actions/setup-go@v5
1919
with:
2020
go-version-file: go.mod
21+
- name: Install ICU4C (MacOS)
22+
if: ${{ matrix.platform == 'macos-latest' }}
23+
run: |
24+
dir=$(brew --cellar icu4c)
25+
dir="$dir"/$(ls "$dir")
26+
echo CGO_CPPFLAGS=-I$dir/include >> $GITHUB_ENV
27+
echo CGO_LDFLAGS=-L$dir/lib >> $GITHUB_ENV
28+
- name: Install ICU4C (Windows)
29+
if: ${{ matrix.platform == 'windows-latest' }}
30+
uses: msys2/setup-msys2@v2
31+
with:
32+
path-type: inherit
33+
msystem: UCRT64
34+
pacboy: icu:p toolchain:p pkg-config:p
2135
- name: Test
22-
if: ${{ matrix.platform != 'ubuntu-latest' }}
36+
if: ${{ matrix.platform == 'macos-latest' }}
2337
run: go test ./...
2438
env:
2539
CI_TEST: "true"
40+
- name: Test
41+
if: ${{ matrix.platform == 'windows-latest' }}
42+
shell: msys2 {0}
43+
run: go.exe test ./...
44+
env:
45+
CI_TEST: "true"
2646
- name: Test
2747
if: ${{ matrix.platform == 'ubuntu-latest' }}
2848
run: go test -race ./...

enginetest/join_op_tests.go

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,61 @@ var EngineOnlyJoinOpTests = []joinOpTest{
105105
}
106106

107107
var DefaultJoinOpTests = []joinOpTest{
108+
{
109+
// https://github.com/dolthub/dolt/issues/9807
110+
name: "FULL OUTER JOIN fails with empty subquery",
111+
setup: [][]string{
112+
{
113+
"CREATE TABLE t(c BOOLEAN);",
114+
"INSERT INTO t VALUES (FALSE);",
115+
},
116+
},
117+
tests: []JoinOpTests{
118+
{
119+
Query: "SELECT * FROM ( SELECT c FROM t WHERE c ) sub1 FULL OUTER JOIN ( SELECT 1 AS c ) sub2 ON 1=1;",
120+
Expected: []sql.Row{
121+
{nil, 1},
122+
},
123+
},
124+
},
125+
},
126+
{
127+
// https://github.com/dolthub/dolt/issues/9807
128+
name: "FULL OUTER JOIN with empty tables",
129+
setup: [][]string{
130+
{
131+
"CREATE TABLE t1 (i INT);",
132+
"CREATE TABLE t2 (j INT);",
133+
"INSERT INTO t2 VALUES (1);",
134+
},
135+
},
136+
tests: []JoinOpTests{
137+
{
138+
Query: "SELECT i, j FROM t1 FULL OUTER JOIN t2 ON 1=1;",
139+
Expected: []sql.Row{
140+
{nil, 1},
141+
},
142+
},
143+
{
144+
Query: "SELECT j, i FROM t2 FULL OUTER JOIN t1 ON 1=1;",
145+
Expected: []sql.Row{
146+
{1, nil},
147+
},
148+
},
149+
{
150+
Query: "SELECT i, j FROM t1 FULL OUTER JOIN t2 ON 1=0;",
151+
Expected: []sql.Row{
152+
{nil, 1},
153+
},
154+
},
155+
{
156+
Query: "SELECT j, i FROM t2 FULL OUTER JOIN t1 ON 1=0;",
157+
Expected: []sql.Row{
158+
{1, nil},
159+
},
160+
},
161+
},
162+
},
108163
{
109164
name: "bug where transitive join edge drops filters",
110165
setup: [][]string{
@@ -1922,15 +1977,55 @@ SELECT SUM(x) FROM xy WHERE x IN (
19221977
},
19231978
},
19241979
{
1925-
name: "where not exists",
1980+
name: "where exists and where not exists",
19261981
setup: [][]string{
19271982
setup.XyData[0],
1983+
{
1984+
"create table t(c varchar(500))",
1985+
"insert into t values ('a'),('a')",
1986+
"create table u(c0 int, c1 int, primary key(c0, c1))",
1987+
"insert into u values (1, 1),(2,2),(2,3)",
1988+
},
19281989
},
19291990
tests: []JoinOpTests{
19301991
{
19311992
Query: `select * from xy_hasnull x where not exists(select 1 from ab_hasnull a where a.b = x.y)`,
19321993
Expected: []sql.Row{{1, 0}, {3, nil}},
19331994
},
1995+
{
1996+
Query: "select x from xy where exists (select 1 from ab where ab.b = -1)",
1997+
Expected: []sql.Row{},
1998+
},
1999+
{
2000+
Query: "select x from xy where exists (select 1 from ab where ab.b = xy.y)",
2001+
Expected: []sql.Row{{0}, {2}},
2002+
},
2003+
{
2004+
Query: "select x from xy where not exists (select 1 from ab where ab.b = xy.y)",
2005+
Expected: []sql.Row{{1}, {3}},
2006+
},
2007+
{
2008+
Query: "select x from xy_hasnull where not exists(select 1 from ab_hasnull where ab_hasnull.b <> xy_hasnull.y)",
2009+
Expected: []sql.Row{{3}},
2010+
},
2011+
{
2012+
Query: "select x from xy_hasnull_idx where exists(select 1 from rs where rs.s = xy_hasnull_idx.y)",
2013+
Expected: []sql.Row{{1}},
2014+
},
2015+
{
2016+
Query: "select x from xy_hasnull_idx where not exists(select 1 from rs where rs.s = xy_hasnull_idx.y)",
2017+
Expected: []sql.Row{{2}, {0}, {3}},
2018+
},
2019+
{
2020+
// https://github.com/dolthub/dolt/issues/9828
2021+
Query: "with v as (select 'a' as c where false) select null from t where not exists (select 1 from v where v.c <> t.c);",
2022+
Expected: []sql.Row{{nil}, {nil}},
2023+
},
2024+
{
2025+
// https://github.com/dolthub/dolt/issues/9797
2026+
Query: "select * from u where exists (select 1 from u as x where x.c0 = u.c0)",
2027+
Expected: []sql.Row{{1, 1}, {2, 2}, {2, 3}},
2028+
},
19342029
},
19352030
},
19362031
{

enginetest/join_planning_tests.go

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,34 @@ join uv d on d.u = c.x`,
17881788
},
17891789
},
17901790
},
1791+
{
1792+
name: "single look up plan does not drop complex equality filters",
1793+
setup: []string{
1794+
"create table t1 (i int primary key);",
1795+
"create table t2 (j int);",
1796+
"create table t3 (k int);",
1797+
"insert into t1 values (1), (2);",
1798+
"insert into t2 values (1), (2);",
1799+
"insert into t3 values (3);",
1800+
},
1801+
tests: []JoinPlanTest{
1802+
{
1803+
q: "select * from t1 cross join t2 join (select * from t3) v3 on v3.k = t2.j;",
1804+
types: []plan.JoinType{plan.JoinTypeHash, plan.JoinTypeCross},
1805+
exp: []sql.Row{},
1806+
},
1807+
{
1808+
q: "select * from t1 cross join t2 join (select * from t3) v3 on v3.k >= t2.j order by i, j, k;",
1809+
types: []plan.JoinType{plan.JoinTypeInner, plan.JoinTypeCross},
1810+
exp: []sql.Row{
1811+
{1, 1, 3},
1812+
{1, 2, 3},
1813+
{2, 1, 3},
1814+
{2, 2, 3},
1815+
},
1816+
},
1817+
},
1818+
},
17911819
}
17921820

17931821
func TestJoinPlanning(t *testing.T, harness Harness) {
@@ -1915,24 +1943,28 @@ func evalIndexTest(t *testing.T, harness Harness, e QueryEngine, q string, index
19151943
})
19161944
}
19171945

1918-
func evalJoinCorrectness(t *testing.T, harness Harness, e QueryEngine, name, q string, exp []sql.Row, skipOld bool) {
1919-
t.Run(name, func(t *testing.T) {
1920-
ctx := NewContext(harness)
1921-
ctx = ctx.WithQuery(q)
1946+
func evalJoinCorrectness(t *testing.T, harness Harness, e QueryEngine, name, q string, exp []sql.Row, skip bool) {
1947+
if skip {
1948+
t.Skip()
1949+
} else {
1950+
t.Run(name, func(t *testing.T) {
1951+
ctx := NewContext(harness)
1952+
ctx = ctx.WithQuery(q)
19221953

1923-
sch, iter, _, err := e.QueryWithBindings(ctx, q, nil, nil, nil)
1924-
require.NoError(t, err, "Unexpected error for query %s: %s", q, err)
1954+
sch, iter, _, err := e.QueryWithBindings(ctx, q, nil, nil, nil)
1955+
require.NoError(t, err, "Unexpected error for query %s: %s", q, err)
19251956

1926-
rows, err := sql.RowIterToRows(ctx, iter)
1927-
require.NoError(t, err, "Unexpected error for query %s: %s", q, err)
1957+
rows, err := sql.RowIterToRows(ctx, iter)
1958+
require.NoError(t, err, "Unexpected error for query %s: %s", q, err)
19281959

1929-
if exp != nil {
1930-
CheckResults(ctx, t, harness, exp, nil, sch, rows, q, e)
1931-
}
1960+
if exp != nil {
1961+
CheckResults(ctx, t, harness, exp, nil, sch, rows, q, e)
1962+
}
19321963

1933-
require.Equal(t, 0, ctx.Memory.NumCaches())
1934-
validateEngine(t, ctx, harness, e)
1935-
})
1964+
require.Equal(t, 0, ctx.Memory.NumCaches())
1965+
validateEngine(t, ctx, harness, e)
1966+
})
1967+
}
19361968
}
19371969

19381970
func collectJoinTypes(n sql.Node) []plan.JoinType {

enginetest/queries/alter_table_queries.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,6 +2107,28 @@ var AddColumnScripts = []ScriptTest{
21072107
},
21082108
},
21092109
},
2110+
{
2111+
Name: "add column with check constraint",
2112+
SetUpScript: []string{
2113+
"create table t (i int primary key, j int)",
2114+
"insert into t values (1, 2)",
2115+
},
2116+
Assertions: []ScriptTestAssertion{
2117+
{
2118+
Query: "alter table t add column k int check (k > 0)",
2119+
// TODO: this should be 1 rowsAffected https://github.com/dolthub/dolt/issues/9606
2120+
Expected: []sql.Row{{types.NewOkResult(0)}},
2121+
},
2122+
{
2123+
Query: "alter table t add column l int check (l is not null)",
2124+
ExpectedErr: sql.ErrCheckConstraintViolated,
2125+
},
2126+
{
2127+
Query: "alter table t add column m int default 0 check (m != 0)",
2128+
ExpectedErr: sql.ErrCheckConstraintViolated,
2129+
},
2130+
},
2131+
},
21102132
{
21112133
Name: "error cases",
21122134
Assertions: []ScriptTestAssertion{

enginetest/queries/function_queries.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,26 @@ var FunctionQueryTests = []QueryTest{
569569
{
570570
Query: "SELECT BIT_LENGTH(i) from mytable order by i limit 1",
571571
Expected: []sql.Row{
572-
{64},
572+
{8},
573573
},
574574
},
575+
{
576+
// https://github.com/dolthub/dolt/issues/9818
577+
Query: "select bit_length(10)",
578+
Expected: []sql.Row{{16}},
579+
},
580+
{
581+
Query: "select bit_length(now())",
582+
Expected: []sql.Row{{152}},
583+
},
584+
{
585+
Query: "select bit_length(-10)",
586+
Expected: []sql.Row{{24}},
587+
},
588+
{
589+
Query: "select bit_length(true)",
590+
Expected: []sql.Row{{8}},
591+
},
575592
{
576593
Query: "select date_format(datetime_col, '%D') from datetime_table order by 1",
577594
Expected: []sql.Row{

0 commit comments

Comments
 (0)