Skip to content

Commit

Permalink
[release-18.0] Fix panic in aggregation (#15728) (#15735)
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
Co-authored-by: Manan Gupta <[email protected]>
Co-authored-by: Manan Gupta <[email protected]>
  • Loading branch information
3 people authored Apr 18, 2024
1 parent 9df99ee commit d914e0e
Show file tree
Hide file tree
Showing 7 changed files with 661 additions and 4 deletions.
4 changes: 2 additions & 2 deletions go/test/endtoend/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func WaitForAuthoritative(t *testing.T, ks, tbl string, readVSchema func() (*int
for {
select {
case <-timeout:
return fmt.Errorf("schema tracking didn't mark table t2 as authoritative until timeout")
return fmt.Errorf("schema tracking didn't mark table %v.%v as authoritative until timeout", ks, tbl)
default:
time.Sleep(1 * time.Second)
res, err := readVSchema()
Expand Down Expand Up @@ -286,7 +286,7 @@ func WaitForColumn(t *testing.T, vtgateProcess cluster.VtgateProcess, ks, tbl, c
if !isMap {
break
}
if colName, exists := colDef["name"]; exists && colName == col {
if colName, exists := colDef["name"]; exists && strings.EqualFold(colName.(string), col) {
return nil
}
}
Expand Down
89 changes: 89 additions & 0 deletions go/test/endtoend/vtgate/queries/tpch/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
Copyright 2024 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package union

import (
_ "embed"
"flag"
"fmt"
"os"
"testing"

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/test/endtoend/utils"
)

var (
clusterInstance *cluster.LocalProcessCluster
vtParams mysql.ConnParams
mysqlParams mysql.ConnParams
keyspaceName = "ks"
cell = "zone-1"

//go:embed schema.sql
schemaSQL string

//go:embed vschema.json
vschema string
)

func TestMain(m *testing.M) {
defer cluster.PanicHandler(nil)
flag.Parse()

exitCode := func() int {
clusterInstance = cluster.NewCluster(cell, "localhost")
defer clusterInstance.Teardown()

// Start topo server
err := clusterInstance.StartTopo()
if err != nil {
return 1
}

// Start keyspace
keyspace := &cluster.Keyspace{
Name: keyspaceName,
SchemaSQL: schemaSQL,
VSchema: vschema,
}
err = clusterInstance.StartKeyspace(*keyspace, []string{"-80", "80-"}, 0, false)
if err != nil {
return 1
}

// Start vtgate
err = clusterInstance.StartVtgate()
if err != nil {
return 1
}

vtParams = clusterInstance.GetVTParams(keyspaceName)

// create mysql instance and connection parameters
conn, closer, err := utils.NewMySQL(clusterInstance, keyspaceName, schemaSQL)
if err != nil {
fmt.Println(err)
return 1
}
defer closer()
mysqlParams = conn
return m.Run()
}()
os.Exit(exitCode)
}
291 changes: 291 additions & 0 deletions go/test/endtoend/vtgate/queries/tpch/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
CREATE TABLE IF NOT EXISTS nation
(
N_NATIONKEY
INTEGER
NOT
NULL,
N_NAME
CHAR
(
25
) NOT NULL,
N_REGIONKEY INTEGER NOT NULL,
N_COMMENT VARCHAR
(
152
),
PRIMARY KEY
(
N_NATIONKEY
));

CREATE TABLE IF NOT EXISTS region
(
R_REGIONKEY
INTEGER
NOT
NULL,
R_NAME
CHAR
(
25
) NOT NULL,
R_COMMENT VARCHAR
(
152
),
PRIMARY KEY
(
R_REGIONKEY
));

CREATE TABLE IF NOT EXISTS part
(
P_PARTKEY
INTEGER
NOT
NULL,
P_NAME
VARCHAR
(
55
) NOT NULL,
P_MFGR CHAR
(
25
) NOT NULL,
P_BRAND CHAR
(
10
) NOT NULL,
P_TYPE VARCHAR
(
25
) NOT NULL,
P_SIZE INTEGER NOT NULL,
P_CONTAINER CHAR
(
10
) NOT NULL,
P_RETAILPRICE DECIMAL
(
15,
2
) NOT NULL,
P_COMMENT VARCHAR
(
23
) NOT NULL,
PRIMARY KEY
(
P_PARTKEY
));

CREATE TABLE IF NOT EXISTS supplier
(
S_SUPPKEY
INTEGER
NOT
NULL,
S_NAME
CHAR
(
25
) NOT NULL,
S_ADDRESS VARCHAR
(
40
) NOT NULL,
S_NATIONKEY INTEGER NOT NULL,
S_PHONE CHAR
(
15
) NOT NULL,
S_ACCTBAL DECIMAL
(
15,
2
) NOT NULL,
S_COMMENT VARCHAR
(
101
) NOT NULL,
PRIMARY KEY
(
S_SUPPKEY
));

CREATE TABLE IF NOT EXISTS partsupp
(
PS_PARTKEY
INTEGER
NOT
NULL,
PS_SUPPKEY
INTEGER
NOT
NULL,
PS_AVAILQTY
INTEGER
NOT
NULL,
PS_SUPPLYCOST
DECIMAL
(
15,
2
) NOT NULL,
PS_COMMENT VARCHAR
(
199
) NOT NULL,
PRIMARY KEY
(
PS_PARTKEY,
PS_SUPPKEY
));

CREATE TABLE IF NOT EXISTS customer
(
C_CUSTKEY
INTEGER
NOT
NULL,
C_NAME
VARCHAR
(
25
) NOT NULL,
C_ADDRESS VARCHAR
(
40
) NOT NULL,
C_NATIONKEY INTEGER NOT NULL,
C_PHONE CHAR
(
15
) NOT NULL,
C_ACCTBAL DECIMAL
(
15,
2
) NOT NULL,
C_MKTSEGMENT CHAR
(
10
) NOT NULL,
C_COMMENT VARCHAR
(
117
) NOT NULL,
PRIMARY KEY
(
C_CUSTKEY
));

CREATE TABLE IF NOT EXISTS orders
(
O_ORDERKEY
INTEGER
NOT
NULL,
O_CUSTKEY
INTEGER
NOT
NULL,
O_ORDERSTATUS
CHAR
(
1
) NOT NULL,
O_TOTALPRICE DECIMAL
(
15,
2
) NOT NULL,
O_ORDERDATE DATE NOT NULL,
O_ORDERPRIORITY CHAR
(
15
) NOT NULL,
O_CLERK CHAR
(
15
) NOT NULL,
O_SHIPPRIORITY INTEGER NOT NULL,
O_COMMENT VARCHAR
(
79
) NOT NULL,
PRIMARY KEY
(
O_ORDERKEY
));

CREATE TABLE IF NOT EXISTS lineitem
(
L_ORDERKEY
INTEGER
NOT
NULL,
L_PARTKEY
INTEGER
NOT
NULL,
L_SUPPKEY
INTEGER
NOT
NULL,
L_LINENUMBER
INTEGER
NOT
NULL,
L_QUANTITY
DECIMAL
(
15,
2
) NOT NULL,
L_EXTENDEDPRICE DECIMAL
(
15,
2
) NOT NULL,
L_DISCOUNT DECIMAL
(
15,
2
) NOT NULL,
L_TAX DECIMAL
(
15,
2
) NOT NULL,
L_RETURNFLAG CHAR
(
1
) NOT NULL,
L_LINESTATUS CHAR
(
1
) NOT NULL,
L_SHIPDATE DATE NOT NULL,
L_COMMITDATE DATE NOT NULL,
L_RECEIPTDATE DATE NOT NULL,
L_SHIPINSTRUCT CHAR
(
25
) NOT NULL,
L_SHIPMODE CHAR
(
10
) NOT NULL,
L_COMMENT VARCHAR
(
44
) NOT NULL,
PRIMARY KEY
(
L_ORDERKEY,
L_LINENUMBER
));
Loading

0 comments on commit d914e0e

Please sign in to comment.