multiple requests to the structure of a tables at once(batching)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ steel_decimal/tests/property_tests.proptest-regressions
|
|||||||
.direnv/
|
.direnv/
|
||||||
canvas/*.toml
|
canvas/*.toml
|
||||||
.aider*
|
.aider*
|
||||||
|
.codex
|
||||||
|
|||||||
2
client
2
client
Submodule client updated: 6a32d8cb3a...8138995272
@@ -4,40 +4,45 @@ package komp_ac.table_structure;
|
|||||||
|
|
||||||
import "common.proto";
|
import "common.proto";
|
||||||
|
|
||||||
// Introspects the physical PostgreSQL table for a given logical table
|
// Introspects the physical PostgreSQL tables for one or more logical tables
|
||||||
// (defined in table_definitions) and returns its column structure.
|
// (defined in table_definitions) and returns their column structures.
|
||||||
// The server validates that:
|
// The server validates that:
|
||||||
// - The profile (schema) exists in `schemas`
|
// - The profile (schema) exists in `schemas`
|
||||||
// - The table is defined for that profile in `table_definitions`
|
// - Every table is defined for that profile in `table_definitions`
|
||||||
// It then queries information_schema for the physical table and returns
|
// It then queries information_schema for the physical tables and returns
|
||||||
// normalized column metadata. If the physical table is missing despite
|
// normalized column metadata.
|
||||||
// a definition, the response may contain an empty `columns` list.
|
|
||||||
service TableStructureService {
|
service TableStructureService {
|
||||||
// Return the physical column list (name, normalized data_type,
|
// Return the physical column list (name, normalized data_type,
|
||||||
// nullability, primary key flag) for a table in a profile.
|
// nullability, primary key flag) for one or more tables in a profile.
|
||||||
//
|
//
|
||||||
// Behavior:
|
// Behavior:
|
||||||
// - NOT_FOUND if profile doesn't exist in `schemas`
|
// - NOT_FOUND if profile doesn't exist in `schemas`
|
||||||
// - NOT_FOUND if table not defined for that profile in `table_definitions`
|
// - NOT_FOUND if any table is not defined for that profile in `table_definitions`
|
||||||
// - Queries information_schema.columns ordered by ordinal position
|
// - Queries information_schema.columns ordered by ordinal position
|
||||||
// - Normalizes data_type text (details under TableColumn.data_type)
|
// - Normalizes data_type text (details under TableColumn.data_type)
|
||||||
// - Returns an empty list if the table is validated but has no visible
|
// - Returns an error if any validated table has no visible columns in
|
||||||
// columns in information_schema (e.g., physical table missing)
|
// information_schema (e.g., physical table missing)
|
||||||
rpc GetTableStructure(GetTableStructureRequest) returns (TableStructureResponse);
|
rpc GetTableStructure(GetTableStructureRequest) returns (GetTableStructureResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request identifying the profile (schema) and table to inspect.
|
// Request identifying the profile (schema) and tables to inspect.
|
||||||
message GetTableStructureRequest {
|
message GetTableStructureRequest {
|
||||||
// Required. Profile (PostgreSQL schema) name. Must exist in `schemas`.
|
// Required. Profile (PostgreSQL schema) name. Must exist in `schemas`.
|
||||||
string profile_name = 1;
|
string profile_name = 1;
|
||||||
|
|
||||||
// Required. Table name within the profile. Must exist in `table_definitions`
|
// Required. Table names within the profile. Each must exist in
|
||||||
// for the given profile. The physical table is then introspected via
|
// `table_definitions` for the given profile. The physical tables are then
|
||||||
// information_schema.
|
// introspected via information_schema.
|
||||||
string table_name = 2;
|
repeated string table_names = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Response with the ordered list of columns (by ordinal position).
|
// Batched response keyed by table name.
|
||||||
|
message GetTableStructureResponse {
|
||||||
|
// Per-table physical column lists keyed by requested table name.
|
||||||
|
map<string, TableStructureResponse> table_structures = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Response with the ordered list of columns (by ordinal position) for one table.
|
||||||
message TableStructureResponse {
|
message TableStructureResponse {
|
||||||
// Columns of the physical table, including system columns (id, deleted,
|
// Columns of the physical table, including system columns (id, deleted,
|
||||||
// created_at), user-defined columns, and any foreign-key columns such as
|
// created_at), user-defined columns, and any foreign-key columns such as
|
||||||
|
|||||||
Binary file not shown.
@@ -1,17 +1,27 @@
|
|||||||
// This file is @generated by prost-build.
|
// This file is @generated by prost-build.
|
||||||
/// Request identifying the profile (schema) and table to inspect.
|
/// Request identifying the profile (schema) and tables to inspect.
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct GetTableStructureRequest {
|
pub struct GetTableStructureRequest {
|
||||||
/// Required. Profile (PostgreSQL schema) name. Must exist in `schemas`.
|
/// Required. Profile (PostgreSQL schema) name. Must exist in `schemas`.
|
||||||
#[prost(string, tag = "1")]
|
#[prost(string, tag = "1")]
|
||||||
pub profile_name: ::prost::alloc::string::String,
|
pub profile_name: ::prost::alloc::string::String,
|
||||||
/// Required. Table name within the profile. Must exist in `table_definitions`
|
/// Required. Table names within the profile. Each must exist in
|
||||||
/// for the given profile. The physical table is then introspected via
|
/// `table_definitions` for the given profile. The physical tables are then
|
||||||
/// information_schema.
|
/// introspected via information_schema.
|
||||||
#[prost(string, tag = "2")]
|
#[prost(string, repeated, tag = "2")]
|
||||||
pub table_name: ::prost::alloc::string::String,
|
pub table_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
||||||
}
|
}
|
||||||
/// Response with the ordered list of columns (by ordinal position).
|
/// Batched response keyed by table name.
|
||||||
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
|
pub struct GetTableStructureResponse {
|
||||||
|
/// Per-table physical column lists keyed by requested table name.
|
||||||
|
#[prost(map = "string, message", tag = "1")]
|
||||||
|
pub table_structures: ::std::collections::HashMap<
|
||||||
|
::prost::alloc::string::String,
|
||||||
|
TableStructureResponse,
|
||||||
|
>,
|
||||||
|
}
|
||||||
|
/// Response with the ordered list of columns (by ordinal position) for one table.
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct TableStructureResponse {
|
pub struct TableStructureResponse {
|
||||||
/// Columns of the physical table, including system columns (id, deleted,
|
/// Columns of the physical table, including system columns (id, deleted,
|
||||||
@@ -55,14 +65,13 @@ pub mod table_structure_service_client {
|
|||||||
)]
|
)]
|
||||||
use tonic::codegen::*;
|
use tonic::codegen::*;
|
||||||
use tonic::codegen::http::Uri;
|
use tonic::codegen::http::Uri;
|
||||||
/// Introspects the physical PostgreSQL table for a given logical table
|
/// Introspects the physical PostgreSQL tables for one or more logical tables
|
||||||
/// (defined in table_definitions) and returns its column structure.
|
/// (defined in table_definitions) and returns their column structures.
|
||||||
/// The server validates that:
|
/// The server validates that:
|
||||||
/// - The profile (schema) exists in `schemas`
|
/// - The profile (schema) exists in `schemas`
|
||||||
/// - The table is defined for that profile in `table_definitions`
|
/// - Every table is defined for that profile in `table_definitions`
|
||||||
/// It then queries information_schema for the physical table and returns
|
/// It then queries information_schema for the physical tables and returns
|
||||||
/// normalized column metadata. If the physical table is missing despite
|
/// normalized column metadata.
|
||||||
/// a definition, the response may contain an empty `columns` list.
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct TableStructureServiceClient<T> {
|
pub struct TableStructureServiceClient<T> {
|
||||||
inner: tonic::client::Grpc<T>,
|
inner: tonic::client::Grpc<T>,
|
||||||
@@ -144,20 +153,20 @@ pub mod table_structure_service_client {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
/// Return the physical column list (name, normalized data_type,
|
/// Return the physical column list (name, normalized data_type,
|
||||||
/// nullability, primary key flag) for a table in a profile.
|
/// nullability, primary key flag) for one or more tables in a profile.
|
||||||
///
|
///
|
||||||
/// Behavior:
|
/// Behavior:
|
||||||
/// - NOT_FOUND if profile doesn't exist in `schemas`
|
/// - NOT_FOUND if profile doesn't exist in `schemas`
|
||||||
/// - NOT_FOUND if table not defined for that profile in `table_definitions`
|
/// - NOT_FOUND if any table is not defined for that profile in `table_definitions`
|
||||||
/// - Queries information_schema.columns ordered by ordinal position
|
/// - Queries information_schema.columns ordered by ordinal position
|
||||||
/// - Normalizes data_type text (details under TableColumn.data_type)
|
/// - Normalizes data_type text (details under TableColumn.data_type)
|
||||||
/// - Returns an empty list if the table is validated but has no visible
|
/// - Returns an error if any validated table has no visible columns in
|
||||||
/// columns in information_schema (e.g., physical table missing)
|
/// information_schema (e.g., physical table missing)
|
||||||
pub async fn get_table_structure(
|
pub async fn get_table_structure(
|
||||||
&mut self,
|
&mut self,
|
||||||
request: impl tonic::IntoRequest<super::GetTableStructureRequest>,
|
request: impl tonic::IntoRequest<super::GetTableStructureRequest>,
|
||||||
) -> std::result::Result<
|
) -> std::result::Result<
|
||||||
tonic::Response<super::TableStructureResponse>,
|
tonic::Response<super::GetTableStructureResponse>,
|
||||||
tonic::Status,
|
tonic::Status,
|
||||||
> {
|
> {
|
||||||
self.inner
|
self.inner
|
||||||
@@ -198,31 +207,30 @@ pub mod table_structure_service_server {
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait TableStructureService: std::marker::Send + std::marker::Sync + 'static {
|
pub trait TableStructureService: std::marker::Send + std::marker::Sync + 'static {
|
||||||
/// Return the physical column list (name, normalized data_type,
|
/// Return the physical column list (name, normalized data_type,
|
||||||
/// nullability, primary key flag) for a table in a profile.
|
/// nullability, primary key flag) for one or more tables in a profile.
|
||||||
///
|
///
|
||||||
/// Behavior:
|
/// Behavior:
|
||||||
/// - NOT_FOUND if profile doesn't exist in `schemas`
|
/// - NOT_FOUND if profile doesn't exist in `schemas`
|
||||||
/// - NOT_FOUND if table not defined for that profile in `table_definitions`
|
/// - NOT_FOUND if any table is not defined for that profile in `table_definitions`
|
||||||
/// - Queries information_schema.columns ordered by ordinal position
|
/// - Queries information_schema.columns ordered by ordinal position
|
||||||
/// - Normalizes data_type text (details under TableColumn.data_type)
|
/// - Normalizes data_type text (details under TableColumn.data_type)
|
||||||
/// - Returns an empty list if the table is validated but has no visible
|
/// - Returns an error if any validated table has no visible columns in
|
||||||
/// columns in information_schema (e.g., physical table missing)
|
/// information_schema (e.g., physical table missing)
|
||||||
async fn get_table_structure(
|
async fn get_table_structure(
|
||||||
&self,
|
&self,
|
||||||
request: tonic::Request<super::GetTableStructureRequest>,
|
request: tonic::Request<super::GetTableStructureRequest>,
|
||||||
) -> std::result::Result<
|
) -> std::result::Result<
|
||||||
tonic::Response<super::TableStructureResponse>,
|
tonic::Response<super::GetTableStructureResponse>,
|
||||||
tonic::Status,
|
tonic::Status,
|
||||||
>;
|
>;
|
||||||
}
|
}
|
||||||
/// Introspects the physical PostgreSQL table for a given logical table
|
/// Introspects the physical PostgreSQL tables for one or more logical tables
|
||||||
/// (defined in table_definitions) and returns its column structure.
|
/// (defined in table_definitions) and returns their column structures.
|
||||||
/// The server validates that:
|
/// The server validates that:
|
||||||
/// - The profile (schema) exists in `schemas`
|
/// - The profile (schema) exists in `schemas`
|
||||||
/// - The table is defined for that profile in `table_definitions`
|
/// - Every table is defined for that profile in `table_definitions`
|
||||||
/// It then queries information_schema for the physical table and returns
|
/// It then queries information_schema for the physical tables and returns
|
||||||
/// normalized column metadata. If the physical table is missing despite
|
/// normalized column metadata.
|
||||||
/// a definition, the response may contain an empty `columns` list.
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TableStructureServiceServer<T> {
|
pub struct TableStructureServiceServer<T> {
|
||||||
inner: Arc<T>,
|
inner: Arc<T>,
|
||||||
@@ -307,7 +315,7 @@ pub mod table_structure_service_server {
|
|||||||
T: TableStructureService,
|
T: TableStructureService,
|
||||||
> tonic::server::UnaryService<super::GetTableStructureRequest>
|
> tonic::server::UnaryService<super::GetTableStructureRequest>
|
||||||
for GetTableStructureSvc<T> {
|
for GetTableStructureSvc<T> {
|
||||||
type Response = super::TableStructureResponse;
|
type Response = super::GetTableStructureResponse;
|
||||||
type Future = BoxFuture<
|
type Future = BoxFuture<
|
||||||
tonic::Response<Self::Response>,
|
tonic::Response<Self::Response>,
|
||||||
tonic::Status,
|
tonic::Status,
|
||||||
|
|||||||
2
server
2
server
Submodule server updated: 82df1dea82...51f3eca615
Reference in New Issue
Block a user