Skip to content

Commit 341d399

Browse files
committed
sql/export: extract EXPORT files from sql/importer
There is no point in keeping EXPORT-related files in the same package as IMPORT-related ones. This is beneficial also due to different owners. The only downside is that backports for EXPORT changes won't be clean for a couple of releases. I copied using "large" pool for "heavy" test configs (i.e. duress). Release note: None
1 parent bc50ec9 commit 341d399

File tree

12 files changed

+139
-54
lines changed

12 files changed

+139
-54
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
#!/pkg/sql/BUILD.bazel @cockroachdb/sql-queries-noreview
7878

7979
/pkg/sql/importer/ @cockroachdb/sql-queries-prs
80-
/pkg/sql/importer/export* @cockroachdb/cdc-prs
8180
/pkg/ccl/importerccl/ @cockroachdb/sql-queries-prs
8281

8382
/pkg/sql/appstatspb @cockroachdb/obs-prs
@@ -261,6 +260,7 @@
261260

262261
/pkg/ccl/jobsccl/ @cockroachdb/jobs-prs @cockroachdb/disaster-recovery
263262
/pkg/ccl/changefeedccl/ @cockroachdb/cdc-prs
263+
/pkg/sql/export/ @cockroachdb/cdc-prs
264264

265265
/pkg/crosscluster/ @cockroachdb/disaster-recovery
266266
/pkg/backup/ @cockroachdb/disaster-recovery

