1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct SqlQueryLogEvent {
4 #[prost(string, tag = "1")]
5 pub query_id: ::prost::alloc::string::String,
6 #[prost(enumeration = "SqlQueryEventType", tag = "2")]
7 pub event_type: i32,
8 #[prost(string, tag = "3")]
9 pub workspace_rid: ::prost::alloc::string::String,
10 #[prost(string, tag = "4")]
11 pub user_rid: ::prost::alloc::string::String,
12 #[prost(enumeration = "SqlQueryBackend", repeated, tag = "5")]
13 pub backends: ::prost::alloc::vec::Vec<i32>,
14 #[prost(enumeration = "SqlQueryStatus", optional, tag = "6")]
15 pub status: ::core::option::Option<i32>,
16 #[prost(string, tag = "7")]
17 pub query_text: ::prost::alloc::string::String,
18 #[prost(message, optional, tag = "8")]
19 pub event_time: ::core::option::Option<
20 super::super::super::google::protobuf::Timestamp,
21 >,
22 #[prost(message, optional, tag = "9")]
23 pub started_at: ::core::option::Option<
24 super::super::super::google::protobuf::Timestamp,
25 >,
26 #[prost(message, optional, tag = "10")]
27 pub finished_at: ::core::option::Option<
28 super::super::super::google::protobuf::Timestamp,
29 >,
30 #[prost(int64, optional, tag = "11")]
31 pub duration_ms: ::core::option::Option<i64>,
32}
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
34#[repr(i32)]
35pub enum SqlQueryEventType {
36 QueryStart = 0,
37 QueryFinish = 1,
38}
39impl SqlQueryEventType {
40 pub fn as_str_name(&self) -> &'static str {
45 match self {
46 Self::QueryStart => "SQL_QUERY_EVENT_TYPE_QUERY_START",
47 Self::QueryFinish => "SQL_QUERY_EVENT_TYPE_QUERY_FINISH",
48 }
49 }
50 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
52 match value {
53 "SQL_QUERY_EVENT_TYPE_QUERY_START" => Some(Self::QueryStart),
54 "SQL_QUERY_EVENT_TYPE_QUERY_FINISH" => Some(Self::QueryFinish),
55 _ => None,
56 }
57 }
58}
59#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
60#[repr(i32)]
61pub enum SqlQueryBackend {
62 Clickhouse = 0,
63 Postgres = 1,
64}
65impl SqlQueryBackend {
66 pub fn as_str_name(&self) -> &'static str {
71 match self {
72 Self::Clickhouse => "SQL_QUERY_BACKEND_CLICKHOUSE",
73 Self::Postgres => "SQL_QUERY_BACKEND_POSTGRES",
74 }
75 }
76 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
78 match value {
79 "SQL_QUERY_BACKEND_CLICKHOUSE" => Some(Self::Clickhouse),
80 "SQL_QUERY_BACKEND_POSTGRES" => Some(Self::Postgres),
81 _ => None,
82 }
83 }
84}
85#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
86#[repr(i32)]
87pub enum SqlQueryStatus {
88 Succeeded = 0,
89 Failed = 1,
90 Throttled = 2,
91 TimedOut = 3,
92}
93impl SqlQueryStatus {
94 pub fn as_str_name(&self) -> &'static str {
99 match self {
100 Self::Succeeded => "SQL_QUERY_STATUS_SUCCEEDED",
101 Self::Failed => "SQL_QUERY_STATUS_FAILED",
102 Self::Throttled => "SQL_QUERY_STATUS_THROTTLED",
103 Self::TimedOut => "SQL_QUERY_STATUS_TIMED_OUT",
104 }
105 }
106 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
108 match value {
109 "SQL_QUERY_STATUS_SUCCEEDED" => Some(Self::Succeeded),
110 "SQL_QUERY_STATUS_FAILED" => Some(Self::Failed),
111 "SQL_QUERY_STATUS_THROTTLED" => Some(Self::Throttled),
112 "SQL_QUERY_STATUS_TIMED_OUT" => Some(Self::TimedOut),
113 _ => None,
114 }
115 }
116}
117#[derive(Clone, PartialEq, ::prost::Message)]
118pub struct SqlServiceQueryRequest {
119 #[prost(string, tag = "1")]
120 pub query: ::prost::alloc::string::String,
121 #[prost(int32, optional, tag = "2")]
122 pub max_rows: ::core::option::Option<i32>,
123 #[prost(string, tag = "3")]
124 pub workspace_rid: ::prost::alloc::string::String,
125}
126#[derive(Clone, PartialEq, ::prost::Message)]
127pub struct SqlServiceQueryResponse {
128 #[prost(bytes = "vec", tag = "1")]
129 pub arrow_payload: ::prost::alloc::vec::Vec<u8>,
130 #[prost(string, tag = "2")]
131 pub query_id: ::prost::alloc::string::String,
132}
133#[derive(Clone, PartialEq, ::prost::Message)]
134pub struct SqlServiceExportRequest {
135 #[prost(string, tag = "1")]
136 pub query: ::prost::alloc::string::String,
137 #[prost(string, tag = "2")]
138 pub workspace_rid: ::prost::alloc::string::String,
139}
140#[derive(Clone, PartialEq, ::prost::Message)]
141pub struct SqlServiceExportResponse {
142 #[prost(string, tag = "1")]
143 pub presigned_url: ::prost::alloc::string::String,
144 #[prost(string, tag = "2")]
145 pub query_id: ::prost::alloc::string::String,
146}
147#[derive(Clone, Copy, PartialEq, ::prost::Message)]
148pub struct GetSqlCatalogRequest {}
149#[derive(Clone, PartialEq, ::prost::Message)]
150pub struct SqlCatalogColumn {
151 #[prost(string, tag = "1")]
152 pub name: ::prost::alloc::string::String,
153 #[prost(string, tag = "2")]
154 pub r#type: ::prost::alloc::string::String,
155 #[prost(bool, tag = "3")]
156 pub nullable: bool,
157}
158#[derive(Clone, PartialEq, ::prost::Message)]
159pub struct SqlCatalogTable {
160 #[prost(string, tag = "1")]
161 pub name: ::prost::alloc::string::String,
162 #[prost(message, repeated, tag = "2")]
163 pub columns: ::prost::alloc::vec::Vec<SqlCatalogColumn>,
164}
165#[derive(Clone, PartialEq, ::prost::Message)]
166pub struct SqlCatalogFunction {
167 #[prost(string, tag = "1")]
168 pub name: ::prost::alloc::string::String,
169}
170#[derive(Clone, PartialEq, ::prost::Message)]
171pub struct SqlCatalog {
172 #[prost(message, repeated, tag = "1")]
173 pub tables: ::prost::alloc::vec::Vec<SqlCatalogTable>,
174 #[prost(message, repeated, tag = "2")]
175 pub functions: ::prost::alloc::vec::Vec<SqlCatalogFunction>,
176}
177#[derive(Clone, PartialEq, ::prost::Message)]
178pub struct GetSqlCatalogResponse {
179 #[prost(message, optional, tag = "1")]
180 pub sql_catalog: ::core::option::Option<SqlCatalog>,
181}
182#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
183#[repr(i32)]
184pub enum SqlError {
185 Unspecified = 0,
186 InvalidQuery = 1,
187 DatasetsNotFound = 2,
188 ExecutionFailed = 3,
189 ExportNotSupportedForBackend = 4,
190 ExportNotConfigured = 5,
191 QueryTimeout = 6,
192 ResourceExhausted = 7,
193 DatasetStorageTypeNotSupported = 8,
194 DataNotFoundForType = 9,
195}
196impl SqlError {
197 pub fn as_str_name(&self) -> &'static str {
202 match self {
203 Self::Unspecified => "SQL_ERROR_UNSPECIFIED",
204 Self::InvalidQuery => "SQL_ERROR_INVALID_QUERY",
205 Self::DatasetsNotFound => "SQL_ERROR_DATASETS_NOT_FOUND",
206 Self::ExecutionFailed => "SQL_ERROR_EXECUTION_FAILED",
207 Self::ExportNotSupportedForBackend => {
208 "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND"
209 }
210 Self::ExportNotConfigured => "SQL_ERROR_EXPORT_NOT_CONFIGURED",
211 Self::QueryTimeout => "SQL_ERROR_QUERY_TIMEOUT",
212 Self::ResourceExhausted => "SQL_ERROR_RESOURCE_EXHAUSTED",
213 Self::DatasetStorageTypeNotSupported => {
214 "SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED"
215 }
216 Self::DataNotFoundForType => "SQL_ERROR_DATA_NOT_FOUND_FOR_TYPE",
217 }
218 }
219 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
221 match value {
222 "SQL_ERROR_UNSPECIFIED" => Some(Self::Unspecified),
223 "SQL_ERROR_INVALID_QUERY" => Some(Self::InvalidQuery),
224 "SQL_ERROR_DATASETS_NOT_FOUND" => Some(Self::DatasetsNotFound),
225 "SQL_ERROR_EXECUTION_FAILED" => Some(Self::ExecutionFailed),
226 "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND" => {
227 Some(Self::ExportNotSupportedForBackend)
228 }
229 "SQL_ERROR_EXPORT_NOT_CONFIGURED" => Some(Self::ExportNotConfigured),
230 "SQL_ERROR_QUERY_TIMEOUT" => Some(Self::QueryTimeout),
231 "SQL_ERROR_RESOURCE_EXHAUSTED" => Some(Self::ResourceExhausted),
232 "SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED" => {
233 Some(Self::DatasetStorageTypeNotSupported)
234 }
235 "SQL_ERROR_DATA_NOT_FOUND_FOR_TYPE" => Some(Self::DataNotFoundForType),
236 _ => None,
237 }
238 }
239}
240pub mod sql_service_client {
242 #![allow(
243 unused_variables,
244 dead_code,
245 missing_docs,
246 clippy::wildcard_imports,
247 clippy::let_unit_value,
248 )]
249 use tonic::codegen::*;
250 use tonic::codegen::http::Uri;
251 #[derive(Debug, Clone)]
252 pub struct SqlServiceClient<T> {
253 inner: tonic::client::Grpc<T>,
254 }
255 impl SqlServiceClient<tonic::transport::Channel> {
256 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
258 where
259 D: TryInto<tonic::transport::Endpoint>,
260 D::Error: Into<StdError>,
261 {
262 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
263 Ok(Self::new(conn))
264 }
265 }
266 impl<T> SqlServiceClient<T>
267 where
268 T: tonic::client::GrpcService<tonic::body::Body>,
269 T::Error: Into<StdError>,
270 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
271 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
272 {
273 pub fn new(inner: T) -> Self {
274 let inner = tonic::client::Grpc::new(inner);
275 Self { inner }
276 }
277 pub fn with_origin(inner: T, origin: Uri) -> Self {
278 let inner = tonic::client::Grpc::with_origin(inner, origin);
279 Self { inner }
280 }
281 pub fn with_interceptor<F>(
282 inner: T,
283 interceptor: F,
284 ) -> SqlServiceClient<InterceptedService<T, F>>
285 where
286 F: tonic::service::Interceptor,
287 T::ResponseBody: Default,
288 T: tonic::codegen::Service<
289 http::Request<tonic::body::Body>,
290 Response = http::Response<
291 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
292 >,
293 >,
294 <T as tonic::codegen::Service<
295 http::Request<tonic::body::Body>,
296 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
297 {
298 SqlServiceClient::new(InterceptedService::new(inner, interceptor))
299 }
300 #[must_use]
305 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
306 self.inner = self.inner.send_compressed(encoding);
307 self
308 }
309 #[must_use]
311 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
312 self.inner = self.inner.accept_compressed(encoding);
313 self
314 }
315 #[must_use]
319 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
320 self.inner = self.inner.max_decoding_message_size(limit);
321 self
322 }
323 #[must_use]
327 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
328 self.inner = self.inner.max_encoding_message_size(limit);
329 self
330 }
331 pub async fn query(
332 &mut self,
333 request: impl tonic::IntoRequest<super::SqlServiceQueryRequest>,
334 ) -> std::result::Result<
335 tonic::Response<tonic::codec::Streaming<super::SqlServiceQueryResponse>>,
336 tonic::Status,
337 > {
338 self.inner
339 .ready()
340 .await
341 .map_err(|e| {
342 tonic::Status::unknown(
343 format!("Service was not ready: {}", e.into()),
344 )
345 })?;
346 let codec = tonic::codec::ProstCodec::default();
347 let path = http::uri::PathAndQuery::from_static(
348 "/nominal.sql.v1.SqlService/Query",
349 );
350 let mut req = request.into_request();
351 req.extensions_mut()
352 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Query"));
353 self.inner.server_streaming(req, path, codec).await
354 }
355 pub async fn export(
356 &mut self,
357 request: impl tonic::IntoRequest<super::SqlServiceExportRequest>,
358 ) -> std::result::Result<
359 tonic::Response<super::SqlServiceExportResponse>,
360 tonic::Status,
361 > {
362 self.inner
363 .ready()
364 .await
365 .map_err(|e| {
366 tonic::Status::unknown(
367 format!("Service was not ready: {}", e.into()),
368 )
369 })?;
370 let codec = tonic::codec::ProstCodec::default();
371 let path = http::uri::PathAndQuery::from_static(
372 "/nominal.sql.v1.SqlService/Export",
373 );
374 let mut req = request.into_request();
375 req.extensions_mut()
376 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Export"));
377 self.inner.unary(req, path, codec).await
378 }
379 pub async fn get_sql_catalog(
380 &mut self,
381 request: impl tonic::IntoRequest<super::GetSqlCatalogRequest>,
382 ) -> std::result::Result<
383 tonic::Response<super::GetSqlCatalogResponse>,
384 tonic::Status,
385 > {
386 self.inner
387 .ready()
388 .await
389 .map_err(|e| {
390 tonic::Status::unknown(
391 format!("Service was not ready: {}", e.into()),
392 )
393 })?;
394 let codec = tonic::codec::ProstCodec::default();
395 let path = http::uri::PathAndQuery::from_static(
396 "/nominal.sql.v1.SqlService/GetSqlCatalog",
397 );
398 let mut req = request.into_request();
399 req.extensions_mut()
400 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "GetSqlCatalog"));
401 self.inner.unary(req, path, codec).await
402 }
403 }
404}