#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SqlServiceQueryRequest {
#[prost(string, tag = "1")]
pub query: ::prost::alloc::string::String,
#[prost(int32, optional, tag = "2")]
pub max_rows: ::core::option::Option<i32>,
#[prost(string, tag = "3")]
pub workspace_rid: ::prost::alloc::string::String,
#[prost(enumeration = "SqlServiceQueryResultFormat", tag = "4")]
pub result_format: i32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SqlServiceQueryResponse {
#[prost(string, tag = "2")]
pub query_id: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "3")]
pub payload: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SqlServiceExportRequest {
#[prost(string, tag = "1")]
pub query: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub workspace_rid: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SqlServiceExportResponse {
#[prost(string, tag = "1")]
pub presigned_url: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub query_id: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct GetSqlCatalogRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SqlCatalogMapType {
#[prost(message, optional, boxed, tag = "1")]
pub key: ::core::option::Option<::prost::alloc::boxed::Box<SqlCatalogDataType>>,
#[prost(message, optional, boxed, tag = "2")]
pub value: ::core::option::Option<::prost::alloc::boxed::Box<SqlCatalogDataType>>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SqlCatalogDataType {
#[prost(oneof = "sql_catalog_data_type::Kind", tags = "1, 2, 3")]
pub kind: ::core::option::Option<sql_catalog_data_type::Kind>,
}
pub mod sql_catalog_data_type {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Kind {
#[prost(enumeration = "super::SqlCatalogScalarType", tag = "1")]
Scalar(i32),
#[prost(message, tag = "2")]
ArrayElement(::prost::alloc::boxed::Box<super::SqlCatalogDataType>),
#[prost(message, tag = "3")]
Map(::prost::alloc::boxed::Box<super::SqlCatalogMapType>),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SqlCatalogColumn {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub r#type: ::prost::alloc::string::String,
#[prost(bool, tag = "3")]
pub nullable: bool,
#[prost(message, optional, tag = "4")]
pub data_type: ::core::option::Option<SqlCatalogDataType>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SqlCatalogTable {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
pub columns: ::prost::alloc::vec::Vec<SqlCatalogColumn>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SqlCatalogFunction {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(enumeration = "SqlCatalogFunctionKind", tag = "2")]
pub kind: i32,
#[prost(bool, tag = "3")]
pub supports_over: bool,
#[prost(int32, tag = "4")]
pub min_args: i32,
#[prost(int32, optional, tag = "5")]
pub max_args: ::core::option::Option<i32>,
#[prost(string, repeated, tag = "6")]
pub argument_type_families: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, optional, tag = "7")]
pub return_type_family: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SqlCatalog {
#[prost(message, repeated, tag = "1")]
pub tables: ::prost::alloc::vec::Vec<SqlCatalogTable>,
#[prost(message, repeated, tag = "2")]
pub functions: ::prost::alloc::vec::Vec<SqlCatalogFunction>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetSqlCatalogResponse {
#[prost(message, optional, tag = "1")]
pub sql_catalog: ::core::option::Option<SqlCatalog>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SqlError {
Unspecified = 0,
InvalidQuery = 1,
DatasetsNotFound = 2,
ExecutionFailed = 3,
ExportNotSupportedForBackend = 4,
ExportNotConfigured = 5,
QueryTimeout = 6,
ResourceExhausted = 7,
DatasetStorageTypeNotSupported = 8,
DataNotFoundForType = 9,
ResultSizeExceeded = 10,
QueryScopeTooLarge = 11,
QueryCancelled = 12,
Unauthenticated = 14,
PermissionDenied = 15,
}
impl SqlError {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "SQL_ERROR_UNSPECIFIED",
Self::InvalidQuery => "SQL_ERROR_INVALID_QUERY",
Self::DatasetsNotFound => "SQL_ERROR_DATASETS_NOT_FOUND",
Self::ExecutionFailed => "SQL_ERROR_EXECUTION_FAILED",
Self::ExportNotSupportedForBackend => {
"SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND"
}
Self::ExportNotConfigured => "SQL_ERROR_EXPORT_NOT_CONFIGURED",
Self::QueryTimeout => "SQL_ERROR_QUERY_TIMEOUT",
Self::ResourceExhausted => "SQL_ERROR_RESOURCE_EXHAUSTED",
Self::DatasetStorageTypeNotSupported => {
"SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED"
}
Self::DataNotFoundForType => "SQL_ERROR_DATA_NOT_FOUND_FOR_TYPE",
Self::ResultSizeExceeded => "SQL_ERROR_RESULT_SIZE_EXCEEDED",
Self::QueryScopeTooLarge => "SQL_ERROR_QUERY_SCOPE_TOO_LARGE",
Self::QueryCancelled => "SQL_ERROR_QUERY_CANCELLED",
Self::Unauthenticated => "SQL_ERROR_UNAUTHENTICATED",
Self::PermissionDenied => "SQL_ERROR_PERMISSION_DENIED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SQL_ERROR_UNSPECIFIED" => Some(Self::Unspecified),
"SQL_ERROR_INVALID_QUERY" => Some(Self::InvalidQuery),
"SQL_ERROR_DATASETS_NOT_FOUND" => Some(Self::DatasetsNotFound),
"SQL_ERROR_EXECUTION_FAILED" => Some(Self::ExecutionFailed),
"SQL_ERROR_EXPORT_NOT_SUPPORTED_FOR_BACKEND" => {
Some(Self::ExportNotSupportedForBackend)
}
"SQL_ERROR_EXPORT_NOT_CONFIGURED" => Some(Self::ExportNotConfigured),
"SQL_ERROR_QUERY_TIMEOUT" => Some(Self::QueryTimeout),
"SQL_ERROR_RESOURCE_EXHAUSTED" => Some(Self::ResourceExhausted),
"SQL_ERROR_DATASET_STORAGE_TYPE_NOT_SUPPORTED" => {
Some(Self::DatasetStorageTypeNotSupported)
}
"SQL_ERROR_DATA_NOT_FOUND_FOR_TYPE" => Some(Self::DataNotFoundForType),
"SQL_ERROR_RESULT_SIZE_EXCEEDED" => Some(Self::ResultSizeExceeded),
"SQL_ERROR_QUERY_SCOPE_TOO_LARGE" => Some(Self::QueryScopeTooLarge),
"SQL_ERROR_QUERY_CANCELLED" => Some(Self::QueryCancelled),
"SQL_ERROR_UNAUTHENTICATED" => Some(Self::Unauthenticated),
"SQL_ERROR_PERMISSION_DENIED" => Some(Self::PermissionDenied),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SqlServiceQueryResultFormat {
Unspecified = 0,
ArrowStream = 1,
JsonLines = 2,
Csv = 3,
}
impl SqlServiceQueryResultFormat {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "SQL_SERVICE_QUERY_RESULT_FORMAT_UNSPECIFIED",
Self::ArrowStream => "SQL_SERVICE_QUERY_RESULT_FORMAT_ARROW_STREAM",
Self::JsonLines => "SQL_SERVICE_QUERY_RESULT_FORMAT_JSON_LINES",
Self::Csv => "SQL_SERVICE_QUERY_RESULT_FORMAT_CSV",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SQL_SERVICE_QUERY_RESULT_FORMAT_UNSPECIFIED" => Some(Self::Unspecified),
"SQL_SERVICE_QUERY_RESULT_FORMAT_ARROW_STREAM" => Some(Self::ArrowStream),
"SQL_SERVICE_QUERY_RESULT_FORMAT_JSON_LINES" => Some(Self::JsonLines),
"SQL_SERVICE_QUERY_RESULT_FORMAT_CSV" => Some(Self::Csv),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SqlCatalogScalarType {
Unspecified = 0,
Varchar = 1,
Boolean = 2,
Integer = 3,
Bigint = 4,
Double = 5,
Timestamp = 6,
Any = 7,
}
impl SqlCatalogScalarType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "SQL_CATALOG_SCALAR_TYPE_UNSPECIFIED",
Self::Varchar => "SQL_CATALOG_SCALAR_TYPE_VARCHAR",
Self::Boolean => "SQL_CATALOG_SCALAR_TYPE_BOOLEAN",
Self::Integer => "SQL_CATALOG_SCALAR_TYPE_INTEGER",
Self::Bigint => "SQL_CATALOG_SCALAR_TYPE_BIGINT",
Self::Double => "SQL_CATALOG_SCALAR_TYPE_DOUBLE",
Self::Timestamp => "SQL_CATALOG_SCALAR_TYPE_TIMESTAMP",
Self::Any => "SQL_CATALOG_SCALAR_TYPE_ANY",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SQL_CATALOG_SCALAR_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"SQL_CATALOG_SCALAR_TYPE_VARCHAR" => Some(Self::Varchar),
"SQL_CATALOG_SCALAR_TYPE_BOOLEAN" => Some(Self::Boolean),
"SQL_CATALOG_SCALAR_TYPE_INTEGER" => Some(Self::Integer),
"SQL_CATALOG_SCALAR_TYPE_BIGINT" => Some(Self::Bigint),
"SQL_CATALOG_SCALAR_TYPE_DOUBLE" => Some(Self::Double),
"SQL_CATALOG_SCALAR_TYPE_TIMESTAMP" => Some(Self::Timestamp),
"SQL_CATALOG_SCALAR_TYPE_ANY" => Some(Self::Any),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SqlCatalogFunctionKind {
Unspecified = 0,
Scalar = 1,
Aggregate = 2,
Window = 3,
Table = 4,
}
impl SqlCatalogFunctionKind {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "SQL_CATALOG_FUNCTION_KIND_UNSPECIFIED",
Self::Scalar => "SQL_CATALOG_FUNCTION_KIND_SCALAR",
Self::Aggregate => "SQL_CATALOG_FUNCTION_KIND_AGGREGATE",
Self::Window => "SQL_CATALOG_FUNCTION_KIND_WINDOW",
Self::Table => "SQL_CATALOG_FUNCTION_KIND_TABLE",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SQL_CATALOG_FUNCTION_KIND_UNSPECIFIED" => Some(Self::Unspecified),
"SQL_CATALOG_FUNCTION_KIND_SCALAR" => Some(Self::Scalar),
"SQL_CATALOG_FUNCTION_KIND_AGGREGATE" => Some(Self::Aggregate),
"SQL_CATALOG_FUNCTION_KIND_WINDOW" => Some(Self::Window),
"SQL_CATALOG_FUNCTION_KIND_TABLE" => Some(Self::Table),
_ => None,
}
}
}
pub mod sql_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct SqlServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl SqlServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> SqlServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> SqlServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
SqlServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn query(
&mut self,
request: impl tonic::IntoRequest<super::SqlServiceQueryRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::SqlServiceQueryResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/nominal.sql.v1.SqlService/Query",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Query"));
self.inner.server_streaming(req, path, codec).await
}
pub async fn export(
&mut self,
request: impl tonic::IntoRequest<super::SqlServiceExportRequest>,
) -> std::result::Result<
tonic::Response<super::SqlServiceExportResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/nominal.sql.v1.SqlService/Export",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("nominal.sql.v1.SqlService", "Export"));
self.inner.unary(req, path, codec).await
}
pub async fn get_sql_catalog(
&mut self,
request: impl tonic::IntoRequest<super::GetSqlCatalogRequest>,
) -> std::result::Result<
tonic::Response<super::GetSqlCatalogResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/nominal.sql.v1.SqlService/GetSqlCatalog",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("nominal.sql.v1.SqlService", "GetSqlCatalog"));
self.inner.unary(req, path, codec).await
}
}
}