pkg/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ ALL_TESTS = [
482482
"//pkg/sql/execinfrapb:execinfrapb_test",
483483
"//pkg/sql/execstats:execstats_disallowed_imports_test",
484484
"//pkg/sql/execstats:execstats_test",
485+
"//pkg/sql/export:export_test",
485486
"//pkg/sql/exprutil:exprutil_test",
486487
"//pkg/sql/flowinfra:flowinfra_disallowed_imports_test",
487488
"//pkg/sql/flowinfra:flowinfra_test",
@@ -1990,6 +1991,8 @@ GO_TARGETS = [
19901991
"//pkg/sql/execstats:execstats",
19911992
"//pkg/sql/execstats:execstats_test",
19921993
"//pkg/sql/execversion:execversion",
1994+
"//pkg/sql/export:export",
1995+
"//pkg/sql/export:export_test",
19931996
"//pkg/sql/exprutil:evalexpr",
19941997
"//pkg/sql/exprutil:exprutil",
19951998
"//pkg/sql/exprutil:exprutil_test",

pkg/sql/export/BUILD.bazel

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "export",
5+
srcs = [
6+
"export_base.go",
7+
"exportcsv.go",
8+
"exportparquet.go",
9+
],
10+
importpath = "github.com/cockroachdb/cockroach/pkg/sql/export",
11+
visibility = ["//visibility:public"],
12+
deps = [
13+
"//pkg/cloud",
14+
"//pkg/roachpb",
15+
"//pkg/settings",
16+
"//pkg/sql/catalog/colinfo",
17+
"//pkg/sql/execinfra",
18+
"//pkg/sql/execinfrapb",
19+
"//pkg/sql/pgwire/pgcode",
20+
"//pkg/sql/pgwire/pgerror",
21+
"//pkg/sql/rowenc",
22+
"//pkg/sql/sem/tree",
23+
"//pkg/sql/types",
24+
"//pkg/util/encoding/csv",
25+
"//pkg/util/mon",
26+
"//pkg/util/parquet",
27+
"//pkg/util/tracing",
28+
"//pkg/util/unique",
29+
"@com_github_cockroachdb_errors//:errors",
30+
],
31+
)
32+
33+
go_test(
34+
name = "export_test",
35+
srcs = [
36+
"exportcsv_test.go",
37+
"exportparquet_test.go",
38+
"main_test.go",
39+
],
40+
exec_properties = select({
41+
"//build/toolchains:is_heavy": {"test.Pool": "large"},
42+
"//conditions:default": {"test.Pool": "default"},
43+
}),
44+
deps = [
45+
":export",
46+
"//pkg/base",
47+
"//pkg/ccl",
48+
"//pkg/col/coldata",
49+
"//pkg/config",
50+
"//pkg/config/zonepb",
51+
"//pkg/kv/kvpb",
52+
"//pkg/kv/kvserver",
53+
"//pkg/multitenant/tenantcapabilitiespb",
54+
"//pkg/security/securityassets",
55+
"//pkg/security/securitytest",
56+
"//pkg/security/username",
57+
"//pkg/server",
58+
"//pkg/settings/cluster",
59+
"//pkg/sql",
60+
"//pkg/sql/catalog/colinfo",
61+
"//pkg/sql/catalog/descidgen",
62+
"//pkg/sql/execinfra",
63+
"//pkg/sql/execinfrapb",
64+
"//pkg/sql/isql",
65+
"//pkg/sql/randgen",
66+
"//pkg/sql/rowenc",
67+
"//pkg/sql/sem/tree",
68+
"//pkg/sql/sessiondata",
69+
"//pkg/sql/types",
70+
"//pkg/testutils",
71+
"//pkg/testutils/serverutils",
72+
"//pkg/testutils/skip",
73+
"//pkg/testutils/sqlutils",
74+
"//pkg/testutils/testcluster",
75+
"//pkg/util/ctxgroup",
76+
"//pkg/util/hlc",
77+
"//pkg/util/leaktest",
78+
"//pkg/util/log",
79+
"//pkg/util/mon",
80+
"//pkg/util/parquet",
81+
"//pkg/util/randutil",
82+
"//pkg/util/syncutil",
83+
"//pkg/workload/bank",
84+
"//pkg/workload/workloadsql",
85+
"@com_github_gogo_protobuf//proto",
86+
"@com_github_jackc_pgx_v5//:pgx",
87+
"@com_github_stretchr_testify//require",
88+
],
89+
)

pkg/sql/importer/export_base.go renamed to pkg/sql/export/export_base.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Use of this software is governed by the CockroachDB Software License
44
// included in the /LICENSE file.
55

6-
package importer
6+
package export
77

88
import (
99
"github.com/cockroachdb/cockroach/pkg/settings"
@@ -22,11 +22,11 @@ var eventMemoryMultipier = settings.RegisterFloatSetting(
2222
settings.FloatWithMinimum(1),
2323
)
2424

25-
// ExportTestingKnobs contains testing knobs for Export.
26-
type ExportTestingKnobs struct {
25+
// TestingKnobs contains testing knobs for Export.
26+
type TestingKnobs struct {
2727
// MemoryMonitor is a test memory monitor to report allocations to.
2828
MemoryMonitor *mon.BytesMonitor
2929
}
3030

3131
// ModuleTestingKnobs is part of the base.ModuleTestingKnobs interface.
32-
func (*ExportTestingKnobs) ModuleTestingKnobs() {}
32+
func (*TestingKnobs) ModuleTestingKnobs() {}

pkg/sql/importer/exportcsv.go renamed to pkg/sql/export/exportcsv.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Use of this software is governed by the CockroachDB Software License
44
// included in the /LICENSE file.
55

6-
package importer
6+
package export
77

88
import (
99
"bytes"
@@ -18,7 +18,6 @@ import (
1818
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
1919
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb"
2020
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
21-
"github.com/cockroachdb/cockroach/pkg/sql/rowexec"
2221
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
2322
"github.com/cockroachdb/cockroach/pkg/sql/types"
2423
"github.com/cockroachdb/cockroach/pkg/util/encoding/csv"
@@ -125,7 +124,7 @@ func newCSVExporter(sp execinfrapb.ExportSpec) *csvExporter {
125124
return exporter
126125
}
127126

128-
func newCSVWriterProcessor(
127+
func NewCSVWriterProcessor(
129128
ctx context.Context,
130129
flowCtx *execinfra.FlowCtx,
131130
processorID int32,
@@ -303,7 +302,3 @@ func (sp *csvWriter) Resume(output execinfra.RowReceiver) {
303302

304303
// Close is part of the execinfra.Processor interface.
305304
func (*csvWriter) Close(context.Context) {}
306-
307-
func init() {
308-
rowexec.NewCSVWriterProcessor = newCSVWriterProcessor
309-
}

pkg/sql/importer/exportcsv_test.go renamed to pkg/sql/export/exportcsv_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Use of this software is governed by the CockroachDB Software License
44
// included in the /LICENSE file.
55

6-
package importer_test
6+
package export_test
77

88
import (
99
"bytes"

pkg/sql/importer/exportparquet.go renamed to pkg/sql/export/exportparquet.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Use of this software is governed by the CockroachDB Software License
44
// included in the /LICENSE file.
55

6-
package importer
6+
package export
77

88
import (
99
"bytes"
@@ -19,7 +19,6 @@ import (
1919
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
2020
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
2121
"github.com/cockroachdb/cockroach/pkg/sql/rowenc"
22-
"github.com/cockroachdb/cockroach/pkg/sql/rowexec"
2322
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
2423
"github.com/cockroachdb/cockroach/pkg/sql/types"
2524
"github.com/cockroachdb/cockroach/pkg/util/parquet"
@@ -48,7 +47,7 @@ func fileName(spec execinfrapb.ExportSpec, part string) string {
4847
return fileName
4948
}
5049

51-
func newParquetWriterProcessor(
50+
func NewParquetWriterProcessor(
5251
ctx context.Context,
5352
flowCtx *execinfra.FlowCtx,
5453
processorID int32,
@@ -251,13 +250,9 @@ func (sp *parquetWriterProcessor) Resume(output execinfra.RowReceiver) {
251250
func (*parquetWriterProcessor) Close(context.Context) {}
252251

253252
// Resume is part of the execinfra.Processor interface.
254-
func (sp *parquetWriterProcessor) testingKnobsOrNil() *ExportTestingKnobs {
253+
func (sp *parquetWriterProcessor) testingKnobsOrNil() *TestingKnobs {
255254
if sp.flowCtx.TestingKnobs().Export == nil {
256255
return nil
257256
}
258-
return sp.flowCtx.TestingKnobs().Export.(*ExportTestingKnobs)
259-
}
260-
261-
func init() {
262-
rowexec.NewParquetWriterProcessor = newParquetWriterProcessor
257+
return sp.flowCtx.TestingKnobs().Export.(*TestingKnobs)
263258
}

pkg/sql/importer/exportparquet_test.go renamed to pkg/sql/export/exportparquet_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Use of this software is governed by the CockroachDB Software License
44
// included in the /LICENSE file.
55

6-
package importer_test
6+
package export_test
77

88
import (
99
"context"
@@ -19,7 +19,7 @@ import (
1919
"github.com/cockroachdb/cockroach/pkg/sql"
2020
"github.com/cockroachdb/cockroach/pkg/sql/catalog/colinfo"
2121
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
22-
"github.com/cockroachdb/cockroach/pkg/sql/importer"
22+
"github.com/cockroachdb/cockroach/pkg/sql/export"
2323
"github.com/cockroachdb/cockroach/pkg/sql/isql"
2424
"github.com/cockroachdb/cockroach/pkg/sql/randgen"
2525
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
@@ -415,7 +415,7 @@ func TestMemoryMonitor(t *testing.T) {
415415
ExternalIODir: dir,
416416
Knobs: base.TestingKnobs{
417417
DistSQL: &execinfra.TestingKnobs{
418-
Export: &importer.ExportTestingKnobs{
418+
Export: &export.TestingKnobs{
419419
MemoryMonitor: mm,
420420
},
421421
},

pkg/sql/export/main_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2025 The Cockroach Authors.
2+
//
3+
// Use of this software is governed by the CockroachDB Software License
4+
// included in the /LICENSE file.
5+
6+
package export_test
7+
8+
import (
9+
"os"
10+
"testing"
11+
12+
"github.com/cockroachdb/cockroach/pkg/security/securityassets"
13+
"github.com/cockroachdb/cockroach/pkg/security/securitytest"
14+
"github.com/cockroachdb/cockroach/pkg/server"
15+
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
16+
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster"
17+
"github.com/cockroachdb/cockroach/pkg/util/randutil"
18+
)
19+
20+
func TestMain(m *testing.M) {
21+
securityassets.SetLoader(securitytest.EmbeddedAssets)
22+
randutil.SeedForTests()
23+
serverutils.InitTestServerFactory(server.TestServerFactory)
24+
serverutils.InitTestClusterFactory(testcluster.TestClusterFactory)
25+
os.Exit(m.Run())
26+
}
27+
28+
//go:generate ../../util/leaktest/add-leaktest.sh *_test.go

pkg/sql/importer/BUILD.bazel

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ filegroup(
99
go_library(
1010
name = "importer",
1111
srcs = [
12-
"export_base.go",
13-
"exportcsv.go",
14-
"exportparquet.go",
1512
"import_job.go",
1613
"import_planning.go",
1714
"import_processor.go",
@@ -105,16 +102,13 @@ go_library(
105102
"//pkg/util/log",
106103
"//pkg/util/log/eventpb",
107104
"//pkg/util/log/logutil",
108-
"//pkg/util/mon",
109-
"//pkg/util/parquet",
110105
"//pkg/util/protoutil",
111106
"//pkg/util/retry",
112107
"//pkg/util/syncutil",
113108
"//pkg/util/timeofday",
114109
"//pkg/util/timeutil",
115110
"//pkg/util/timeutil/pgdate",
116111
"//pkg/util/tracing",
117-
"//pkg/util/unique",
118112
"//pkg/workload",
119113
"@com_github_cockroachdb_apd_v3//:apd",
120114
"@com_github_cockroachdb_errors//:errors",
@@ -135,8 +129,6 @@ go_test(
135129
"client_import_test.go",
136130
"csv_internal_test.go",
137131
"csv_testdata_helpers_test.go",
138-
"exportcsv_test.go",
139-
"exportparquet_test.go",
140132
"import_csv_mark_redaction_test.go",
141133
"import_into_test.go",
142134
"import_mvcc_test.go",
@@ -164,15 +156,11 @@ go_test(
164156
deps = [
165157
"//pkg/base",
166158
"//pkg/blobs",
167-
"//pkg/ccl",
168159
"//pkg/cloud",
169160
"//pkg/cloud/cloudpb",
170161
"//pkg/cloud/impl:cloudimpl",
171162
"//pkg/cloud/nodelocal",
172163
"//pkg/cloud/userfile",
173-
"//pkg/col/coldata",
174-
"//pkg/config",
175-
"//pkg/config/zonepb",
176164
"//pkg/jobs",
177165
"//pkg/jobs/jobspb",
178166
"//pkg/jobs/jobstest",
@@ -184,7 +172,6 @@ go_test(
184172
"//pkg/kv/kvserver",
185173
"//pkg/kv/kvserver/kvserverbase",
186174
"//pkg/kv/kvserver/protectedts",
187-
"//pkg/multitenant/tenantcapabilitiespb",
188175
"//pkg/roachpb",
189176
"//pkg/security/securityassets",
190177
"//pkg/security/securitytest",
@@ -196,9 +183,7 @@ go_test(
196183
"//pkg/sql/catalog/bootstrap",
197184
"//pkg/sql/catalog/catformat",
198185
"//pkg/sql/catalog/catpb",
199-
"//pkg/sql/catalog/colinfo",
200186
"//pkg/sql/catalog/dbdesc",
201-
"//pkg/sql/catalog/descidgen",
202187
"//pkg/sql/catalog/descpb",
203188
"//pkg/sql/catalog/descs",
204189
"//pkg/sql/catalog/tabledesc",
@@ -240,8 +225,6 @@ go_test(
240225
"//pkg/util/leaktest",
241226
"//pkg/util/log",
242227
"//pkg/util/log/eventpb",
243-
"//pkg/util/mon",
244-
"//pkg/util/parquet",
245228
"//pkg/util/protoutil",
246229
"//pkg/util/randutil",
247230
"//pkg/util/retry",
@@ -250,16 +233,12 @@ go_test(
250233
"//pkg/util/timeutil/pgdate",
251234
"//pkg/util/tracing",
252235
"//pkg/workload",
253-
"//pkg/workload/bank",
254236
"//pkg/workload/tpcc",
255-
"//pkg/workload/workloadsql",
256237
"@com_github_cockroachdb_cockroach_go_v2//crdb",
257238
"@com_github_cockroachdb_errors//:errors",
258239
"@com_github_go_sql_driver_mysql//:mysql",
259-
"@com_github_gogo_protobuf//proto",
260240
"@com_github_jackc_pgconn//:pgconn",
261241
"@com_github_jackc_pgx_v4//:pgx",
262-
"@com_github_jackc_pgx_v5//:pgx",
263242
"@com_github_kr_pretty//:pretty",
264243
"@com_github_lib_pq//:pq",
265244
"@com_github_linkedin_goavro_v2//:goavro",

0 commit comments

Comments
 (0)