Skip to content
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
20 changes: 18 additions & 2 deletions enginetest/queries/script_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -13472,24 +13472,40 @@ select * from t1 except (
},
},
{
// https://github.com/dolthub/dolt/issues/10070
// https://github.com/dolthub/dolt/issues/10092
Name: "NOT EXISTS with nullable filter",
SetUpScript: []string{
"CREATE TABLE t0(c0 INT , c1 INT);",
"INSERT INTO t0(c0, c1) VALUES (1, -2);",
"create table t1(c0 int, primary key(c0))",
"insert into t1 values (1)",
"create table t2(c0 varchar(500), primary key(c0))",
"insert into t2 values ('9')",
"create table t3(c0 boolean, primary key(c0))",
"insert into t3 values(false)",
},
Assertions: []ScriptTestAssertion{
{
// https://github.com/dolthub/dolt/issues/10070
Query: `SELECT * FROM t0 WHERE NOT EXISTS (SELECT 1 FROM (SELECT 1) alias0 WHERE (CASE -1 WHEN t0.c1 THEN false END));`,
Expected: []sql.Row{{1, -2}},
},
{
// https://github.com/dolthub/dolt/issues/10092
Query: "select * from t1 where not exists (select 1 from (select 1) as subquery where weekday(t1.c0))",
Expected: []sql.Row{{1}},
},
{
// https://github.com/dolthub/dolt/issues/10102
Query: "SELECT * FROM t2 WHERE NOT EXISTS (SELECT 1 FROM (SELECT 1) AS sub0 WHERE ASIN(t2.c0));",
Expected: []sql.Row{{"9"}},
// Postgres does not allow varchar types as inputs for ASIN
Dialect: "mysql",
},
{
// https://github.com/dolthub/dolt/issues/10157
Query: "SELECT * FROM t3 WHERE NOT EXISTS (SELECT 1 FROM (SELECT 1) AS sub0 WHERE LOG2(t3.c0));",
Expected: []sql.Row{{0}},
},
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions sql/expression/function/logarithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (*LogBase) CollationCoercibility(ctx *sql.Context) (collation sql.Collation

// IsNullable implements the sql.Expression interface.
func (l *LogBase) IsNullable() bool {
return l.base == float64(1) || l.base <= float64(0) || l.Child.IsNullable()
return true
}

// Eval implements the Expression interface.
Expand Down Expand Up @@ -196,7 +196,7 @@ func (*Log) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID,

// IsNullable implements the Expression interface.
func (l *Log) IsNullable() bool {
return l.LeftChild.IsNullable() || l.RightChild.IsNullable()
return true
}

// Eval implements the Expression interface.
Expand Down
25 changes: 25 additions & 0 deletions sql/expression/function/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ func (*Tan) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID,
return sql.Collation_binary, 5
}

// IsNullable implements sql.Expression
func (t *Tan) IsNullable() bool {
return true
}

// Eval implements sql.Expression
func (t *Tan) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
val, err := t.EvalChild(ctx, row)
Expand Down Expand Up @@ -325,6 +330,11 @@ func (*Asin) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID,
return sql.Collation_binary, 5
}

// IsNullable implements sql.Expression
func (a *Asin) IsNullable() bool {
return true
}

// Eval implements sql.Expression
func (a *Asin) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
val, err := a.EvalChild(ctx, row)
Expand Down Expand Up @@ -382,6 +392,11 @@ func (*Acos) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID,
return sql.Collation_binary, 5
}

// IsNullable implements sql.Expression
func (a *Acos) IsNullable() bool {
return true
}

// Eval implements sql.Expression
func (a *Acos) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
val, err := a.EvalChild(ctx, row)
Expand Down Expand Up @@ -559,6 +574,11 @@ func (*Cot) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID,
return sql.Collation_binary, 5
}

// IsNullable implements sql.Expression
func (c *Cot) IsNullable() bool {
return true
}

// Eval implements sql.Expression
func (c *Cot) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
val, err := c.EvalChild(ctx, row)
Expand Down Expand Up @@ -991,6 +1011,11 @@ func (e *Exp) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID
return sql.Collation_binary, 5
}

// IsNullable implements sql.Expression
func (e *Exp) IsNullable() bool {
return true
}

// Eval implements the Expression interface.
func (e *Exp) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
if e.Child == nil {
Expand Down