From f549397328517d5b2e07f932df19ba2eb6beafe8 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Fri, 28 Jun 2024 16:14:35 +0530 Subject: [PATCH] remove stored procedures stuff --- crates/configuration/src/introspection.rs | 17 ------ crates/configuration/src/version1.rs | 66 ++--------------------- 2 files changed, 4 insertions(+), 79 deletions(-) diff --git a/crates/configuration/src/introspection.rs b/crates/configuration/src/introspection.rs index 0f6550cc..993a1b70 100644 --- a/crates/configuration/src/introspection.rs +++ b/crates/configuration/src/introspection.rs @@ -1,23 +1,6 @@ //! Configuration and state for our connector. use serde::Deserialize; -#[derive(Deserialize, Debug)] -pub struct IntrospectStoredProcedureArgument { - pub name: String, - pub r#type: String, - pub is_nullable: bool, - pub max_length: u8, - pub is_output: bool, -} - -#[derive(Deserialize, Debug)] -pub struct IntrospectStoredProcedure { - pub schema: String, - pub name: String, - #[serde(default)] - pub arguments: Vec, -} - #[derive(Deserialize, Debug)] pub struct IntrospectionTable { pub name: String, diff --git a/crates/configuration/src/version1.rs b/crates/configuration/src/version1.rs index 317ee224..7697b24c 100644 --- a/crates/configuration/src/version1.rs +++ b/crates/configuration/src/version1.rs @@ -7,11 +7,7 @@ use crate::secret::Secret; use crate::{uri, ConnectionUri}; use query_engine_metadata::metadata; -use query_engine_metadata::metadata::stored_procedures::{ - StoredProcedureArgumentInfo, StoredProcedureInfo, StoredProcedures, -}; use query_engine_metadata::metadata::{database, Nullable}; - use query_engine_metrics::metrics; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -21,13 +17,8 @@ use std::collections::BTreeSet; use thiserror::Error; use tiberius::Query; -// TODO(KC): Move the `table_configuration.sql` to the `static` folder present -// in the root of this repo. const TABLE_CONFIGURATION_QUERY: &str = include_str!("table_configuration.sql"); -const STORED_PROCS_CONFIGURATION_QUERY: &str = - include_str!("../../../static/introspect_stored_procedures.sql"); - const TYPES_QUERY: &str = "SELECT name FROM sys.types FOR JSON PATH"; const CURRENT_VERSION: u32 = 1; @@ -201,17 +192,9 @@ pub async fn configure( let type_names: Vec = serde_json::from_str(types_row.get(0).unwrap()).unwrap(); - metadata.comparison_operators = get_comparison_operators(&type_names); - - metadata.aggregate_functions = get_aggregate_functions(&type_names); + metadata.comparison_operators = get_comparison_operators(&type_names).await; - let stored_procedures_row = - select_first_row(&mssql_pool, STORED_PROCS_CONFIGURATION_QUERY).await; - - let stored_procedures: Vec = - serde_json::from_str(stored_procedures_row.get(0).unwrap()).unwrap(); - - metadata.stored_procedures = get_stored_procedures(stored_procedures); + metadata.aggregate_functions = get_aggregate_functions(&type_names).await; Ok(RawConfiguration { version: 1, @@ -225,48 +208,9 @@ struct TypeItem { name: database::ScalarType, } -fn get_stored_procedures( - introspected_stored_procedures: Vec, -) -> query_engine_metadata::metadata::stored_procedures::StoredProcedures { - let mut metadata_stored_procs = BTreeMap::new(); - for stored_procedure in introspected_stored_procedures.into_iter() { - //metadata_stored_procs.insert(stored_procedure.name, quer) - - let metadata_stored_procedure = StoredProcedureInfo { - name: stored_procedure.name.clone(), - schema: stored_procedure.schema, - arguments: stored_procedure - .arguments - .into_iter() - .map(|sp| -> (String, StoredProcedureArgumentInfo) { - // The first character is `@`, so, we skip it. - ( - sp.name.clone(), - StoredProcedureArgumentInfo { - name: sp.name, - r#type: query_engine_metadata::metadata::ScalarType(sp.r#type), - nullable: if sp.is_nullable { - Nullable::Nullable - } else { - Nullable::NonNullable - }, - is_output: sp.is_output, - description: None, - }, - ) - }) - .collect(), - returns: None, - description: None, - }; - metadata_stored_procs.insert(stored_procedure.name, metadata_stored_procedure); - } - StoredProcedures(metadata_stored_procs) -} - // we lookup all types in sys.types, then use our hardcoded ideas about each one to attach // aggregate functions -fn get_aggregate_functions(type_names: &Vec) -> database::AggregateFunctions { +async fn get_aggregate_functions(type_names: &Vec) -> database::AggregateFunctions { let mut aggregate_functions = BTreeMap::new(); for type_name in type_names { @@ -393,7 +337,7 @@ fn get_aggregate_functions_for_type( // we lookup all types in sys.types, then use our hardcoded ideas about each one to attach // comparison operators -fn get_comparison_operators(type_names: &Vec) -> database::ComparisonOperators { +async fn get_comparison_operators(type_names: &Vec) -> database::ComparisonOperators { let mut comparison_operators = BTreeMap::new(); for type_name in type_names { @@ -635,8 +579,6 @@ pub fn occurring_scalar_types(metadata: &metadata::Metadata) -> BTreeSet