mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-03 03:10:26 -05:00
added alternative enginetest query plans for nbf __DOLT_1__
This commit is contained in:
@@ -68,7 +68,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220608200020-bfd14203a2b8
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220609192725-a2b74bdc6a64
|
||||
github.com/google/flatbuffers v2.0.6+incompatible
|
||||
github.com/gosuri/uilive v0.0.4
|
||||
github.com/kch42/buzhash v0.0.0-20160816060738-9bdec3dec7c6
|
||||
|
||||
@@ -180,6 +180,12 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
|
||||
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220608200020-bfd14203a2b8 h1:wSei9vEJ+1OGzqLtPrCAKvn6tejx+ciZ8crNSspvIIc=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220608200020-bfd14203a2b8/go.mod h1:gvDEMITJQDVYDLR4XtcqEZx6rawTvMh2veM1bPsJC3I=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220609185103-d9747f44d1be h1:Kx8gvR2n06k9xyeKoqwSzFdsplToszCK/cJk9NMmSuA=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220609185103-d9747f44d1be/go.mod h1:gvDEMITJQDVYDLR4XtcqEZx6rawTvMh2veM1bPsJC3I=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220609191211-4d5fc1efeb17 h1:jgS5TWuAh1+XblNQnPkwl3jkGNdccpj3aYp4XTg5/Us=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220609191211-4d5fc1efeb17/go.mod h1:gvDEMITJQDVYDLR4XtcqEZx6rawTvMh2veM1bPsJC3I=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220609192725-a2b74bdc6a64 h1:gSFE+R7a0AsD640bX6pv/iHYJVph5lRZDmkZe6GsNxI=
|
||||
github.com/dolthub/go-mysql-server v0.11.1-0.20220609192725-a2b74bdc6a64/go.mod h1:gvDEMITJQDVYDLR4XtcqEZx6rawTvMh2veM1bPsJC3I=
|
||||
github.com/dolthub/ishell v0.0.0-20220112232610-14e753f0f371 h1:oyPHJlzumKta1vnOQqUnfdz+pk3EmnHS3Nd0cCT0I2g=
|
||||
github.com/dolthub/ishell v0.0.0-20220112232610-14e753f0f371/go.mod h1:dhGBqcCEfK5kuFmeO5+WOx3hqc1k3M29c1oS/R7N4ms=
|
||||
github.com/dolthub/jsonpath v0.0.0-20210609232853-d49537a30474 h1:xTrR+l5l+1Lfq0NvhiEsctylXinUMFhhsqaEcl414p8=
|
||||
|
||||
@@ -145,8 +145,6 @@ func TestVersionedQueries(t *testing.T) {
|
||||
// Tests of choosing the correct execution plan independent of result correctness. Mostly useful for confirming that
|
||||
// the right indexes are being used for joining tables.
|
||||
func TestQueryPlans(t *testing.T) {
|
||||
skipNewFormat(t)
|
||||
|
||||
// Dolt supports partial keys, so the index matched is different for some plans
|
||||
// TODO: Fix these differences by implementing partial key matching in the memory tables, or the engine itself
|
||||
skipped := []string{
|
||||
@@ -158,10 +156,18 @@ func TestQueryPlans(t *testing.T) {
|
||||
"SELECT pk,pk1,pk2 FROM one_pk LEFT JOIN two_pk ON pk=pk1 ORDER BY 1,2,3",
|
||||
"SELECT pk,pk1,pk2 FROM one_pk t1, two_pk t2 WHERE pk=1 AND pk2=1 AND pk1=1 ORDER BY 1,2",
|
||||
}
|
||||
|
||||
// Parallelism introduces Exchange nodes into the query plans, so disable.
|
||||
// TODO: exchange nodes should really only be part of the explain plan under certain debug settings
|
||||
enginetest.TestQueryPlans(t, newDoltHarness(t).WithParallelism(1).WithSkippedQueries(skipped))
|
||||
harness := newDoltHarness(t).WithParallelism(1).WithSkippedQueries(skipped)
|
||||
|
||||
var plans []queries.QueryPlanTest
|
||||
if types.IsFormat_DOLT_1(types.Format_Default) {
|
||||
plans = NewFormatQueryPlanTests
|
||||
} else {
|
||||
plans = queries.PlanTests
|
||||
}
|
||||
|
||||
enginetest.TestQueryPlans(t, harness, plans)
|
||||
}
|
||||
|
||||
func TestDoltDiffQueryPlans(t *testing.T) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,89 @@
|
||||
// Copyright 2022 Dolthub, Inc.
|
||||
//
|
||||
// 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 enginetest
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/dolthub/go-mysql-server/sql/parse"
|
||||
|
||||
"github.com/dolthub/go-mysql-server/enginetest"
|
||||
"github.com/dolthub/go-mysql-server/enginetest/queries"
|
||||
"github.com/dolthub/go-mysql-server/enginetest/scriptgen/setup"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGenNewFormatQueryPlans(t *testing.T) {
|
||||
// must run with env var: DOLT_DEFAULT_BIN_FORMAT="__DOLT_1__"
|
||||
t.Skip()
|
||||
harness := newDoltHarness(t).WithParallelism(1)
|
||||
harness.Setup(setup.SimpleSetup...)
|
||||
engine, err := harness.NewEngine(t)
|
||||
require.NoError(t, err)
|
||||
|
||||
tmp, err := ioutil.TempDir("", "*")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
outputPath := filepath.Join(tmp, "queryPlans.txt")
|
||||
f, err := os.Create(outputPath)
|
||||
require.NoError(t, err)
|
||||
|
||||
w := bufio.NewWriter(f)
|
||||
_, _ = w.WriteString("var NewFormatQueryPlanTests = []queries.QueryPlanTest{\n")
|
||||
for _, tt := range queries.PlanTests {
|
||||
_, _ = w.WriteString("\t{\n")
|
||||
ctx := enginetest.NewContextWithEngine(harness, engine)
|
||||
parsed, err := parse.Parse(ctx, tt.Query)
|
||||
require.NoError(t, err)
|
||||
|
||||
node, err := engine.Analyzer.Analyze(ctx, parsed, nil)
|
||||
require.NoError(t, err)
|
||||
planString := enginetest.ExtractQueryNode(node).String()
|
||||
|
||||
if strings.Contains(tt.Query, "`") {
|
||||
_, _ = w.WriteString(fmt.Sprintf(`Query: "%s",`, tt.Query))
|
||||
} else {
|
||||
_, _ = w.WriteString(fmt.Sprintf("Query: `%s`,", tt.Query))
|
||||
}
|
||||
_, _ = w.WriteString("\n")
|
||||
|
||||
_, _ = w.WriteString(`ExpectedPlan: `)
|
||||
for i, line := range strings.Split(planString, "\n") {
|
||||
if i > 0 {
|
||||
_, _ = w.WriteString(" + \n")
|
||||
}
|
||||
if len(line) > 0 {
|
||||
_, _ = w.WriteString(fmt.Sprintf(`"%s\n"`, strings.ReplaceAll(line, `"`, `\"`)))
|
||||
} else {
|
||||
// final line with comma
|
||||
_, _ = w.WriteString("\"\",\n")
|
||||
}
|
||||
}
|
||||
_, _ = w.WriteString("\t},\n")
|
||||
}
|
||||
_, _ = w.WriteString("}")
|
||||
|
||||
_ = w.Flush()
|
||||
|
||||
t.Logf("Query plans in %s", outputPath)
|
||||
}
|
||||
Reference in New Issue
Block a user