@@ -16,58 +16,52 @@ using namespace NYdb::NTable;
16
16
17
17
Y_UNIT_TEST_SUITE (KqpAnalyze) {
18
18
19
- void CreateTable (NStat::TTestEnv& env, const TString& databaseName, const TString& tableName) {
20
- TTableClient client (env.GetDriver ());
21
- auto session = client.CreateSession ().GetValueSync ().GetSession ();
22
-
23
- auto fullTableName = Sprintf (" Root/%s/%s" , databaseName.c_str (), tableName.c_str ());
24
- auto result = session.ExecuteSchemeQuery (Sprintf (R"(
25
- CREATE TABLE `%s` (
26
- Key Uint64 NOT NULL,
27
- Value String,
28
- PRIMARY KEY (Key)
29
- )
30
- )" , fullTableName.c_str ())).GetValueSync ();
31
- UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
32
-
33
- TValueBuilder rows;
34
- rows.BeginList ();
35
- for (size_t i = 0 ; i < 1000 ; ++i) {
36
- auto key = TValueBuilder ().Uint64 (i).Build ();
37
- auto value = TValueBuilder ().OptionalString (" Hello, world!" ).Build ();
38
-
39
- rows.AddListItem ();
40
- rows.BeginStruct ();
41
- rows.AddMember (" Key" , key);
42
- rows.AddMember (" Value" , value);
43
- rows.EndStruct ();
44
- }
45
- rows.EndList ();
46
-
47
- result = client.BulkUpsert (fullTableName, rows.Build ()).GetValueSync ();
48
- UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
49
- }
50
-
51
19
using namespace NStat ;
52
20
53
- Y_UNIT_TEST (AnalyzeDatashardTable ) {
21
+ Y_UNIT_TEST_TWIN (AnalyzeTable, ColumnStore ) {
54
22
TTestEnv env (1 , 1 , 1 , true );
55
23
CreateDatabase (env, " Database" );
56
24
57
25
TTableClient client (env.GetDriver ());
58
26
auto session = client.CreateSession ().GetValueSync ().GetSession ();
59
27
60
- auto result = session.ExecuteSchemeQuery (
61
- Sprintf (R"(
28
+ TString createTable = Sprintf (R"(
62
29
CREATE TABLE `%s` (
63
30
Key Uint64 NOT NULL,
64
31
Value String,
65
32
PRIMARY KEY (Key)
66
33
)
67
- )" , " Root/Database/Table" )
68
- ).GetValueSync ();
34
+ )" , " Root/Database/Table" );
35
+ if (ColumnStore) {
36
+ createTable +=
37
+ R"(
38
+ PARTITION BY HASH(Key)
39
+ WITH (
40
+ STORE = COLUMN,
41
+ AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 16
42
+ )
43
+ )" ;
44
+ }
45
+
46
+ auto result = session.ExecuteSchemeQuery (createTable).GetValueSync ();
69
47
UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
70
48
49
+ if (ColumnStore) {
50
+ result = session.ExecuteSchemeQuery (
51
+ Sprintf (R"(
52
+ ALTER OBJECT `%s` (TYPE TABLE)
53
+ SET (
54
+ ACTION=UPSERT_INDEX,
55
+ NAME=cms_value,
56
+ TYPE=COUNT_MIN_SKETCH,
57
+ FEATURES=`{"column_names" : ['Value']}`
58
+ );
59
+ )" , " Root/Database/Table"
60
+ )
61
+ ).GetValueSync ();
62
+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
63
+ }
64
+
71
65
TValueBuilder rows;
72
66
rows.BeginList ();
73
67
for (size_t i = 0 ; i < 1500 ; ++i) {
@@ -88,7 +82,15 @@ Y_UNIT_TEST(AnalyzeDatashardTable) {
88
82
result = session.ExecuteSchemeQuery (
89
83
Sprintf (R"( ANALYZE `Root/%s/%s`)" , " Database" , " Table" )
90
84
).GetValueSync ();
91
- UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
85
+
86
+ if (ColumnStore) {
87
+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
88
+ } else {
89
+ UNIT_ASSERT (!result.IsSuccess ());
90
+ auto issues = result.GetIssues ().ToString ();
91
+ UNIT_ASSERT_C (issues.find (" analyze is not supported for oltp tables." ) != TString::npos, issues);
92
+ return ;
93
+ }
92
94
93
95
auto & runtime = *env.GetServer ().GetRuntime ();
94
96
ui64 saTabletId;
0 commit comments