1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct SqlServiceQueryRequest {
4 #[prost(string, tag = "1")]
5 pub query: ::prost::alloc::string::String,
6 #[prost(int32, optional, tag = "2")]
7 pub max_rows: ::core::option::Option<i32>,
8 #[prost(string, tag = "3")]
9 pub workspace_rid: ::prost::alloc::string::String,
10}
11#[derive(Clone, PartialEq, ::prost::Message)]
12pub struct SqlServiceQueryResponse {
13 #[prost(bytes = "vec", tag = "1")]
14 pub arrow_payload: ::prost::alloc::vec::Vec<u8>,
15 #[prost(string, tag = "2")]
16 pub query_id: ::prost::alloc::string::String,
17}
18#[derive(Clone, PartialEq, ::prost::Message)]
19pub struct SqlServiceExportRequest {
20 #[prost(string, tag = "1")]
21 pub query: ::prost::alloc::string::String,
22 #[prost(string, tag = "2")]
23 pub workspace_rid: ::prost::alloc::string::String,
24}
25#[derive(Clone, PartialEq, ::prost::Message)]
26pub struct SqlServiceExportResponse {
27 #[prost(string, tag = "1")]
28 pub presigned_url: ::prost::alloc::string::String,
29 #[prost(string, tag = "2")]
30 pub query_id: ::prost::alloc::string::String,
31}
32#[derive(Clone, Copy, PartialEq, ::prost::Message)]
33pub struct GetSqlCatalogRequest {}
34#[derive(Clone, PartialEq, ::prost::Message)]
35pub struct SqlCatalogColumn {
36 #[prost(string, tag = "1")]
37 pub name: ::prost::alloc::string::String,
38 #[prost(string, tag = "2")]
39 pub r#type: ::prost::alloc::string::String,
40 #[prost(bool, tag = "3")]
41 pub nullable: bool,
42}
43#[derive(Clone, PartialEq, ::prost::Message)]
44pub struct SqlCatalogTable {
45 #[prost(string, tag = "1")]
46 pub name: ::prost::alloc::string::String,
47 #[prost(message, repeated, tag = "2")]
48 pub columns: ::prost::alloc::vec::Vec<SqlCatalogColumn>,
49}
50#[derive(Clone, PartialEq, ::prost::Message)]
51pub struct SqlCatalogFunction {
52 #[prost(string, tag = "1")]
53 pub name: ::prost::alloc::string::String,
54}
55#[derive(Clone, PartialEq, ::prost::Message)]
56pub struct SqlCatalog {
57 #[prost(message, repeated, tag = "1")]
58 pub tables: ::prost::alloc::vec::Vec<SqlCatalogTable>,
59 #[prost(message, repeated, tag = "2")]
60 pub functions: ::prost::alloc::vec::Vec<SqlCatalogFunction>,
61}
62#[derive(Clone, PartialEq, ::prost::Message)]
63pub struct GetSqlCatalogResponse {
64 #[prost(message, optional, tag = "1")]
65 pub sql_catalog: ::core::option::Option<SqlCatalog>,
66}
67#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
68#[repr(i32)]
69pub enum SqlError {
70 Unspecified = 0,
71 InvalidQuery = 1,
72 DatasetsNotFound = 2,
73 ExecutionFailed = 3,
74 ExportNotSupportedForBackend = 4,
75 ExportNotConfigured = 5,
76 QueryTimeout = 6,
77 ResourceExhausted = 7,
78}
79impl SqlError {
80 pub fn as_str_name(&self) -> &'static str {
85 match self {
86 Self::Unspecified => "SQL_ERROR_UNSPECIFIED",
87 Self::InvalidQuery => "SQL_ERROR_INVALID_QUERY",
88 Self::DatasetsNotFound => "SQL_ERROR_DATASETS_NOT_FOUND",
89 Self::ExecutionFailed => "SQL_ERROR_EXECUTION_FAILED",
90 Self::ExportNotSupportedForBackend => {
91 "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND"
92 }
93 Self::ExportNotConfigured => "SQL_ERROR_EXPORT_NOT_CONFIGURED",
94 Self::QueryTimeout => "SQL_ERROR_QUERY_TIMEOUT",
95 Self::ResourceExhausted => "SQL_ERROR_RESOURCE_EXHAUSTED",
96 }
97 }
98 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
100 match value {
101 "SQL_ERROR_UNSPECIFIED" => Some(Self::Unspecified),
102 "SQL_ERROR_INVALID_QUERY" => Some(Self::InvalidQuery),
103 "SQL_ERROR_DATASETS_NOT_FOUND" => Some(Self::DatasetsNotFound),
104 "SQL_ERROR_EXECUTION_FAILED" => Some(Self::ExecutionFailed),
105 "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND" => {
106 Some(Self::ExportNotSupportedForBackend)
107 }
108 "SQL_ERROR_EXPORT_NOT_CONFIGURED" => Some(Self::ExportNotConfigured),
109 "SQL_ERROR_QUERY_TIMEOUT" => Some(Self::QueryTimeout),
110 "SQL_ERROR_RESOURCE_EXHAUSTED" => Some(Self::ResourceExhausted),
111 _ => None,
112 }
113 }
114}
115pub mod sql_service_client {
117 #![allow(
118 unused_variables,
119 dead_code,
120 missing_docs,
121 clippy::wildcard_imports,
122 clippy::let_unit_value,
123 )]
124 use tonic::codegen::*;
125 use tonic::codegen::http::Uri;
126 #[derive(Debug, Clone)]
127 pub struct SqlServiceClient<T> {
128 inner: tonic::client::Grpc<T>,
129 }
130 impl SqlServiceClient<tonic::transport::Channel> {
131 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
133 where
134 D: TryInto<tonic::transport::Endpoint>,
135 D::Error: Into<StdError>,
136 {
137 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
138 Ok(Self::new(conn))
139 }
140 }
141 impl<T> SqlServiceClient<T>
142 where
143 T: tonic::client::GrpcService<tonic::body::Body>,
144 T::Error: Into<StdError>,
145 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
146 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
147 {
148 pub fn new(inner: T) -> Self {
149 let inner = tonic::client::Grpc::new(inner);
150 Self { inner }
151 }
152 pub fn with_origin(inner: T, origin: Uri) -> Self {
153 let inner = tonic::client::Grpc::with_origin(inner, origin);
154 Self { inner }
155 }
156 pub fn with_interceptor<F>(
157 inner: T,
158 interceptor: F,
159 ) -> SqlServiceClient<InterceptedService<T, F>>
160 where
161 F: tonic::service::Interceptor,
162 T::ResponseBody: Default,
163 T: tonic::codegen::Service<
164 http::Request<tonic::body::Body>,
165 Response = http::Response<
166 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
167 >,
168 >,
169 <T as tonic::codegen::Service<
170 http::Request<tonic::body::Body>,
171 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
172 {
173 SqlServiceClient::new(InterceptedService::new(inner, interceptor))
174 }
175 #[must_use]
180 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
181 self.inner = self.inner.send_compressed(encoding);
182 self
183 }
184 #[must_use]
186 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
187 self.inner = self.inner.accept_compressed(encoding);
188 self
189 }
190 #[must_use]
194 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
195 self.inner = self.inner.max_decoding_message_size(limit);
196 self
197 }
198 #[must_use]
202 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
203 self.inner = self.inner.max_encoding_message_size(limit);
204 self
205 }
206 pub async fn query(
207 &mut self,
208 request: impl tonic::IntoRequest<super::SqlServiceQueryRequest>,
209 ) -> std::result::Result<
210 tonic::Response<super::SqlServiceQueryResponse>,
211 tonic::Status,
212 > {
213 self.inner
214 .ready()
215 .await
216 .map_err(|e| {
217 tonic::Status::unknown(
218 format!("Service was not ready: {}", e.into()),
219 )
220 })?;
221 let codec = tonic::codec::ProstCodec::default();
222 let path = http::uri::PathAndQuery::from_static(
223 "/nominal.sql.v1.SqlService/Query",
224 );
225 let mut req = request.into_request();
226 req.extensions_mut()
227 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Query"));
228 self.inner.unary(req, path, codec).await
229 }
230 pub async fn export(
231 &mut self,
232 request: impl tonic::IntoRequest<super::SqlServiceExportRequest>,
233 ) -> std::result::Result<
234 tonic::Response<super::SqlServiceExportResponse>,
235 tonic::Status,
236 > {
237 self.inner
238 .ready()
239 .await
240 .map_err(|e| {
241 tonic::Status::unknown(
242 format!("Service was not ready: {}", e.into()),
243 )
244 })?;
245 let codec = tonic::codec::ProstCodec::default();
246 let path = http::uri::PathAndQuery::from_static(
247 "/nominal.sql.v1.SqlService/Export",
248 );
249 let mut req = request.into_request();
250 req.extensions_mut()
251 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Export"));
252 self.inner.unary(req, path, codec).await
253 }
254 pub async fn get_sql_catalog(
255 &mut self,
256 request: impl tonic::IntoRequest<super::GetSqlCatalogRequest>,
257 ) -> std::result::Result<
258 tonic::Response<super::GetSqlCatalogResponse>,
259 tonic::Status,
260 > {
261 self.inner
262 .ready()
263 .await
264 .map_err(|e| {
265 tonic::Status::unknown(
266 format!("Service was not ready: {}", e.into()),
267 )
268 })?;
269 let codec = tonic::codec::ProstCodec::default();
270 let path = http::uri::PathAndQuery::from_static(
271 "/nominal.sql.v1.SqlService/GetSqlCatalog",
272 );
273 let mut req = request.into_request();
274 req.extensions_mut()
275 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "GetSqlCatalog"));
276 self.inner.unary(req, path, codec).await
277 }
278 }
279}