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 #[prost(enumeration = "SqlServiceQueryResultFormat", tag = "4")]
11 pub result_format: i32,
12}
13#[derive(Clone, PartialEq, ::prost::Message)]
14pub struct SqlServiceQueryResponse {
15 #[prost(string, tag = "2")]
16 pub query_id: ::prost::alloc::string::String,
17 #[prost(bytes = "vec", tag = "3")]
18 pub payload: ::prost::alloc::vec::Vec<u8>,
19}
20#[derive(Clone, Copy, PartialEq, ::prost::Message)]
21pub struct SqlServiceParquetOptions {
22 #[prost(uint64, optional, tag = "1")]
23 pub row_group_rows: ::core::option::Option<u64>,
24 #[prost(enumeration = "SqlServiceParquetCompression", tag = "2")]
25 pub compression: i32,
26}
27#[derive(Clone, PartialEq, ::prost::Message)]
28pub struct SqlServiceExportRequest {
29 #[prost(string, tag = "1")]
30 pub query: ::prost::alloc::string::String,
31 #[prost(string, tag = "2")]
32 pub workspace_rid: ::prost::alloc::string::String,
33 #[prost(enumeration = "SqlServiceExportFormat", tag = "3")]
34 pub format: i32,
35 #[prost(message, optional, tag = "4")]
36 pub parquet_options: ::core::option::Option<SqlServiceParquetOptions>,
37}
38#[derive(Clone, PartialEq, ::prost::Message)]
39pub struct SqlServiceExportResponse {
40 #[prost(string, tag = "1")]
41 pub presigned_url: ::prost::alloc::string::String,
42 #[prost(string, tag = "2")]
43 pub query_id: ::prost::alloc::string::String,
44}
45#[derive(Clone, Copy, PartialEq, ::prost::Message)]
46pub struct GetSqlCatalogRequest {}
47#[derive(Clone, PartialEq, ::prost::Message)]
48pub struct SqlCatalogMapType {
49 #[prost(message, optional, boxed, tag = "1")]
50 pub key: ::core::option::Option<::prost::alloc::boxed::Box<SqlCatalogDataType>>,
51 #[prost(message, optional, boxed, tag = "2")]
52 pub value: ::core::option::Option<::prost::alloc::boxed::Box<SqlCatalogDataType>>,
53}
54#[derive(Clone, PartialEq, ::prost::Message)]
55pub struct SqlCatalogDataType {
56 #[prost(oneof = "sql_catalog_data_type::Kind", tags = "1, 2, 3")]
57 pub kind: ::core::option::Option<sql_catalog_data_type::Kind>,
58}
59pub mod sql_catalog_data_type {
61 #[derive(Clone, PartialEq, ::prost::Oneof)]
62 pub enum Kind {
63 #[prost(enumeration = "super::SqlCatalogScalarType", tag = "1")]
64 Scalar(i32),
65 #[prost(message, tag = "2")]
66 ArrayElement(::prost::alloc::boxed::Box<super::SqlCatalogDataType>),
67 #[prost(message, tag = "3")]
68 Map(::prost::alloc::boxed::Box<super::SqlCatalogMapType>),
69 }
70}
71#[derive(Clone, PartialEq, ::prost::Message)]
72pub struct SqlCatalogColumn {
73 #[prost(string, tag = "1")]
74 pub name: ::prost::alloc::string::String,
75 #[prost(string, tag = "2")]
76 pub r#type: ::prost::alloc::string::String,
77 #[prost(bool, tag = "3")]
78 pub nullable: bool,
79 #[prost(message, optional, tag = "4")]
80 pub data_type: ::core::option::Option<SqlCatalogDataType>,
81}
82#[derive(Clone, PartialEq, ::prost::Message)]
83pub struct SqlCatalogTable {
84 #[prost(string, tag = "1")]
85 pub name: ::prost::alloc::string::String,
86 #[prost(message, repeated, tag = "2")]
87 pub columns: ::prost::alloc::vec::Vec<SqlCatalogColumn>,
88}
89#[derive(Clone, PartialEq, ::prost::Message)]
90pub struct SqlCatalogFunction {
91 #[prost(string, tag = "1")]
92 pub name: ::prost::alloc::string::String,
93 #[prost(enumeration = "SqlCatalogFunctionKind", tag = "2")]
94 pub kind: i32,
95 #[prost(bool, tag = "3")]
96 pub supports_over: bool,
97 #[prost(int32, tag = "4")]
98 pub min_args: i32,
99 #[prost(int32, optional, tag = "5")]
100 pub max_args: ::core::option::Option<i32>,
101 #[prost(string, repeated, tag = "6")]
102 pub argument_type_families: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
103 #[prost(string, optional, tag = "7")]
104 pub return_type_family: ::core::option::Option<::prost::alloc::string::String>,
105}
106#[derive(Clone, PartialEq, ::prost::Message)]
107pub struct SqlCatalog {
108 #[prost(message, repeated, tag = "1")]
109 pub tables: ::prost::alloc::vec::Vec<SqlCatalogTable>,
110 #[prost(message, repeated, tag = "2")]
111 pub functions: ::prost::alloc::vec::Vec<SqlCatalogFunction>,
112}
113#[derive(Clone, PartialEq, ::prost::Message)]
114pub struct GetSqlCatalogResponse {
115 #[prost(message, optional, tag = "1")]
116 pub sql_catalog: ::core::option::Option<SqlCatalog>,
117}
118#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
119#[repr(i32)]
120pub enum SqlError {
121 Unspecified = 0,
122 InvalidQuery = 1,
123 DatasetsNotFound = 2,
124 ExecutionFailed = 3,
125 ExportNotSupportedForBackend = 4,
126 ExportNotConfigured = 5,
127 QueryTimeout = 6,
128 ResourceExhausted = 7,
129 DatasetStorageTypeNotSupported = 8,
130 DataNotFoundForType = 9,
131 ResultSizeExceeded = 10,
132 QueryScopeTooLarge = 11,
133 QueryCancelled = 12,
134 Unauthenticated = 14,
135 PermissionDenied = 15,
136}
137impl SqlError {
138 pub fn as_str_name(&self) -> &'static str {
143 match self {
144 Self::Unspecified => "SQL_ERROR_UNSPECIFIED",
145 Self::InvalidQuery => "SQL_ERROR_INVALID_QUERY",
146 Self::DatasetsNotFound => "SQL_ERROR_DATASETS_NOT_FOUND",
147 Self::ExecutionFailed => "SQL_ERROR_EXECUTION_FAILED",
148 Self::ExportNotSupportedForBackend => {
149 "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND"
150 }
151 Self::ExportNotConfigured => "SQL_ERROR_EXPORT_NOT_CONFIGURED",
152 Self::QueryTimeout => "SQL_ERROR_QUERY_TIMEOUT",
153 Self::ResourceExhausted => "SQL_ERROR_RESOURCE_EXHAUSTED",
154 Self::DatasetStorageTypeNotSupported => {
155 "SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED"
156 }
157 Self::DataNotFoundForType => "SQL_ERROR_DATA_NOT_FOUND_FOR_TYPE",
158 Self::ResultSizeExceeded => "SQL_ERROR_RESULT_SIZE_EXCEEDED",
159 Self::QueryScopeTooLarge => "SQL_ERROR_QUERY_SCOPE_TOO_LARGE",
160 Self::QueryCancelled => "SQL_ERROR_QUERY_CANCELLED",
161 Self::Unauthenticated => "SQL_ERROR_UNAUTHENTICATED",
162 Self::PermissionDenied => "SQL_ERROR_PERMISSION_DENIED",
163 }
164 }
165 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
167 match value {
168 "SQL_ERROR_UNSPECIFIED" => Some(Self::Unspecified),
169 "SQL_ERROR_INVALID_QUERY" => Some(Self::InvalidQuery),
170 "SQL_ERROR_DATASETS_NOT_FOUND" => Some(Self::DatasetsNotFound),
171 "SQL_ERROR_EXECUTION_FAILED" => Some(Self::ExecutionFailed),
172 "SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND" => {
173 Some(Self::ExportNotSupportedForBackend)
174 }
175 "SQL_ERROR_EXPORT_NOT_CONFIGURED" => Some(Self::ExportNotConfigured),
176 "SQL_ERROR_QUERY_TIMEOUT" => Some(Self::QueryTimeout),
177 "SQL_ERROR_RESOURCE_EXHAUSTED" => Some(Self::ResourceExhausted),
178 "SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED" => {
179 Some(Self::DatasetStorageTypeNotSupported)
180 }
181 "SQL_ERROR_DATA_NOT_FOUND_FOR_TYPE" => Some(Self::DataNotFoundForType),
182 "SQL_ERROR_RESULT_SIZE_EXCEEDED" => Some(Self::ResultSizeExceeded),
183 "SQL_ERROR_QUERY_SCOPE_TOO_LARGE" => Some(Self::QueryScopeTooLarge),
184 "SQL_ERROR_QUERY_CANCELLED" => Some(Self::QueryCancelled),
185 "SQL_ERROR_UNAUTHENTICATED" => Some(Self::Unauthenticated),
186 "SQL_ERROR_PERMISSION_DENIED" => Some(Self::PermissionDenied),
187 _ => None,
188 }
189 }
190}
191#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
192#[repr(i32)]
193pub enum SqlServiceQueryResultFormat {
194 Unspecified = 0,
195 ArrowStream = 1,
196 JsonLines = 2,
197 Csv = 3,
198}
199impl SqlServiceQueryResultFormat {
200 pub fn as_str_name(&self) -> &'static str {
205 match self {
206 Self::Unspecified => "SQL_SERVICE_QUERY_RESULT_FORMAT_UNSPECIFIED",
207 Self::ArrowStream => "SQL_SERVICE_QUERY_RESULT_FORMAT_ARROW_STREAM",
208 Self::JsonLines => "SQL_SERVICE_QUERY_RESULT_FORMAT_JSON_LINES",
209 Self::Csv => "SQL_SERVICE_QUERY_RESULT_FORMAT_CSV",
210 }
211 }
212 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
214 match value {
215 "SQL_SERVICE_QUERY_RESULT_FORMAT_UNSPECIFIED" => Some(Self::Unspecified),
216 "SQL_SERVICE_QUERY_RESULT_FORMAT_ARROW_STREAM" => Some(Self::ArrowStream),
217 "SQL_SERVICE_QUERY_RESULT_FORMAT_JSON_LINES" => Some(Self::JsonLines),
218 "SQL_SERVICE_QUERY_RESULT_FORMAT_CSV" => Some(Self::Csv),
219 _ => None,
220 }
221 }
222}
223#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
224#[repr(i32)]
225pub enum SqlServiceExportFormat {
226 Unspecified = 0,
227 Csv = 1,
228 Parquet = 2,
229}
230impl SqlServiceExportFormat {
231 pub fn as_str_name(&self) -> &'static str {
236 match self {
237 Self::Unspecified => "SQL_SERVICE_EXPORT_FORMAT_UNSPECIFIED",
238 Self::Csv => "SQL_SERVICE_EXPORT_FORMAT_CSV",
239 Self::Parquet => "SQL_SERVICE_EXPORT_FORMAT_PARQUET",
240 }
241 }
242 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
244 match value {
245 "SQL_SERVICE_EXPORT_FORMAT_UNSPECIFIED" => Some(Self::Unspecified),
246 "SQL_SERVICE_EXPORT_FORMAT_CSV" => Some(Self::Csv),
247 "SQL_SERVICE_EXPORT_FORMAT_PARQUET" => Some(Self::Parquet),
248 _ => None,
249 }
250 }
251}
252#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
253#[repr(i32)]
254pub enum SqlServiceParquetCompression {
255 Unspecified = 0,
256 Zstd = 1,
257 Lz4 = 2,
258 Snappy = 3,
259 None = 4,
260}
261impl SqlServiceParquetCompression {
262 pub fn as_str_name(&self) -> &'static str {
267 match self {
268 Self::Unspecified => "SQL_SERVICE_PARQUET_COMPRESSION_UNSPECIFIED",
269 Self::Zstd => "SQL_SERVICE_PARQUET_COMPRESSION_ZSTD",
270 Self::Lz4 => "SQL_SERVICE_PARQUET_COMPRESSION_LZ4",
271 Self::Snappy => "SQL_SERVICE_PARQUET_COMPRESSION_SNAPPY",
272 Self::None => "SQL_SERVICE_PARQUET_COMPRESSION_NONE",
273 }
274 }
275 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
277 match value {
278 "SQL_SERVICE_PARQUET_COMPRESSION_UNSPECIFIED" => Some(Self::Unspecified),
279 "SQL_SERVICE_PARQUET_COMPRESSION_ZSTD" => Some(Self::Zstd),
280 "SQL_SERVICE_PARQUET_COMPRESSION_LZ4" => Some(Self::Lz4),
281 "SQL_SERVICE_PARQUET_COMPRESSION_SNAPPY" => Some(Self::Snappy),
282 "SQL_SERVICE_PARQUET_COMPRESSION_NONE" => Some(Self::None),
283 _ => None,
284 }
285 }
286}
287#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
288#[repr(i32)]
289pub enum SqlCatalogScalarType {
290 Unspecified = 0,
291 Varchar = 1,
292 Boolean = 2,
293 Integer = 3,
294 Bigint = 4,
295 Double = 5,
296 Timestamp = 6,
297 Any = 7,
298}
299impl SqlCatalogScalarType {
300 pub fn as_str_name(&self) -> &'static str {
305 match self {
306 Self::Unspecified => "SQL_CATALOG_SCALAR_TYPE_UNSPECIFIED",
307 Self::Varchar => "SQL_CATALOG_SCALAR_TYPE_VARCHAR",
308 Self::Boolean => "SQL_CATALOG_SCALAR_TYPE_BOOLEAN",
309 Self::Integer => "SQL_CATALOG_SCALAR_TYPE_INTEGER",
310 Self::Bigint => "SQL_CATALOG_SCALAR_TYPE_BIGINT",
311 Self::Double => "SQL_CATALOG_SCALAR_TYPE_DOUBLE",
312 Self::Timestamp => "SQL_CATALOG_SCALAR_TYPE_TIMESTAMP",
313 Self::Any => "SQL_CATALOG_SCALAR_TYPE_ANY",
314 }
315 }
316 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
318 match value {
319 "SQL_CATALOG_SCALAR_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
320 "SQL_CATALOG_SCALAR_TYPE_VARCHAR" => Some(Self::Varchar),
321 "SQL_CATALOG_SCALAR_TYPE_BOOLEAN" => Some(Self::Boolean),
322 "SQL_CATALOG_SCALAR_TYPE_INTEGER" => Some(Self::Integer),
323 "SQL_CATALOG_SCALAR_TYPE_BIGINT" => Some(Self::Bigint),
324 "SQL_CATALOG_SCALAR_TYPE_DOUBLE" => Some(Self::Double),
325 "SQL_CATALOG_SCALAR_TYPE_TIMESTAMP" => Some(Self::Timestamp),
326 "SQL_CATALOG_SCALAR_TYPE_ANY" => Some(Self::Any),
327 _ => None,
328 }
329 }
330}
331#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
332#[repr(i32)]
333pub enum SqlCatalogFunctionKind {
334 Unspecified = 0,
335 Scalar = 1,
336 Aggregate = 2,
337 Window = 3,
338 Table = 4,
339}
340impl SqlCatalogFunctionKind {
341 pub fn as_str_name(&self) -> &'static str {
346 match self {
347 Self::Unspecified => "SQL_CATALOG_FUNCTION_KIND_UNSPECIFIED",
348 Self::Scalar => "SQL_CATALOG_FUNCTION_KIND_SCALAR",
349 Self::Aggregate => "SQL_CATALOG_FUNCTION_KIND_AGGREGATE",
350 Self::Window => "SQL_CATALOG_FUNCTION_KIND_WINDOW",
351 Self::Table => "SQL_CATALOG_FUNCTION_KIND_TABLE",
352 }
353 }
354 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
356 match value {
357 "SQL_CATALOG_FUNCTION_KIND_UNSPECIFIED" => Some(Self::Unspecified),
358 "SQL_CATALOG_FUNCTION_KIND_SCALAR" => Some(Self::Scalar),
359 "SQL_CATALOG_FUNCTION_KIND_AGGREGATE" => Some(Self::Aggregate),
360 "SQL_CATALOG_FUNCTION_KIND_WINDOW" => Some(Self::Window),
361 "SQL_CATALOG_FUNCTION_KIND_TABLE" => Some(Self::Table),
362 _ => None,
363 }
364 }
365}
366pub mod sql_service_client {
368 #![allow(
369 unused_variables,
370 dead_code,
371 missing_docs,
372 clippy::wildcard_imports,
373 clippy::let_unit_value,
374 )]
375 use tonic::codegen::*;
376 use tonic::codegen::http::Uri;
377 #[derive(Debug, Clone)]
378 pub struct SqlServiceClient<T> {
379 inner: tonic::client::Grpc<T>,
380 }
381 impl SqlServiceClient<tonic::transport::Channel> {
382 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
384 where
385 D: TryInto<tonic::transport::Endpoint>,
386 D::Error: Into<StdError>,
387 {
388 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
389 Ok(Self::new(conn))
390 }
391 }
392 impl<T> SqlServiceClient<T>
393 where
394 T: tonic::client::GrpcService<tonic::body::Body>,
395 T::Error: Into<StdError>,
396 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
397 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
398 {
399 pub fn new(inner: T) -> Self {
400 let inner = tonic::client::Grpc::new(inner);
401 Self { inner }
402 }
403 pub fn with_origin(inner: T, origin: Uri) -> Self {
404 let inner = tonic::client::Grpc::with_origin(inner, origin);
405 Self { inner }
406 }
407 pub fn with_interceptor<F>(
408 inner: T,
409 interceptor: F,
410 ) -> SqlServiceClient<InterceptedService<T, F>>
411 where
412 F: tonic::service::Interceptor,
413 T::ResponseBody: Default,
414 T: tonic::codegen::Service<
415 http::Request<tonic::body::Body>,
416 Response = http::Response<
417 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
418 >,
419 >,
420 <T as tonic::codegen::Service<
421 http::Request<tonic::body::Body>,
422 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
423 {
424 SqlServiceClient::new(InterceptedService::new(inner, interceptor))
425 }
426 #[must_use]
431 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
432 self.inner = self.inner.send_compressed(encoding);
433 self
434 }
435 #[must_use]
437 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
438 self.inner = self.inner.accept_compressed(encoding);
439 self
440 }
441 #[must_use]
445 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
446 self.inner = self.inner.max_decoding_message_size(limit);
447 self
448 }
449 #[must_use]
453 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
454 self.inner = self.inner.max_encoding_message_size(limit);
455 self
456 }
457 pub async fn query(
458 &mut self,
459 request: impl tonic::IntoRequest<super::SqlServiceQueryRequest>,
460 ) -> std::result::Result<
461 tonic::Response<tonic::codec::Streaming<super::SqlServiceQueryResponse>>,
462 tonic::Status,
463 > {
464 self.inner
465 .ready()
466 .await
467 .map_err(|e| {
468 tonic::Status::unknown(
469 format!("Service was not ready: {}", e.into()),
470 )
471 })?;
472 let codec = tonic::codec::ProstCodec::default();
473 let path = http::uri::PathAndQuery::from_static(
474 "/nominal.sql.v1.SqlService/Query",
475 );
476 let mut req = request.into_request();
477 req.extensions_mut()
478 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Query"));
479 self.inner.server_streaming(req, path, codec).await
480 }
481 pub async fn export(
482 &mut self,
483 request: impl tonic::IntoRequest<super::SqlServiceExportRequest>,
484 ) -> std::result::Result<
485 tonic::Response<super::SqlServiceExportResponse>,
486 tonic::Status,
487 > {
488 self.inner
489 .ready()
490 .await
491 .map_err(|e| {
492 tonic::Status::unknown(
493 format!("Service was not ready: {}", e.into()),
494 )
495 })?;
496 let codec = tonic::codec::ProstCodec::default();
497 let path = http::uri::PathAndQuery::from_static(
498 "/nominal.sql.v1.SqlService/Export",
499 );
500 let mut req = request.into_request();
501 req.extensions_mut()
502 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Export"));
503 self.inner.unary(req, path, codec).await
504 }
505 pub async fn get_sql_catalog(
506 &mut self,
507 request: impl tonic::IntoRequest<super::GetSqlCatalogRequest>,
508 ) -> std::result::Result<
509 tonic::Response<super::GetSqlCatalogResponse>,
510 tonic::Status,
511 > {
512 self.inner
513 .ready()
514 .await
515 .map_err(|e| {
516 tonic::Status::unknown(
517 format!("Service was not ready: {}", e.into()),
518 )
519 })?;
520 let codec = tonic::codec::ProstCodec::default();
521 let path = http::uri::PathAndQuery::from_static(
522 "/nominal.sql.v1.SqlService/GetSqlCatalog",
523 );
524 let mut req = request.into_request();
525 req.extensions_mut()
526 .insert(GrpcMethod::new("nominal.sql.v1.SqlService", "GetSqlCatalog"));
527 self.inner.unary(req, path, codec).await
528 }
529 }
530}