Skip to content

Commit c3344ba

Browse files
committed
importer: disable import into tables with vector indexes
Import into vector indexes is not yet implemented. Disable it for this release to prevent wildly unexpected behaviors. Fixes: #145105 Informs: #145227 Release note (sql change): IMPORT into tables with vector indexes is not supported in 25.2.
1 parent 650eac4 commit c3344ba

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

pkg/sql/importer/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ go_library(
8888
"//pkg/sql/sem/catconstants",
8989
"//pkg/sql/sem/catid",
9090
"//pkg/sql/sem/eval",
91+
"//pkg/sql/sem/idxtype",
9192
"//pkg/sql/sem/tree",
9293
"//pkg/sql/sessiondata",
9394
"//pkg/sql/sqlclustersettings",

pkg/sql/importer/import_planning.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgnotice"
4444
"github.com/cockroachdb/cockroach/pkg/sql/privilege"
4545
"github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants"
46+
"github.com/cockroachdb/cockroach/pkg/sql/sem/idxtype"
4647
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
4748
"github.com/cockroachdb/cockroach/pkg/util"
4849
"github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented"
@@ -812,6 +813,13 @@ func importPlanHook(
812813
if err != nil {
813814
return err
814815
}
816+
// Check if the table has any vector indexes
817+
for _, idx := range found.NonDropIndexes() {
818+
if idx.GetType() == idxtype.VECTOR {
819+
return unimplemented.NewWithIssueDetail(145227, "import.vector-index",
820+
"IMPORT INTO is not supported for tables with vector indexes")
821+
}
822+
}
815823

816824
if len(found.LDRJobIDs) > 0 {
817825
return errors.Newf("cannot run an import on table %s which is apart of a Logical Data Replication stream", table)

pkg/sql/logictest/testdata/logic_test/vector_index

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,3 +623,28 @@ SELECT a FROM test_144621@vec_idx ORDER BY v <-> '[1, 2, 3]' LIMIT 1;
623623
----
624624

625625
subtest end
626+
627+
subtest import_into
628+
629+
statement ok
630+
CREATE TABLE import_test (a INT PRIMARY KEY, v VECTOR(3))
631+
632+
statement ok
633+
INSERT INTO import_test VALUES (1, '[1, 2, 3]')
634+
635+
let $exp_file
636+
WITH cte AS (EXPORT INTO CSV 'nodelocal://1/vector_import_test' FROM SELECT * FROM import_test) SELECT filename FROM cte;
637+
638+
statement ok
639+
TRUNCATE TABLE import_test
640+
641+
statement ok
642+
CREATE VECTOR INDEX vec_idx ON import_test (v)
643+
644+
statement error IMPORT INTO is not supported for tables with vector indexes
645+
IMPORT INTO import_test (a, v) CSV DATA ('nodelocal://1/vector_import_test/$exp_file')
646+
647+
statement ok
648+
DROP TABLE import_test
649+
650+
subtest end

0 commit comments

Comments
 (0)