Skip to content
Snippets Groups Projects
Unverified Commit 0f095e5c authored by iamlinjunhong's avatar iamlinjunhong Committed by GitHub
Browse files

fix coalesce and cast bugs and add syntax of commit work (#4783)

Approved by: @ouyuanning, @aressu1985
parent ecaef770
Branches
No related tags found
No related merge requests found
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -1482,6 +1482,10 @@ completion_type:
{
$$ = tree.COMPLETION_TYPE_NO_CHAIN
}
| WORK
{
$$ = tree.COMPLETION_TYPE_NO_CHAIN
}
| AND CHAIN NO RELEASE
{
$$ = tree.COMPLETION_TYPE_CHAIN
......
......@@ -52,6 +52,9 @@ var (
input string
output string
}{{
input: "commit work",
output: "commit",
}, {
input: "select * from tables",
}, {
input: "update t1 set a = default",
......
......@@ -1027,9 +1027,6 @@ func (b *baseBinder) bindNumVal(astExpr *tree.NumVal, typ *Type) (*Expr, error)
case tree.P_bit:
return returnDecimalExpr(astExpr.String())
case tree.P_char:
if typ != nil && typ.Id != int32(types.T_char) && typ.Id != int32(types.T_varchar) {
return appendCastBeforeExpr(getStringExpr(astExpr.String()), typ)
}
expr := getStringExpr(astExpr.String())
return expr, nil
default:
......
......@@ -143,6 +143,9 @@ func coalesceGeneral[T NormalType](vs []*vector.Vector, proc *process.Process, t
for i := startIdx; i < len(vs); i++ {
input := vs[i]
if input.Typ.Oid != types.T_any {
rs.Typ = input.Typ
}
cols := vector.MustTCols[T](input)
if input.IsScalar() {
if input.IsScalarNull() {
......
......@@ -37,9 +37,7 @@ DROP TABLE t0;
# Comparison
CREATE TABLE t1 (a char(10), b INT);
INSERT INTO t1 VALUES ('', 0);
-- @bvt:issue#4696
SELECT COALESCE(a) = COALESCE(b) FROM t1;
-- @bvt:issue
DROP TABLE t1;
# ORDER BY clause, DATE TYPE
......@@ -118,10 +116,8 @@ drop table it3;
#DATATYPE, distinct
CREATE TABLE t1 (dt2 DATETIME(2), t3 TIMESTAMP, d DATE);
INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '2001-01-01 00:00:00.567', '2002-01-01');
-- @bvt:issue#4696
SELECT distinct COALESCE(dt2, t3) FROM t1;
SELECT CONCAT_WS(",", COALESCE(dt2, t3)) FROM t1;
-- @bvt:issue
DROP TABLE t1;
#SELECT 嵌套
......
......@@ -39,8 +39,7 @@ DROP TABLE t0;
CREATE TABLE t1 (a char(10), b INT);
INSERT INTO t1 VALUES ('', 0);
SELECT COALESCE(a) = COALESCE(b) FROM t1;
COALESCE(a) = COALESCE(b)
1
Can't cast column from CHAR type to INT type because of one or more values in that column.
DROP TABLE t1;
CREATE TABLE t1 ( a INTEGER, b varchar(255) );
INSERT INTO t1 VALUES (1,'z');
......
......@@ -82,9 +82,9 @@ coalesce(b, 2022-10-01)
select coalesce(b, '2022-10-01 10:10:10.999999') from t2;
coalesce(b, 2022-10-01 10:10:10.999999)
2022-02-20 10:10:11
2022-10-01 10:10:10
2022-10-01 10:10:10.999999000
2023-04-03 22:10:30
2022-10-01 10:10:10
2022-10-01 10:10:10.999999000
select coalesce(b, '2022') from t2;
Can't cast '2022' from VARCHAR type to DATETIME type.
select coalesce(b, '2022/10/01') from t2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment