@@ -824,6 +824,87 @@ Y_UNIT_TEST_SUITE(TGRpcNewClient) {
824
824
client.CreateSession ().Apply (createSessionHandler).Wait ();
825
825
UNIT_ASSERT (done);
826
826
}
827
+
828
+ Y_UNIT_TEST (InMemoryTables) {
829
+ TKikimrWithGrpcAndRootSchemaNoSystemViews server;
830
+ server.Server_ ->GetRuntime ()->GetAppData ().FeatureFlags .SetEnablePublicApiKeepInMemory (true );
831
+
832
+ ui16 grpc = server.GetPort ();
833
+ TString location = TStringBuilder () << " localhost:" << grpc;
834
+
835
+ auto connection = NYdb::TDriver (
836
+ TDriverConfig ()
837
+ .SetEndpoint (location));
838
+
839
+ auto client = NYdb::NTable::TTableClient (connection);
840
+ auto createSessionResult = client.CreateSession ().ExtractValueSync ();
841
+ UNIT_ASSERT (!createSessionResult.IsTransportError ());
842
+ auto session = createSessionResult.GetSession ();
843
+
844
+ auto createTableResult = session.CreateTable (" /Root/Table" , client.GetTableBuilder ()
845
+ .AddNullableColumn (" Key" , EPrimitiveType::Int32)
846
+ .AddNullableColumn (" Value" , EPrimitiveType::String)
847
+ .SetPrimaryKeyColumn (" Key" )
848
+ // Note: only needed because this test doesn't initial table profiles
849
+ .BeginStorageSettings ()
850
+ .SetTabletCommitLog0 (" ssd" )
851
+ .SetTabletCommitLog1 (" ssd" )
852
+ .EndStorageSettings ()
853
+ .BeginColumnFamily (" default" )
854
+ .SetData (" ssd" )
855
+ .SetKeepInMemory (true )
856
+ .EndColumnFamily ()
857
+ .Build ()).ExtractValueSync ();
858
+ UNIT_ASSERT_C (createTableResult.IsSuccess (), (NYdb::TStatus&)createTableResult);
859
+
860
+ {
861
+ auto describeTableResult = session.DescribeTable (" /Root/Table" ).ExtractValueSync ();
862
+ UNIT_ASSERT_C (describeTableResult.IsSuccess (), (NYdb::TStatus&)describeTableResult);
863
+ auto desc = describeTableResult.GetTableDescription ();
864
+ auto families = desc.GetColumnFamilies ();
865
+ UNIT_ASSERT_VALUES_EQUAL (families.size (), 1u );
866
+ auto family = families.at (0 );
867
+ UNIT_ASSERT_VALUES_EQUAL (family.GetKeepInMemory (), true );
868
+ }
869
+
870
+ {
871
+ auto alterTableResult = session.AlterTable (" /Root/Table" , NYdb::NTable::TAlterTableSettings ()
872
+ .BeginAlterColumnFamily (" default" )
873
+ .SetKeepInMemory (false )
874
+ .EndAlterColumnFamily ()).ExtractValueSync ();
875
+ UNIT_ASSERT_C (alterTableResult.IsSuccess (), (NYdb::TStatus&)alterTableResult);
876
+ }
877
+
878
+ {
879
+ auto describeTableResult = session.DescribeTable (" /Root/Table" ).ExtractValueSync ();
880
+ UNIT_ASSERT_C (describeTableResult.IsSuccess (), (NYdb::TStatus&)describeTableResult);
881
+ auto desc = describeTableResult.GetTableDescription ();
882
+ auto families = desc.GetColumnFamilies ();
883
+ UNIT_ASSERT_VALUES_EQUAL (families.size (), 1u );
884
+ auto family = families.at (0 );
885
+ // Note: server cannot currently distinguish between implicitly
886
+ // unset and explicitly disabled, so it returns the former.
887
+ UNIT_ASSERT_VALUES_EQUAL (family.GetKeepInMemory (), Nothing ());
888
+ }
889
+
890
+ {
891
+ auto alterTableResult = session.AlterTable (" /Root/Table" , NYdb::NTable::TAlterTableSettings ()
892
+ .BeginAlterColumnFamily (" default" )
893
+ .SetKeepInMemory (true )
894
+ .EndAlterColumnFamily ()).ExtractValueSync ();
895
+ UNIT_ASSERT_C (alterTableResult.IsSuccess (), (NYdb::TStatus&)alterTableResult);
896
+ }
897
+
898
+ {
899
+ auto describeTableResult = session.DescribeTable (" /Root/Table" ).ExtractValueSync ();
900
+ UNIT_ASSERT_C (describeTableResult.IsSuccess (), (NYdb::TStatus&)describeTableResult);
901
+ auto desc = describeTableResult.GetTableDescription ();
902
+ auto families = desc.GetColumnFamilies ();
903
+ UNIT_ASSERT_VALUES_EQUAL (families.size (), 1u );
904
+ auto family = families.at (0 );
905
+ UNIT_ASSERT_VALUES_EQUAL (family.GetKeepInMemory (), true );
906
+ }
907
+ }
827
908
}
828
909
829
910
static TString CreateSession (std::shared_ptr<grpc::Channel> channel) {
0 commit comments