ydb_table.proto 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  1. syntax = "proto3";
  2. option cc_enable_arenas = true;
  3. import "ydb/public/api/protos/annotations/validation.proto";
  4. import "ydb/public/api/protos/ydb_common.proto";
  5. import "ydb/public/api/protos/ydb_issue_message.proto";
  6. import "ydb/public/api/protos/ydb_operation.proto";
  7. import "ydb/public/api/protos/ydb_query_stats.proto";
  8. import "ydb/public/api/protos/ydb_value.proto";
  9. import "ydb/public/api/protos/ydb_scheme.proto";
  10. import "ydb/public/api/protos/ydb_status_codes.proto";
  11. import "ydb/public/api/protos/ydb_formats.proto";
  12. import "google/protobuf/empty.proto";
  13. import "google/protobuf/duration.proto";
  14. import "google/protobuf/timestamp.proto";
  15. package Ydb.Table;
  16. option java_package = "com.yandex.ydb.table";
  17. // Create new session
  18. message CreateSessionRequest {
  19. Ydb.Operations.OperationParams operation_params = 1;
  20. }
  21. // Create new session
  22. message CreateSessionResponse {
  23. // Holds CreateSessionResult in case of CreateSessionResult
  24. Ydb.Operations.Operation operation = 1;
  25. }
  26. message CreateSessionResult {
  27. // Session identifier
  28. string session_id = 1;
  29. }
  30. // Delete session with given id string
  31. message DeleteSessionRequest {
  32. // Session identifier
  33. string session_id = 1;
  34. Ydb.Operations.OperationParams operation_params = 2;
  35. }
  36. message DeleteSessionResponse {
  37. Ydb.Operations.Operation operation = 1;
  38. }
  39. message GlobalIndex {
  40. }
  41. message GlobalAsyncIndex {
  42. }
  43. // Represent secondary index
  44. message TableIndex {
  45. // Name of index
  46. string name = 1;
  47. // list of columns
  48. repeated string index_columns = 2;
  49. // Type of index
  50. oneof type {
  51. GlobalIndex global_index = 3;
  52. GlobalAsyncIndex global_async_index = 4;
  53. }
  54. // list of columns content to be copied in to index table
  55. repeated string data_columns = 5;
  56. }
  57. // Represent secondary index with index state
  58. message TableIndexDescription {
  59. enum Status {
  60. STATUS_UNSPECIFIED = 0;
  61. // Index is ready to use
  62. STATUS_READY = 1;
  63. // index is being built
  64. STATUS_BUILDING = 2;
  65. }
  66. // Name of index
  67. string name = 1;
  68. // list of columns
  69. repeated string index_columns = 2;
  70. // Type of index
  71. oneof type {
  72. GlobalIndex global_index = 3;
  73. GlobalAsyncIndex global_async_index = 5;
  74. }
  75. Status status = 4;
  76. // list of columns content to be copied in to index table
  77. repeated string data_columns = 6;
  78. // Size of index data in bytes
  79. uint64 size_bytes = 7;
  80. }
  81. // State of index building operation
  82. message IndexBuildState {
  83. enum State {
  84. STATE_UNSPECIFIED = 0;
  85. STATE_PREPARING = 1;
  86. STATE_TRANSFERING_DATA = 2;
  87. STATE_APPLYING = 3;
  88. STATE_DONE = 4;
  89. STATE_CANCELLATION = 5;
  90. STATE_CANCELLED = 6;
  91. STATE_REJECTION = 7;
  92. STATE_REJECTED = 8;
  93. }
  94. }
  95. // Description of index building operation
  96. message IndexBuildDescription {
  97. string path = 1;
  98. TableIndex index = 2;
  99. }
  100. message IndexBuildMetadata {
  101. IndexBuildDescription description = 1;
  102. IndexBuildState.State state = 2;
  103. float progress = 3;
  104. }
  105. message ChangefeedMode {
  106. enum Mode {
  107. MODE_UNSPECIFIED = 0;
  108. // Only the key component of the modified row
  109. MODE_KEYS_ONLY = 1;
  110. // Updated columns
  111. MODE_UPDATES = 2;
  112. // The entire row, as it appears after it was modified
  113. MODE_NEW_IMAGE = 3;
  114. // The entire row, as it appeared before it was modified
  115. MODE_OLD_IMAGE = 4;
  116. // Both new and old images of the row
  117. MODE_NEW_AND_OLD_IMAGES = 5;
  118. }
  119. }
  120. message ChangefeedFormat {
  121. enum Format {
  122. FORMAT_UNSPECIFIED = 0;
  123. // Change record in JSON format for common (row oriented) tables
  124. FORMAT_JSON = 1;
  125. // Change record in JSON format for document (DynamoDB-compatible) tables
  126. FORMAT_DYNAMODB_STREAMS_JSON = 2;
  127. }
  128. }
  129. message Changefeed {
  130. // Name of the feed
  131. string name = 1;
  132. // Mode specifies the information that will be written to the feed
  133. ChangefeedMode.Mode mode = 2;
  134. // Format of the data
  135. ChangefeedFormat.Format format = 3;
  136. // How long data in changefeed's underlying topic should be stored
  137. google.protobuf.Duration retention_period = 4;
  138. // Emit virtual timestamps of changes along with data or not
  139. bool virtual_timestamps = 5;
  140. // Initial scan will output the current state of the table first
  141. bool initial_scan = 6;
  142. // Attributes. Total size is limited to 10 KB.
  143. map<string, string> attributes = 7 [(map_key).length.range = {min: 1, max: 100}, (length).range = {min: 1, max: 4096}];
  144. // Value that will be emitted in the `awsRegion` field of the record in DYNAMODB_STREAMS_JSON format
  145. string aws_region = 8 [(length).le = 128];
  146. // Periodically emit resolved timestamps. If unspecified, resolved timestamps are not emitted.
  147. google.protobuf.Duration resolved_timestamps_interval = 9;
  148. }
  149. message ChangefeedDescription {
  150. enum State {
  151. STATE_UNSPECIFIED = 0;
  152. // Normal state, from this state changefeed can be disabled
  153. STATE_ENABLED = 1;
  154. // No new change records are generated, but the old ones remain available
  155. // From this state changefeed cannot be switched to any other state
  156. STATE_DISABLED = 2;
  157. // An initial scan is being performed.
  158. // After its completion changefeed will switch to the normal state
  159. STATE_INITIAL_SCAN = 3;
  160. }
  161. // Name of the feed
  162. string name = 1;
  163. // Mode specifies the information that will be written to the feed
  164. ChangefeedMode.Mode mode = 2;
  165. // Format of the data
  166. ChangefeedFormat.Format format = 3;
  167. // State of the feed
  168. State state = 4;
  169. // State of emitting of virtual timestamps along with data
  170. bool virtual_timestamps = 5;
  171. // Attributes
  172. map<string, string> attributes = 6;
  173. // Value that will be emitted in the `awsRegion` field of the record in DYNAMODB_STREAMS_JSON format
  174. string aws_region = 7;
  175. // Interval of emitting of resolved timestamps. If unspecified, resolved timestamps are not emitted.
  176. google.protobuf.Duration resolved_timestamps_interval = 8;
  177. }
  178. message StoragePool {
  179. string media = 1;
  180. }
  181. message StoragePolicy {
  182. string preset_name = 1;
  183. StoragePool syslog = 2;
  184. StoragePool log = 3;
  185. StoragePool data = 4;
  186. StoragePool external = 5;
  187. Ydb.FeatureFlag.Status keep_in_memory = 6;
  188. repeated ColumnFamilyPolicy column_families = 7;
  189. }
  190. message ColumnFamilyPolicy {
  191. enum Compression {
  192. COMPRESSION_UNSPECIFIED = 0;
  193. UNCOMPRESSED = 1;
  194. COMPRESSED = 2;
  195. }
  196. // Name of the column family, the name "default" must be used for the
  197. // primary column family that contains as least primary key columns
  198. string name = 1;
  199. // Storage settings for the column group (default to values in storage policy)
  200. StoragePool data = 2;
  201. StoragePool external = 3;
  202. // When enabled table data will be kept in memory
  203. // WARNING: DO NOT USE
  204. Ydb.FeatureFlag.Status keep_in_memory = 4;
  205. // Optionally specify whether data should be compressed
  206. Compression compression = 5;
  207. }
  208. message CompactionPolicy {
  209. string preset_name = 1;
  210. }
  211. message ExplicitPartitions {
  212. // Specify key values used to split table into partitions.
  213. // Each value becomes the first key of a new partition.
  214. // Key values should go in ascending order.
  215. // Total number of created partitions is number of specified
  216. // keys + 1.
  217. repeated TypedValue split_points = 1;
  218. }
  219. message PartitionStats {
  220. // Approximate number of rows in shard
  221. uint64 rows_estimate = 1;
  222. // Approximate size of shard (bytes)
  223. uint64 store_size = 2;
  224. }
  225. message TableStats {
  226. // Stats for each partition
  227. repeated PartitionStats partition_stats = 1;
  228. // Approximate number of rows in table
  229. uint64 rows_estimate = 2;
  230. // Approximate size of table (bytes)
  231. uint64 store_size = 3;
  232. // Number of partitions in table
  233. uint64 partitions = 4;
  234. // Timestamp of table creation
  235. google.protobuf.Timestamp creation_time = 5;
  236. // Timestamp of last modification
  237. google.protobuf.Timestamp modification_time = 6;
  238. }
  239. message PartitioningPolicy {
  240. enum AutoPartitioningPolicy {
  241. AUTO_PARTITIONING_POLICY_UNSPECIFIED = 0;
  242. DISABLED = 1;
  243. AUTO_SPLIT = 2;
  244. AUTO_SPLIT_MERGE = 3;
  245. }
  246. string preset_name = 1;
  247. AutoPartitioningPolicy auto_partitioning = 2;
  248. oneof partitions {
  249. // Allows to enable uniform sharding using given shards number.
  250. // The first components of primary key must have Uint32/Uint64 type.
  251. uint64 uniform_partitions = 3;
  252. // Explicitly specify key values which are used as borders for
  253. // created partitions.
  254. ExplicitPartitions explicit_partitions = 4;
  255. }
  256. }
  257. message ExecutionPolicy {
  258. string preset_name = 1;
  259. }
  260. message ReplicationPolicy {
  261. string preset_name = 1;
  262. // If value is non-zero then it specifies a number of read-only
  263. // replicas to create for a table. Zero value means preset
  264. // setting usage.
  265. uint32 replicas_count = 2;
  266. // If this feature in enabled then requested number of replicas
  267. // will be created in each availability zone.
  268. Ydb.FeatureFlag.Status create_per_availability_zone = 3;
  269. // If this feature in enabled then read-only replicas can be promoted
  270. // to leader.
  271. Ydb.FeatureFlag.Status allow_promotion = 4;
  272. }
  273. message CachingPolicy {
  274. string preset_name = 1;
  275. }
  276. message TableProfile {
  277. string preset_name = 1;
  278. StoragePolicy storage_policy = 2;
  279. CompactionPolicy compaction_policy = 3;
  280. PartitioningPolicy partitioning_policy = 4;
  281. ExecutionPolicy execution_policy = 5;
  282. ReplicationPolicy replication_policy = 6;
  283. CachingPolicy caching_policy = 7;
  284. }
  285. message ColumnMeta {
  286. // Name of column
  287. string name = 1;
  288. // Type of column
  289. Type type = 2;
  290. // Column family name of the column
  291. string family = 3;
  292. // Column nullability
  293. optional bool not_null = 4;
  294. }
  295. message DateTypeColumnModeSettings {
  296. // The row will be considered as expired at the moment of time, when the value
  297. // stored in <column_name> is less than or equal to the current time (in epoch
  298. // time format), and <expire_after_seconds> has passed since that moment;
  299. // i.e. the expiration threshold is the value of <column_name> plus <expire_after_seconds>.
  300. // The column type must be a date type
  301. string column_name = 1;
  302. uint32 expire_after_seconds = 2;
  303. }
  304. message ValueSinceUnixEpochModeSettings {
  305. // Same as DateTypeColumnModeSettings (above), but useful when type of the
  306. // value stored in <column_name> is not a date type.
  307. enum Unit {
  308. UNIT_UNSPECIFIED = 0;
  309. UNIT_SECONDS = 1;
  310. UNIT_MILLISECONDS = 2;
  311. UNIT_MICROSECONDS = 3;
  312. UNIT_NANOSECONDS = 4;
  313. }
  314. // The column type must be one of:
  315. // - Uint32
  316. // - Uint64
  317. // - DyNumber
  318. string column_name = 1;
  319. // Interpretation of the value stored in <column_name>
  320. Unit column_unit = 2;
  321. // This option is always interpreted as seconds regardless of the
  322. // <column_unit> value.
  323. uint32 expire_after_seconds = 3;
  324. }
  325. message TtlSettings {
  326. oneof mode {
  327. DateTypeColumnModeSettings date_type_column = 1;
  328. ValueSinceUnixEpochModeSettings value_since_unix_epoch = 2;
  329. }
  330. // There is no guarantee that expired row will be deleted immediately upon
  331. // expiration. There may be a delay between the time a row expires and the
  332. // time that server deletes the row from the table.
  333. // Ttl periodically runs background removal operations (BRO) on table's partitions.
  334. // By default, there is:
  335. // - no more than one BRO on the table;
  336. // - BRO is started no more than once an hour on the same partition.
  337. // Use options below to change that behavior.
  338. // How often to run BRO on the same partition.
  339. // BRO will not be started more often, but may be started less often.
  340. uint32 run_interval_seconds = 3;
  341. }
  342. message StorageSettings {
  343. // This specifies internal channel 0 commit log storage pool
  344. // Fastest available storage recommended, negligible amounts of short-lived data
  345. StoragePool tablet_commit_log0 = 1;
  346. // This specifies internal channel 1 commit log storage pool
  347. // Fastest available storage recommended, small amounts of short-lived data
  348. StoragePool tablet_commit_log1 = 2;
  349. // This specifies external blobs storage pool
  350. StoragePool external = 4;
  351. // Optionally store large values in "external blobs"
  352. // WARNING: DO NOT USE
  353. // This feature is experimental and should not be used, restrictions apply:
  354. // * Table cannot split/merge when this is enabled
  355. // * Table cannot be copied or backed up when this is enabled
  356. // * This feature cannot be disabled once enabled for a table
  357. Ydb.FeatureFlag.Status store_external_blobs = 5;
  358. }
  359. message ColumnFamily {
  360. enum Compression {
  361. COMPRESSION_UNSPECIFIED = 0;
  362. COMPRESSION_NONE = 1;
  363. COMPRESSION_LZ4 = 2;
  364. }
  365. // Name of the column family, the name "default" must be used for the
  366. // primary column family that contains at least primary key columns
  367. string name = 1;
  368. // This specifies data storage settings for column family
  369. StoragePool data = 2;
  370. // Optionally specify how data should be compressed
  371. Compression compression = 3;
  372. // When enabled table data will be kept in memory
  373. // WARNING: DO NOT USE
  374. Ydb.FeatureFlag.Status keep_in_memory = 4;
  375. }
  376. message PartitioningSettings {
  377. // List of columns to partition by
  378. repeated string partition_by = 1;
  379. // Enable auto partitioning on reaching upper or lower partition size bound
  380. Ydb.FeatureFlag.Status partitioning_by_size = 2;
  381. // Preferred partition size for auto partitioning by size, Mb
  382. uint64 partition_size_mb = 3;
  383. // Enable auto partitioning based on load on each partition
  384. Ydb.FeatureFlag.Status partitioning_by_load = 4;
  385. reserved 5; // partitioning_by_load settings
  386. // Minimum partitions count auto merge would stop working at
  387. uint64 min_partitions_count = 6;
  388. // Maximum partitions count auto split would stop working at
  389. uint64 max_partitions_count = 7;
  390. }
  391. message AzReadReplicasSettings {
  392. // AZ name
  393. string name = 1;
  394. // Read replicas count in this AZ
  395. uint64 read_replicas_count = 2;
  396. }
  397. message ClusterReplicasSettings {
  398. // List of read replicas settings for each AZ
  399. repeated AzReadReplicasSettings az_read_replicas_settings = 2;
  400. }
  401. message ReadReplicasSettings {
  402. oneof settings {
  403. // Set equal read replicas count for every AZ
  404. uint64 per_az_read_replicas_count = 1;
  405. // Set total replicas count between all AZs
  406. uint64 any_az_read_replicas_count = 2;
  407. }
  408. // Specify read replicas count for each AZ in cluster
  409. reserved 3; // cluster_replicas_settings (part of oneof settings)
  410. }
  411. message CreateTableRequest {
  412. // Session identifier
  413. string session_id = 1;
  414. // Full path
  415. string path = 2;
  416. // Columns (name, type)
  417. repeated ColumnMeta columns = 3;
  418. // List of columns used as primary key
  419. repeated string primary_key = 4;
  420. // Table profile
  421. TableProfile profile = 5;
  422. Ydb.Operations.OperationParams operation_params = 6;
  423. // List of secondary indexes
  424. repeated TableIndex indexes = 7;
  425. // Table rows time to live settings
  426. TtlSettings ttl_settings = 8;
  427. // Storage settings for table
  428. StorageSettings storage_settings = 9;
  429. // Column families
  430. repeated ColumnFamily column_families = 10;
  431. // Attributes. Total size is limited to 10 KB.
  432. map<string, string> attributes = 11 [(map_key).length.range = {min: 1, max: 100}, (length).range = {min: 1, max: 4096}];
  433. // Predefined named set of settings for table compaction ["default", "small_table", "log_table"].
  434. string compaction_policy = 12;
  435. // Either one of the following partitions options can be specified
  436. oneof partitions {
  437. // Enable uniform partitioning using given partitions count.
  438. // The first components of primary key must have Uint32/Uint64 type.
  439. uint64 uniform_partitions = 13;
  440. // Explicitly specify key values which are used as borders for created partitions.
  441. ExplicitPartitions partition_at_keys = 14;
  442. }
  443. // Partitioning settings for table
  444. PartitioningSettings partitioning_settings = 15;
  445. // Bloom filter by key
  446. Ydb.FeatureFlag.Status key_bloom_filter = 16;
  447. // Read replicas settings for table
  448. ReadReplicasSettings read_replicas_settings = 17;
  449. // Tiering rules name. It specifies how data migrates from one tier (logical storage) to another.
  450. string tiering = 18;
  451. }
  452. message CreateTableResponse {
  453. Ydb.Operations.Operation operation = 1;
  454. }
  455. // Drop table with given path
  456. message DropTableRequest {
  457. // Session identifier
  458. string session_id = 1;
  459. // Full path
  460. string path = 2;
  461. reserved 3;
  462. Ydb.Operations.OperationParams operation_params = 4;
  463. }
  464. message DropTableResponse {
  465. Ydb.Operations.Operation operation = 1;
  466. }
  467. message RenameIndexItem {
  468. // Index name to rename
  469. string source_name = 1;
  470. // Target index name
  471. string destination_name = 2;
  472. // Move options
  473. bool replace_destination = 3;
  474. }
  475. // Alter table with given path
  476. message AlterTableRequest {
  477. // Session identifier
  478. string session_id = 1;
  479. // Full path
  480. string path = 2;
  481. // Columns (name, type) to add
  482. repeated ColumnMeta add_columns = 3;
  483. // Columns to remove
  484. repeated string drop_columns = 4;
  485. Ydb.Operations.OperationParams operation_params = 5;
  486. // Columns to alter
  487. repeated ColumnMeta alter_columns = 6;
  488. // Setup or remove time to live settings
  489. oneof ttl_action {
  490. TtlSettings set_ttl_settings = 7;
  491. google.protobuf.Empty drop_ttl_settings = 8;
  492. }
  493. // Add secondary indexes
  494. repeated TableIndex add_indexes = 9;
  495. // Remove secondary indexes
  496. repeated string drop_indexes = 10;
  497. // Change table storage settings
  498. StorageSettings alter_storage_settings = 11;
  499. // Add/alter column families
  500. repeated ColumnFamily add_column_families = 12;
  501. repeated ColumnFamily alter_column_families = 13;
  502. // Alter attributes. Leave the value blank to drop an attribute.
  503. // Cannot be used in combination with other fields (except session_id and path) at the moment.
  504. map<string, string> alter_attributes = 14 [(map_key).length.range = {min: 1, max: 100}, (length).le = 4096];
  505. // Set predefined named set of settings for table compaction ["default", "small_table", "log_table"].
  506. // Set "default" to use default preset.
  507. string set_compaction_policy = 15;
  508. // Change table partitioning settings
  509. PartitioningSettings alter_partitioning_settings = 16;
  510. // Enable/disable bloom filter by key
  511. Ydb.FeatureFlag.Status set_key_bloom_filter = 17;
  512. // Set read replicas settings for table
  513. ReadReplicasSettings set_read_replicas_settings = 18;
  514. // Add change feeds
  515. repeated Changefeed add_changefeeds = 19;
  516. // Remove change feeds (by its names)
  517. repeated string drop_changefeeds = 20;
  518. // Rename existed index
  519. repeated RenameIndexItem rename_indexes = 21;
  520. // Setup or remove tiering
  521. oneof tiering_action {
  522. string set_tiering = 22;
  523. google.protobuf.Empty drop_tiering = 23;
  524. }
  525. }
  526. message AlterTableResponse {
  527. Ydb.Operations.Operation operation = 1;
  528. }
  529. // Copy table with given path
  530. message CopyTableRequest {
  531. // Session identifier
  532. string session_id = 1;
  533. // Copy from path
  534. string source_path = 2;
  535. // Copy to path
  536. string destination_path = 3;
  537. Ydb.Operations.OperationParams operation_params = 4;
  538. }
  539. message CopyTableResponse {
  540. Ydb.Operations.Operation operation = 1;
  541. }
  542. message CopyTableItem {
  543. // Copy from path
  544. string source_path = 1;
  545. // Copy to path
  546. string destination_path = 2;
  547. // Copy options
  548. bool omit_indexes = 3;
  549. }
  550. // Creates consistent copy of given tables.
  551. message CopyTablesRequest {
  552. Ydb.Operations.OperationParams operation_params = 1;
  553. // Session identifier
  554. string session_id = 2;
  555. // Source and destination paths which describe copies
  556. repeated CopyTableItem tables = 3;
  557. }
  558. message CopyTablesResponse {
  559. Ydb.Operations.Operation operation = 1;
  560. }
  561. message RenameTableItem {
  562. // Full path
  563. string source_path = 1;
  564. // Full path
  565. string destination_path = 2;
  566. // Move options
  567. bool replace_destination = 3;
  568. }
  569. // Moves given tables
  570. message RenameTablesRequest {
  571. Ydb.Operations.OperationParams operation_params = 1;
  572. // Session identifier
  573. string session_id = 2;
  574. // Source and destination paths inside RenameTableItem describe rename actions
  575. repeated RenameTableItem tables = 3;
  576. }
  577. message RenameTablesResponse {
  578. Ydb.Operations.Operation operation = 1;
  579. }
  580. // Describe table with given path
  581. message DescribeTableRequest {
  582. // Session identifier
  583. string session_id = 1;
  584. // Full path
  585. string path = 2;
  586. Ydb.Operations.OperationParams operation_params = 4;
  587. // Includes shard key distribution info
  588. bool include_shard_key_bounds = 5;
  589. // Includes table statistics
  590. bool include_table_stats = 6;
  591. // Includes partition statistics (required include_table_statistics)
  592. bool include_partition_stats = 7;
  593. }
  594. message DescribeTableResponse {
  595. // Holds DescribeTableResult in case of successful call
  596. Ydb.Operations.Operation operation = 1;
  597. }
  598. message DescribeTableResult {
  599. // Description of scheme object
  600. Ydb.Scheme.Entry self = 1;
  601. // List of columns
  602. repeated ColumnMeta columns = 2;
  603. // List of primary key columns
  604. repeated string primary_key = 3;
  605. // List of key ranges for shard
  606. repeated TypedValue shard_key_bounds = 4;
  607. // List of indexes
  608. repeated TableIndexDescription indexes = 5;
  609. // Statistics of table
  610. TableStats table_stats = 6;
  611. // TTL params
  612. TtlSettings ttl_settings = 7;
  613. // Storage settings for table
  614. StorageSettings storage_settings = 8;
  615. // Column families
  616. repeated ColumnFamily column_families = 9;
  617. // Attributes
  618. map<string, string> attributes = 10;
  619. // Predefined named set of settings for table compaction
  620. reserved 11; // compaction_policy
  621. // Partitioning settings for table
  622. PartitioningSettings partitioning_settings = 12;
  623. // Bloom filter by key
  624. Ydb.FeatureFlag.Status key_bloom_filter = 13;
  625. // Read replicas settings for table
  626. ReadReplicasSettings read_replicas_settings = 14;
  627. // List of changefeeds
  628. repeated ChangefeedDescription changefeeds = 15;
  629. // Tiering rules name
  630. string tiering = 16;
  631. }
  632. message Query {
  633. // Text of query or id prepared query
  634. oneof query {
  635. // SQL program
  636. string yql_text = 1;
  637. // Prepared query id
  638. string id = 2;
  639. }
  640. }
  641. message SerializableModeSettings {
  642. }
  643. message OnlineModeSettings {
  644. bool allow_inconsistent_reads = 1;
  645. }
  646. message StaleModeSettings {
  647. }
  648. message SnapshotModeSettings {
  649. }
  650. message TransactionSettings {
  651. oneof tx_mode {
  652. SerializableModeSettings serializable_read_write = 1;
  653. OnlineModeSettings online_read_only = 2;
  654. StaleModeSettings stale_read_only = 3;
  655. SnapshotModeSettings snapshot_read_only = 4;
  656. }
  657. }
  658. message TransactionControl {
  659. oneof tx_selector {
  660. string tx_id = 1;
  661. TransactionSettings begin_tx = 2;
  662. }
  663. bool commit_tx = 10;
  664. }
  665. message QueryCachePolicy {
  666. bool keep_in_cache = 1;
  667. }
  668. // Collect and return query execution stats
  669. message QueryStatsCollection {
  670. enum Mode {
  671. STATS_COLLECTION_UNSPECIFIED = 0;
  672. STATS_COLLECTION_NONE = 1; // Stats collection is disabled
  673. STATS_COLLECTION_BASIC = 2; // Aggregated stats of reads, updates and deletes per table
  674. STATS_COLLECTION_FULL = 3; // Add execution stats and plan on top of STATS_COLLECTION_BASIC
  675. STATS_COLLECTION_PROFILE = 4; // Detailed execution stats including stats for individual tasks and channels
  676. }
  677. }
  678. message ExecuteDataQueryRequest {
  679. // Session identifier
  680. string session_id = 1;
  681. TransactionControl tx_control = 2;
  682. Query query = 3;
  683. // Map of query parameters (optional)
  684. map<string, TypedValue> parameters = 4;
  685. QueryCachePolicy query_cache_policy = 5;
  686. Ydb.Operations.OperationParams operation_params = 6;
  687. QueryStatsCollection.Mode collect_stats = 7;
  688. }
  689. message ExecuteDataQueryResponse {
  690. Ydb.Operations.Operation operation = 1;
  691. }
  692. message ExecuteSchemeQueryRequest {
  693. // Session identifier
  694. string session_id = 1;
  695. // SQL text
  696. string yql_text = 2;
  697. Ydb.Operations.OperationParams operation_params = 3;
  698. }
  699. message ExecuteSchemeQueryResponse {
  700. Ydb.Operations.Operation operation = 1;
  701. }
  702. // Holds transaction id
  703. message TransactionMeta {
  704. // Transaction identifier
  705. string id = 1;
  706. }
  707. // Holds query id and type of parameters
  708. message QueryMeta {
  709. // Query identifier
  710. string id = 1;
  711. // Type of parameters
  712. map<string, Type> parameters_types = 2;
  713. }
  714. // One QueryResult can contain multiple tables
  715. message ExecuteQueryResult {
  716. // Result rets (for each table)
  717. repeated Ydb.ResultSet result_sets = 1;
  718. // Transaction metadata
  719. TransactionMeta tx_meta = 2;
  720. // Query metadata
  721. QueryMeta query_meta = 3;
  722. // Query execution statistics
  723. Ydb.TableStats.QueryStats query_stats = 4;
  724. }
  725. // Explain data query
  726. message ExplainDataQueryRequest {
  727. // Session identifier
  728. string session_id = 1;
  729. // SQL text to explain
  730. string yql_text = 2;
  731. Ydb.Operations.OperationParams operation_params = 3;
  732. }
  733. message ExplainDataQueryResponse {
  734. // Holds ExplainQueryResult in case of successful call
  735. Ydb.Operations.Operation operation = 1;
  736. }
  737. message ExplainQueryResult {
  738. string query_ast = 1;
  739. string query_plan = 2;
  740. }
  741. // Prepare given program to execute
  742. message PrepareDataQueryRequest {
  743. // Session identifier
  744. string session_id = 1;
  745. // SQL text
  746. string yql_text = 2;
  747. Ydb.Operations.OperationParams operation_params = 3;
  748. }
  749. message PrepareDataQueryResponse {
  750. // Holds PrepareQueryResult in case of successful call
  751. Ydb.Operations.Operation operation = 1;
  752. }
  753. message PrepareQueryResult {
  754. // Query id, used to perform ExecuteDataQuery
  755. string query_id = 1;
  756. // Parameters type, used to fill in parameter values
  757. map<string, Type> parameters_types = 2;
  758. }
  759. // Keep session alive
  760. message KeepAliveRequest {
  761. // Session identifier
  762. string session_id = 1;
  763. Ydb.Operations.OperationParams operation_params = 2;
  764. }
  765. message KeepAliveResponse {
  766. Ydb.Operations.Operation operation = 1;
  767. }
  768. message KeepAliveResult {
  769. enum SessionStatus {
  770. SESSION_STATUS_UNSPECIFIED = 0;
  771. SESSION_STATUS_READY = 1;
  772. SESSION_STATUS_BUSY = 2;
  773. }
  774. SessionStatus session_status = 1;
  775. }
  776. // Begin transaction on given session with given settings
  777. message BeginTransactionRequest {
  778. // Session identifier
  779. string session_id = 1;
  780. TransactionSettings tx_settings = 2;
  781. Ydb.Operations.OperationParams operation_params = 3;
  782. }
  783. message BeginTransactionResponse {
  784. // Holds BeginTransactionResult in case of successful call
  785. Ydb.Operations.Operation operation = 1;
  786. }
  787. message BeginTransactionResult {
  788. TransactionMeta tx_meta = 1;
  789. }
  790. // Commit transaction with given session and tx id
  791. message CommitTransactionRequest {
  792. // Session identifier
  793. string session_id = 1;
  794. // Transaction identifier
  795. string tx_id = 2;
  796. Ydb.Operations.OperationParams operation_params = 3;
  797. QueryStatsCollection.Mode collect_stats = 4;
  798. }
  799. message CommitTransactionResponse {
  800. Ydb.Operations.Operation operation = 1;
  801. }
  802. message CommitTransactionResult {
  803. Ydb.TableStats.QueryStats query_stats = 1;
  804. }
  805. // Rollback transaction with given session and tx id
  806. message RollbackTransactionRequest {
  807. // Session identifier
  808. string session_id = 1;
  809. // Transaction identifier
  810. string tx_id = 2;
  811. Ydb.Operations.OperationParams operation_params = 3;
  812. }
  813. message RollbackTransactionResponse {
  814. Ydb.Operations.Operation operation = 1;
  815. }
  816. message StoragePolicyDescription {
  817. string name = 1;
  818. map<string, string> labels = 2;
  819. }
  820. message CompactionPolicyDescription {
  821. string name = 1;
  822. map<string, string> labels = 2;
  823. }
  824. message PartitioningPolicyDescription {
  825. string name = 1;
  826. map<string, string> labels = 2;
  827. }
  828. message ExecutionPolicyDescription {
  829. string name = 1;
  830. map<string, string> labels = 2;
  831. }
  832. message ReplicationPolicyDescription {
  833. string name = 1;
  834. map<string, string> labels = 2;
  835. }
  836. message CachingPolicyDescription {
  837. string name = 1;
  838. map<string, string> labels = 2;
  839. }
  840. message TableProfileDescription {
  841. string name = 1;
  842. map<string, string> labels = 2;
  843. string default_storage_policy = 3;
  844. repeated string allowed_storage_policies = 4;
  845. string default_compaction_policy = 5;
  846. repeated string allowed_compaction_policies = 6;
  847. string default_partitioning_policy = 7;
  848. repeated string allowed_partitioning_policies = 8;
  849. string default_execution_policy = 9;
  850. repeated string allowed_execution_policies = 10;
  851. string default_replication_policy = 11;
  852. repeated string allowed_replication_policies = 12;
  853. string default_caching_policy = 13;
  854. repeated string allowed_caching_policies = 14;
  855. }
  856. message DescribeTableOptionsRequest {
  857. Ydb.Operations.OperationParams operation_params = 1;
  858. }
  859. message DescribeTableOptionsResponse {
  860. // operation.result holds ListTableParametersResult
  861. Ydb.Operations.Operation operation = 1;
  862. }
  863. message DescribeTableOptionsResult {
  864. repeated TableProfileDescription table_profile_presets = 1;
  865. repeated StoragePolicyDescription storage_policy_presets = 2;
  866. repeated CompactionPolicyDescription compaction_policy_presets = 3;
  867. repeated PartitioningPolicyDescription partitioning_policy_presets = 4;
  868. repeated ExecutionPolicyDescription execution_policy_presets = 5;
  869. repeated ReplicationPolicyDescription replication_policy_presets = 6;
  870. repeated CachingPolicyDescription caching_policy_presets = 7;
  871. }
  872. // ReadTable request/response
  873. message KeyRange {
  874. // Left border
  875. oneof from_bound {
  876. // Specify if we don't want to include given key
  877. TypedValue greater = 1;
  878. // Specify if we want to include given key
  879. TypedValue greater_or_equal = 2;
  880. }
  881. // Right border
  882. oneof to_bound {
  883. // Specify if we don't want to include given key
  884. TypedValue less = 3;
  885. // Specify if we want to include given key
  886. TypedValue less_or_equal = 4;
  887. }
  888. }
  889. // Request to read table (without SQL)
  890. message ReadTableRequest {
  891. // Session identifier
  892. string session_id = 1;
  893. // Path to table to read
  894. string path = 2;
  895. // Primary key range to read
  896. KeyRange key_range = 3;
  897. // Output columns
  898. repeated string columns = 4;
  899. // Require ordered reading
  900. bool ordered = 5;
  901. // Limits row count to read
  902. uint64 row_limit = 6;
  903. // Use a server-side snapshot
  904. Ydb.FeatureFlag.Status use_snapshot = 7;
  905. // Per-batch limits
  906. uint64 batch_limit_bytes = 8;
  907. uint64 batch_limit_rows = 9;
  908. }
  909. // ReadTable doesn't use Operation, returns result directly
  910. message ReadTableResponse {
  911. // Status of request (same as other statuses)
  912. StatusIds.StatusCode status = 1;
  913. // Issues
  914. repeated Ydb.Issue.IssueMessage issues = 2;
  915. // Optional snapshot that corresponds to the returned data
  916. VirtualTimestamp snapshot = 4;
  917. // Read table result
  918. ReadTableResult result = 3;
  919. }
  920. // Result of read table request
  921. message ReadTableResult {
  922. // Result set (same as result of sql request)
  923. Ydb.ResultSet result_set = 1;
  924. }
  925. message ReadRowsRequest {
  926. // Session identifier
  927. string session_id = 1;
  928. // Path to table to read
  929. string path = 2;
  930. // Keys to read. Must be a list of structs where each stuct is a key
  931. // for one requested row and should contain all key columns
  932. TypedValue keys = 3;
  933. // Output columns. If empty all columns will be requested
  934. repeated string columns = 4;
  935. }
  936. message ReadRowsResponse {
  937. // Status of request (same as other statuses)
  938. StatusIds.StatusCode status = 1;
  939. // Issues
  940. repeated Ydb.Issue.IssueMessage issues = 2;
  941. // Result set (same as result of sql request)
  942. Ydb.ResultSet result_set = 3;
  943. }
  944. message BulkUpsertRequest {
  945. string table = 1;
  946. // "rows" parameter must be a list of structs where each stuct represents one row.
  947. // It must contain all key columns but not necessarily all non-key columns.
  948. // Similar to UPSERT statement only values of specified columns will be updated.
  949. TypedValue rows = 2;
  950. Ydb.Operations.OperationParams operation_params = 3;
  951. // You may set data_format + data instead of rows to insert data in serialized formats.
  952. oneof data_format {
  953. Ydb.Formats.ArrowBatchSettings arrow_batch_settings = 7;
  954. Ydb.Formats.CsvSettings csv_settings = 8;
  955. }
  956. // It's last in the definition to help with sidecar patterns
  957. bytes data = 1000;
  958. }
  959. message BulkUpsertResponse {
  960. Ydb.Operations.Operation operation = 1;
  961. }
  962. message BulkUpsertResult {
  963. }
  964. message ExecuteScanQueryRequest {
  965. enum Mode {
  966. MODE_UNSPECIFIED = 0;
  967. MODE_EXPLAIN = 1;
  968. // MODE_PREPARE = 2;
  969. MODE_EXEC = 3;
  970. }
  971. reserved 1; // session_id
  972. reserved 2; // tx_control
  973. Query query = 3;
  974. map<string, TypedValue> parameters = 4;
  975. reserved 5; // query_cache_policy
  976. Mode mode = 6;
  977. reserved 7; // report_progress
  978. QueryStatsCollection.Mode collect_stats = 8;
  979. }
  980. message ExecuteScanQueryPartialResponse {
  981. StatusIds.StatusCode status = 1;
  982. repeated Ydb.Issue.IssueMessage issues = 2;
  983. ExecuteScanQueryPartialResult result = 3;
  984. }
  985. message ExecuteScanQueryPartialResult {
  986. Ydb.ResultSet result_set = 1;
  987. reserved 2; // tx_meta
  988. reserved 3; // query_meta
  989. reserved 4; // query_progress
  990. reserved 5; // query_plan
  991. Ydb.TableStats.QueryStats query_stats = 6;
  992. }