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 #[prost(string, tag = "12")]
33 pub org_rid: ::prost::alloc::string::String,
34}
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
36#[repr(i32)]
37pub enum SqlQueryEventType {
38 QueryStart = 0,
39 QueryFinish = 1,
40}
41impl SqlQueryEventType {
42 pub fn as_str_name(&self) -> &'static str {
47 match self {
48 Self::QueryStart => "SQL_QUERY_EVENT_TYPE_QUERY_START",
49 Self::QueryFinish => "SQL_QUERY_EVENT_TYPE_QUERY_FINISH",
50 }
51 }
52 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
54 match value {
55 "SQL_QUERY_EVENT_TYPE_QUERY_START" => Some(Self::QueryStart),
56 "SQL_QUERY_EVENT_TYPE_QUERY_FINISH" => Some(Self::QueryFinish),
57 _ => None,
58 }
59 }
60}
61#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
62#[repr(i32)]
63pub enum SqlQueryBackend {
64 Clickhouse = 0,
65 Postgres = 1,
66}
67impl SqlQueryBackend {
68 pub fn as_str_name(&self) -> &'static str {
73 match self {
74 Self::Clickhouse => "SQL_QUERY_BACKEND_CLICKHOUSE",
75 Self::Postgres => "SQL_QUERY_BACKEND_POSTGRES",
76 }
77 }
78 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
80 match value {
81 "SQL_QUERY_BACKEND_CLICKHOUSE" => Some(Self::Clickhouse),
82 "SQL_QUERY_BACKEND_POSTGRES" => Some(Self::Postgres),
83 _ => None,
84 }
85 }
86}
87#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
88#[repr(i32)]
89pub enum SqlQueryStatus {
90 Succeeded = 0,
91 Failed = 1,
92 Throttled = 2,
93 TimedOut = 3,
94}
95impl SqlQueryStatus {
96 pub fn as_str_name(&self) -> &'static str {
101 match self {
102 Self::Succeeded => "SQL_QUERY_STATUS_SUCCEEDED",
103 Self::Failed => "SQL_QUERY_STATUS_FAILED",
104 Self::Throttled => "SQL_QUERY_STATUS_THROTTLED",
105 Self::TimedOut => "SQL_QUERY_STATUS_TIMED_OUT",
106 }
107 }
108 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
110 match value {
111 "SQL_QUERY_STATUS_SUCCEEDED" => Some(Self::Succeeded),
112 "SQL_QUERY_STATUS_FAILED" => Some(Self::Failed),
113 "SQL_QUERY_STATUS_THROTTLED" => Some(Self::Throttled),
114 "SQL_QUERY_STATUS_TIMED_OUT" => Some(Self::TimedOut),
115 _ => None,
116 }
117 }
118}
119#[derive(Clone, PartialEq, ::prost::Message)]
120pub struct SqlServiceQueryRequest {
121 #[prost(string, tag = "1")]
122 pub query: ::prost::alloc::string::String,
123 #[prost(int32, optional, tag = "2")]
124 pub max_rows: ::core::option::Option<i32>,
125 #[prost(string, tag = "3")]
126 pub workspace_rid: ::prost::alloc::string::String,
127 #[prost(enumeration = "SqlServiceQueryResultFormat", tag = "4")]
128 pub result_format: i32,
129}
130#[derive(Clone, PartialEq, ::prost::Message)]
131pub struct SqlServiceQueryResponse {
132 #[deprecated]
133 #[prost(bytes = "vec", tag = "1")]
134 pub arrow_payload: ::prost::alloc::vec::Vec<u8>,
135 #[prost(string, tag = "2")]
136 pub query_id: ::prost::alloc::string::String,
137 #[prost(bytes = "vec", tag = "3")]
138 pub payload: ::prost::alloc::vec::Vec<u8>,
139}
140#[derive(Clone, PartialEq, ::prost::Message)]
141pub struct SqlServiceExportRequest {
142 #[prost(string, tag = "1")]
143 pub query: ::prost::alloc::string::String,
144 #[prost(string, tag = "2")]
145 pub workspace_rid: ::prost::alloc::string::String,
146}
147#[derive(Clone, PartialEq, ::prost::Message)]
148pub struct SqlServiceExportResponse {
149 #[prost(string, tag = "1")]
150 pub presigned_url: ::prost::alloc::string::String,
151 #[prost(string, tag = "2")]
152 pub query_id: ::prost::alloc::string::String,
153}
154#[derive(Clone, Copy, PartialEq, ::prost::Message)]
155pub struct GetSqlCatalogRequest {}
156#[derive(Clone, PartialEq, ::prost::Message)]
157pub struct SqlCatalogColumn {
158 #[prost(string, tag = "1")]
159 pub name: ::prost::alloc::string::String,
160 #[prost(string, tag = "2")]
161 pub r#type: ::prost::alloc::string::String,
162 #[prost(bool, tag = "3")]
163 pub nullable: bool,
164}
165#[derive(Clone, PartialEq, ::prost::Message)]
166pub struct SqlCatalogTable {
167 #[prost(string, tag = "1")]
168 pub name: ::prost::alloc::string::String,
169 #[prost(message, repeated, tag = "2")]
170 pub columns: ::prost::alloc::vec::Vec<SqlCatalogColumn>,
171}
172#[derive(Clone, PartialEq, ::prost::Message)]
173pub struct SqlCatalogFunction {
174 #[prost(string, tag = "1")]
175 pub name: ::prost::alloc::string::String,
176}
177#[derive(Clone, PartialEq, ::prost::Message)]
178pub struct SqlCatalog {
179 #[prost(message, repeated, tag = "1")]
180 pub tables: ::prost::alloc::vec::Vec<SqlCatalogTable>,
181 #[prost(message, repeated, tag = "2")]
182 pub functions: ::prost::alloc::vec::Vec<SqlCatalogFunction>,
183}
184#[derive(Clone, PartialEq, ::prost::Message)]
185pub struct GetSqlCatalogResponse {
186 #[prost(message, optional, tag = "1")]
187 pub sql_catalog: ::core::option::Option<SqlCatalog>,
188}
189#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
190#[repr(i32)]
191pub enum SqlError {
192 Unspecified = 0,
193 InvalidQuery = 1,
194 DatasetsNotFound = 2,
195 ExecutionFailed = 3,
196 ExportNotSupportedForBackend = 4,
197 ExportNotConfigured = 5,
198 QueryTimeout = 6,
199 ResourceExhausted = 7,
200 DatasetStorageTypeNotSupported = 8,
201 DataNotFoundForType = 9,
202}
203impl SqlError {
204 pub fn as_str_name(&self) -> &'static str {
209 match self {
210 Self::Unspecified => "SQL_ERROR_UNSPECIFIED",
211 Self::InvalidQuery => "SQL_ERROR_INVALID_QUERY",
212 Self::DatasetsNotFound => "SQL_ERROR_DATASETS_NOT_FOUND",
213 Self::ExecutionFailed => "SQL_ERROR_EXECUTION_FAILED",
214 Self::ExportNotSupportedForBackend => {
215 "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND"
216 }
217 Self::ExportNotConfigured => "SQL_ERROR_EXPORT_NOT_CONFIGURED",
218 Self::QueryTimeout => "SQL_ERROR_QUERY_TIMEOUT",
219 Self::ResourceExhausted => "SQL_ERROR_RESOURCE_EXHAUSTED",
220 Self::DatasetStorageTypeNotSupported => {
221 "SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED"
222 }
223 Self::DataNotFoundForType => "SQL_ERROR_DATA_NOT_FOUND_FOR_TYPE",
224 }
225 }
226 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
228 match value {
229 "SQL_ERROR_UNSPECIFIED" => Some(Self::Unspecified),
230 "SQL_ERROR_INVALID_QUERY" => Some(Self::InvalidQuery),
231 "SQL_ERROR_DATASETS_NOT_FOUND" => Some(Self::DatasetsNotFound),
232 "SQL_ERROR_EXECUTION_FAILED" => Some(Self::ExecutionFailed),
233 "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND" => {
234 Some(Self::ExportNotSupportedForBackend)
235 }
236 "SQL_ERROR_EXPORT_NOT_CONFIGURED" => Some(Self::ExportNotConfigured),
237 "SQL_ERROR_QUERY_TIMEOUT" => Some(Self::QueryTimeout),
238 "SQL_ERROR_RESOURCE_EXHAUSTED" => Some(Self::ResourceExhausted),
239 "SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED" => {
240 Some(Self::DatasetStorageTypeNotSupported)
241 }
242 "SQL_ERROR_DATA_NOT_FOUND_FOR_TYPE" => Some(Self::DataNotFoundForType),
243 _ => None,
244 }
245 }
246}
247#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
248#[repr(i32)]
249pub enum SqlServiceQueryResultFormat {
250 Unspecified = 0,
251 ArrowStream = 1,
252 JsonLines = 2,
253 Csv = 3,
254}
255impl SqlServiceQueryResultFormat {
256 pub fn as_str_name(&self) -> &'static str {
261 match self {
262 Self::Unspecified => "SQL_SERVICE_QUERY_RESULT_FORMAT_UNSPECIFIED",
263 Self::ArrowStream => "SQL_SERVICE_QUERY_RESULT_FORMAT_ARROW_STREAM",
264 Self::JsonLines => "SQL_SERVICE_QUERY_RESULT_FORMAT_JSON_LINES",
265 Self::Csv => "SQL_SERVICE_QUERY_RESULT_FORMAT_CSV",
266 }
267 }
268 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
270 match value {
271 "SQL_SERVICE_QUERY_RESULT_FORMAT_UNSPECIFIED" => Some(Self::Unspecified),
272 "SQL_SERVICE_QUERY_RESULT_FORMAT_ARROW_STREAM" => Some(Self::ArrowStream),
273 "SQL_SERVICE_QUERY_RESULT_FORMAT_JSON_LINES" => Some(Self::JsonLines),
274 "SQL_SERVICE_QUERY_RESULT_FORMAT_CSV" => Some(Self::Csv),
275 _ => None,
276 }
277 }
278}
279pub mod sql_service_client {
281 #![allow(
282 unused_variables,
283 dead_code,
284 missing_docs,
285 clippy::wildcard_imports,
286 clippy::let_unit_value,
287 )]
288 use tonic::codegen::*;
289 use tonic::codegen::http::Uri;
290 #[derive(Debug, Clone)]
291 pub struct SqlServiceClient<T> {
292 inner: tonic::client::Grpc<T>,
293 }
294 impl SqlServiceClient<tonic::transport::Channel> {
295 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
297 where
298 D: TryInto<tonic::transport::Endpoint>,
299 D::Error: Into<StdError>,
300 {
301 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
302 Ok(Self::new(conn))
303 }
304 }
305 impl<T> SqlServiceClient<T>
306 where
307 T: tonic::client::GrpcService<tonic::body::Body>,
308 T::Error: Into<StdError>,
309 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
310 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
311 {
312 pub fn new(inner: T) -> Self {
313 let inner = tonic::client::Grpc::new(inner);
314 Self { inner }
315 }
316 pub fn with_origin(inner: T, origin: Uri) -> Self {
317 let inner = tonic::client::Grpc::with_origin(inner, origin);
318 Self { inner }
319 }
320 pub fn with_interceptor<F>(
321 inner: T,
322 interceptor: F,
323 ) -> SqlServiceClient<InterceptedService<T, F>>
324 where
325 F: tonic::service::Interceptor,
326 T::ResponseBody: Default,
327 T: tonic::codegen::Service<
328 http::Request<tonic::body::Body>,
329 Response = http::Response<
330 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
331 >,
332 >,
333 <T as tonic::codegen::Service<
334 http::Request<tonic::body::Body>,
335 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
336 {
337 SqlServiceClient::new(InterceptedService::new(inner, interceptor))
338 }
339 #[must_use]
344 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
345 self.inner = self.inner.send_compressed(encoding);
346 self
347 }
348 #[must_use]
350 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
351 self.inner = self.inner.accept_compressed(encoding);
352 self
353 }
354 #[must_use]
358 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
359 self.inner = self.inner.max_decoding_message_size(limit);
360 self
361 }
362 #[must_use]
366 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
367 self.inner = self.inner.max_encoding_message_size(limit);
368 self
369 }
370 pub async fn query(
371 &mut self,
372 request: impl tonic::IntoRequest<super::SqlServiceQueryRequest>,
373 ) -> std::result::Result<
374 tonic::Response<tonic::codec::Streaming<super::SqlServiceQueryResponse>>,
375 tonic::Status,
376 > {
377 self.inner
378 .ready()
379 .await
380 .map_err(|e| {
381 tonic::Status::unknown(
382 format!("Service was not ready: {}", e.into()),
383 )
384 })?;
385 let codec = tonic::codec::ProstCodec::default();
386 let path = http::uri::PathAndQuery::from_static(
387 "/nominal.sql.v1.SqlService/Query",
388 );
389 let mut req = request.into_request();
390 req.extensions_mut()
391 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Query"));
392 self.inner.server_streaming(req, path, codec).await
393 }
394 pub async fn export(
395 &mut self,
396 request: impl tonic::IntoRequest<super::SqlServiceExportRequest>,
397 ) -> std::result::Result<
398 tonic::Response<super::SqlServiceExportResponse>,
399 tonic::Status,
400 > {
401 self.inner
402 .ready()
403 .await
404 .map_err(|e| {
405 tonic::Status::unknown(
406 format!("Service was not ready: {}", e.into()),
407 )
408 })?;
409 let codec = tonic::codec::ProstCodec::default();
410 let path = http::uri::PathAndQuery::from_static(
411 "/nominal.sql.v1.SqlService/Export",
412 );
413 let mut req = request.into_request();
414 req.extensions_mut()
415 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Export"));
416 self.inner.unary(req, path, codec).await
417 }
418 pub async fn get_sql_catalog(
419 &mut self,
420 request: impl tonic::IntoRequest<super::GetSqlCatalogRequest>,
421 ) -> std::result::Result<
422 tonic::Response<super::GetSqlCatalogResponse>,
423 tonic::Status,
424 > {
425 self.inner
426 .ready()
427 .await
428 .map_err(|e| {
429 tonic::Status::unknown(
430 format!("Service was not ready: {}", e.into()),
431 )
432 })?;
433 let codec = tonic::codec::ProstCodec::default();
434 let path = http::uri::PathAndQuery::from_static(
435 "/nominal.sql.v1.SqlService/GetSqlCatalog",
436 );
437 let mut req = request.into_request();
438 req.extensions_mut()
439 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "GetSqlCatalog"));
440 self.inner.unary(req, path, codec).await
441 }
442 }
443}