1
1
#include " table_index.h"
2
+ #include " table_vector_index.h"
2
3
3
4
#include < library/cpp/testing/unittest/registar.h>
4
5
@@ -40,39 +41,38 @@ Y_UNIT_TEST_SUITE (TableIndex) {
40
41
UNIT_ASSERT (IsCompatibleIndex (type, Table3, {{" DATA" }, {}}, explain));
41
42
UNIT_ASSERT (explain.empty ());
42
43
}
43
-
44
- // will be fixed:
45
- UNIT_ASSERT (IsCompatibleIndex (type, Table, {{}, {}}, explain));
46
- UNIT_ASSERT (explain.empty ());
47
-
48
- UNIT_ASSERT (IsCompatibleIndex (type, Table, {{" PK2" }, {}}, explain));
49
- UNIT_ASSERT (explain.empty ());
50
44
}
51
45
52
46
Y_UNIT_TEST (NotCompatibleSecondaryIndex) {
53
47
TString explain;
54
48
auto type = NKikimrSchemeOp::EIndexType::EIndexTypeGlobal;
55
49
56
50
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" NOT EXIST" }, {}}, explain));
57
- UNIT_ASSERT (! explain. empty () );
51
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " all index key columns should be in table columns, index key column NOT EXIST is missed " );
58
52
59
53
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{}, {" NOT EXIST" }}, explain));
60
- UNIT_ASSERT (! explain. empty () );
54
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " all index data columns should be in table columns, index data column NOT EXIST is missed " );
61
55
62
56
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" NOT EXIST" }, {" NOT EXIST" }}, explain));
63
- UNIT_ASSERT (! explain. empty () );
57
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " all index key columns should be in table columns, index key column NOT EXIST is missed " );
64
58
65
59
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" DATA1" , " DATA1" }, {}}, explain));
66
- UNIT_ASSERT (! explain. empty () );
60
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " all index key columns should be unique, for example DATA1 " );
67
61
68
62
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" DATA1" }, {" PK2" }}, explain));
69
- UNIT_ASSERT (! explain. empty () );
63
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " the same column can't be used as key and data column for one index, for example PK2 " );
70
64
71
65
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" DATA1" }, {" DATA1" }}, explain));
72
- UNIT_ASSERT (! explain. empty () );
66
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " the same column can't be used as key and data column for one index, for example DATA1 " );
73
67
74
68
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" DATA1" }, {" DATA3" , " DATA3" }}, explain));
75
- UNIT_ASSERT (!explain.empty ());
69
+ UNIT_ASSERT_STRINGS_EQUAL (explain, " all index data columns should be unique, for example DATA3" );
70
+
71
+ UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{}, {}}, explain));
72
+ UNIT_ASSERT_STRINGS_EQUAL (explain, " should be at least single index key column" );
73
+
74
+ UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" PK2" }, {}}, explain));
75
+ UNIT_ASSERT_STRINGS_EQUAL (explain, " index keys are prefix of table keys" );
76
76
}
77
77
78
78
Y_UNIT_TEST (CompatibleVectorIndex) {
@@ -90,46 +90,44 @@ Y_UNIT_TEST_SUITE (TableIndex) {
90
90
91
91
UNIT_ASSERT (IsCompatibleIndex (type, Table, {{" DATA1" }, {" DATA1" }}, explain));
92
92
UNIT_ASSERT (explain.empty ());
93
-
94
- // will be fixed:
95
- {
96
- const TTableColumns Table3{{" PK" , " DATA" , NTableVectorKmeansTreeIndex::PostingTable_ParentIdColumn}, {NTableVectorKmeansTreeIndex::PostingTable_ParentIdColumn}};
97
-
98
- UNIT_ASSERT (IsCompatibleIndex (type, Table3, {{" DATA" }, {}}, explain));
99
- UNIT_ASSERT (explain.empty ());
100
- }
101
93
}
102
94
103
95
Y_UNIT_TEST (NotCompatibleVectorIndex) {
104
96
TString explain;
105
97
auto type = NKikimrSchemeOp::EIndexType::EIndexTypeGlobalVectorKmeansTree;
106
98
107
99
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" NOT EXIST" }, {}}, explain));
108
- UNIT_ASSERT (! explain. empty () );
100
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " all index key columns should be in table columns, index key column NOT EXIST is missed " );
109
101
110
102
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{}, {" NOT EXIST" }}, explain));
111
- UNIT_ASSERT (! explain. empty () );
103
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " all index data columns should be in table columns, index data column NOT EXIST is missed " );
112
104
113
105
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" NOT EXIST" }, {" NOT EXIST" }}, explain));
114
- UNIT_ASSERT (! explain. empty () );
106
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " all index key columns should be in table columns, index key column NOT EXIST is missed " );
115
107
116
108
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" DATA1" , " DATA1" }, {}}, explain));
117
- UNIT_ASSERT (! explain. empty () );
109
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " all index key columns should be unique, for example DATA1 " );
118
110
119
111
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" DATA1" , " DATA2" }, {}}, explain));
120
- UNIT_ASSERT (! explain. empty () );
112
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " only single key column is supported for vector index " );
121
113
122
114
UNIT_ASSERT (!IsCompatibleIndex (type, Table, {{" DATA1" }, {" PK2" }}, explain));
123
- UNIT_ASSERT (! explain. empty () );
115
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " the same column can't be used as key and data column for one index, for example PK2 " );
124
116
125
117
{
126
118
const TTableColumns Table2{{" PK" , " DATA" , NTableVectorKmeansTreeIndex::PostingTable_ParentIdColumn}, {" PK" }};
127
119
128
120
UNIT_ASSERT (!IsCompatibleIndex (type, Table2, {{NTableVectorKmeansTreeIndex::PostingTable_ParentIdColumn}, {}}, explain));
129
- UNIT_ASSERT (! explain. empty () );
121
+ UNIT_ASSERT_STRINGS_EQUAL ( explain, " index key column shouldn't have a reserved name: -parent " );
130
122
131
123
UNIT_ASSERT (!IsCompatibleIndex (type, Table2, {{" DATA" }, {NTableVectorKmeansTreeIndex::PostingTable_ParentIdColumn}}, explain));
132
- UNIT_ASSERT (!explain.empty ());
124
+ UNIT_ASSERT_STRINGS_EQUAL (explain, " index data column shouldn't have a reserved name: -parent" );
125
+ }
126
+ {
127
+ const TTableColumns Table3{{" PK" , " DATA" , NTableVectorKmeansTreeIndex::PostingTable_ParentIdColumn}, {NTableVectorKmeansTreeIndex::PostingTable_ParentIdColumn}};
128
+
129
+ UNIT_ASSERT (!IsCompatibleIndex (type, Table3, {{" DATA" }, {}}, explain));
130
+ UNIT_ASSERT_STRINGS_EQUAL (explain, " table key column shouldn't have a reserved name: -parent" );
133
131
}
134
132
}
135
133
}
0 commit comments