2 using System.Collections.Generic;
13 [Trait(
"Category",
"Integration")]
22 var typeDef =
@"{""type"":""record"",""name"":""test_rec"",""fields"":[{""name"":""id"",""type"":""int""},{""name"":""name"",""type"":""string""},{""name"":""value"",""type"":""double""}]}";
23 var props =
new Dictionary<string, IList<string>>
25 {
"id",
new List<string> {
"int",
"primary_key" } }
28 var typeResp = ctx.Kinetica.createType(typeDef,
"insert_test_type", props,
new Dictionary<string, string>());
31 var tableName = ctx.QualifiedTable(
"test_table");
32 ctx.Kinetica.createTable(tableName, typeResp.type_id,
new Dictionary<string, string>());
35 ctx.Kinetica.executeSql($
"INSERT INTO {tableName} (id, name, value) VALUES (1, 'Alice', 1.1)");
36 ctx.Kinetica.executeSql($
"INSERT INTO {tableName} (id, name, value) VALUES (2, 'Bob', 2.2)");
37 ctx.Kinetica.executeSql($
"INSERT INTO {tableName} (id, name, value) VALUES (3, 'Charlie', 3.3)");
40 var showTableResp = ctx.Kinetica.showTable(tableName,
new Dictionary<string, string> { {
"get_sizes",
"true" } });
41 Assert.Equal(3, showTableResp.total_size);
47 using var ctx =
new TestContext(
"insert_update_pk");
50 var typeDef =
@"{""type"":""record"",""name"":""pk_rec"",""fields"":[{""name"":""id"",""type"":""int""},{""name"":""value"",""type"":""string""}]}";
51 var props =
new Dictionary<string, IList<string>>
53 {
"id",
new List<string> {
"int",
"primary_key" } }
56 var typeResp = ctx.Kinetica.createType(typeDef,
"pk_test_type", props,
new Dictionary<string, string>());
58 var tableName = ctx.QualifiedTable(
"pk_table");
59 ctx.Kinetica.createTable(tableName, typeResp.type_id,
new Dictionary<string, string>());
62 ctx.Kinetica.executeSql($
"INSERT INTO {tableName} (id, value) VALUES (1, 'original')");
63 ctx.Kinetica.executeSql($
"INSERT INTO {tableName} (id, value) VALUES (2, 'data')");
66 var showTableResp = ctx.Kinetica.showTable(tableName,
new Dictionary<string, string> { {
"get_sizes",
"true" } });
67 Assert.Equal(2, showTableResp.total_size);
70 ctx.Kinetica.executeSql($
"UPDATE {tableName} SET value = 'updated' WHERE id = 1");
73 var showTableResp2 = ctx.Kinetica.showTable(tableName,
new Dictionary<string, string> { {
"get_sizes",
"true" } });
74 Assert.Equal(2, showTableResp2.total_size);
77 var selectResp = ctx.Kinetica.executeSql($
"SELECT value FROM {tableName} WHERE id = 1", 0, -9999);
78 Assert.Equal(1, selectResp.total_number_of_records);
87 ctx.Kinetica.executeSql($
"CREATE TABLE {ctx.QualifiedTable("batch_table
")} (id INT NOT NULL, x DOUBLE, y DOUBLE, PRIMARY KEY (id))");
89 var tableName = ctx.QualifiedTable(
"batch_table");
93 for (
int i = 0; i < numRecords; i++)
95 ctx.Kinetica.executeSql($
"INSERT INTO {tableName} (id, x, y) VALUES ({i}, {i * 0.1}, {i * 0.2})");
99 var showTableResp = ctx.Kinetica.showTable(tableName,
new Dictionary<string, string> { {
"get_sizes",
"true" } });
100 Assert.Equal(numRecords, showTableResp.total_size);
Tests for insert_records endpoint.
void TestInsertRecordsLargeBatch()
Test context that manages schema and cleanup for integration tests.
void TestInsertRecordsUpdateOnExistingPk()
void TestInsertRecordsJson()