Skip to content

Commit

Permalink
[release-19.0] Fix TPCH test by providing the correct field informati…
Browse files Browse the repository at this point in the history
…on in evalengine (#15623) (#15655)

Signed-off-by: Manan Gupta <[email protected]>
Signed-off-by: Dirkjan Bussink <[email protected]>
Co-authored-by: Manan Gupta <[email protected]>
Co-authored-by: Dirkjan Bussink <[email protected]>
Co-authored-by: Manan Gupta <[email protected]>
  • Loading branch information
4 people authored Apr 4, 2024
1 parent c29371b commit 9f5a25d
Show file tree
Hide file tree
Showing 13 changed files with 815 additions and 13 deletions.
4 changes: 2 additions & 2 deletions go/test/endtoend/utils/cmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ func (mcmp *MySQLCompare) ExecAndIgnore(query string) (*sqltypes.Result, error)
return mcmp.VtConn.ExecuteFetch(query, 1000, true)
}

func (mcmp *MySQLCompare) Run(query string, f func(mcmp *MySQLCompare)) {
mcmp.t.Run(query, func(t *testing.T) {
func (mcmp *MySQLCompare) Run(name string, f func(mcmp *MySQLCompare)) {
mcmp.t.Run(name, func(t *testing.T) {
inner := &MySQLCompare{
t: t,
MySQLConn: mcmp.MySQLConn,
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 9f5a25d

Please sign in to comment.