diff --git a/.github/workflows/deploy-stage.yaml b/.github/workflows/deploy-stage.yaml index 511abd4..e16c9af 100644 --- a/.github/workflows/deploy-stage.yaml +++ b/.github/workflows/deploy-stage.yaml @@ -1,5 +1,8 @@ name: Deploy connector to dockerhub, release cli on github on: + pull_request: + branches: + - main push: branches: - main @@ -41,7 +44,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - push: true + push: ${{ startsWith(github.ref, 'refs/tags/v') }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/CHANGELOG.md b/CHANGELOG.md index a10e93b..2494ed7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.3] + +- Update SDK version to enable unauthorized access to health endpoint + ## [1.0.2] - Allow `DateTime64` shorthand for `DateTime64(3)` diff --git a/Cargo.lock b/Cargo.lock index fdab4a9..13eae04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,6 +250,16 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +[[package]] +name = "bstr" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -350,17 +360,33 @@ checksum = "97af0562545a7d7f3d9222fcf909963bec36dcb502afaacab98c6ffac8da47ce" [[package]] name = "common" -version = "1.0.2" +version = "1.0.3" dependencies = [ "bytes", + "indexmap 2.5.0", + "insta", + "ndc-models", "peg", "reqwest 0.12.7", "schemars", "serde", "serde_json", + "strum", "tracing", ] +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -458,6 +484,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "encoding_rs" version = "0.8.34" @@ -624,6 +656,19 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "globset" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", +] + [[package]] name = "h2" version = "0.3.26" @@ -914,6 +959,21 @@ dependencies = [ "serde", ] +[[package]] +name = "insta" +version = "1.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6593a41c7a73841868772495db7dc1e8ecab43bb5c0b6da2059246c4b506ab60" +dependencies = [ + "console", + "globset", + "lazy_static", + "linked-hash-map", + "serde", + "similar", + "walkdir", +] + [[package]] name = "ipnet" version = "2.9.0" @@ -962,6 +1022,12 @@ version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1076,12 +1142,14 @@ dependencies = [ [[package]] name = "ndc-clickhouse" -version = "1.0.2" +version = "1.0.3" dependencies = [ "async-trait", "bytes", "common", + "http 0.2.12", "indexmap 2.5.0", + "insta", "ndc-sdk", "prometheus", "reqwest 0.12.7", @@ -1096,10 +1164,13 @@ dependencies = [ [[package]] name = "ndc-clickhouse-cli" -version = "1.0.2" +version = "1.0.3" dependencies = [ "clap", "common", + "insta", + "ndc-models", + "reqwest 0.12.7", "schemars", "serde", "serde_json", @@ -1108,20 +1179,22 @@ dependencies = [ [[package]] name = "ndc-models" -version = "0.1.4" -source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.4#20172e3b2552b78d16dbafcd047f559ced420309" +version = "0.1.6" +source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.6#d1be19e9cdd86ac7b6ad003ff82b7e5b4e96b84f" dependencies = [ "indexmap 2.5.0", + "ref-cast", "schemars", "serde", "serde_json", "serde_with", + "smol_str", ] [[package]] name = "ndc-sdk" -version = "0.1.5" -source = "git+https://github.com/hasura/ndc-sdk-rs?tag=v0.1.5#7f8382001b745c24b5f066411dde6822df65f545" +version = "0.4.0" +source = "git+https://github.com/hasura/ndc-sdk-rs?tag=v0.4.0#665509f7d3b47ce4f014fc23f817a3599ba13933" dependencies = [ "async-trait", "axum", @@ -1153,8 +1226,8 @@ dependencies = [ [[package]] name = "ndc-test" -version = "0.1.4" -source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.4#20172e3b2552b78d16dbafcd047f559ced420309" +version = "0.1.6" +source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.6#d1be19e9cdd86ac7b6ad003ff82b7e5b4e96b84f" dependencies = [ "async-trait", "clap", @@ -1166,6 +1239,7 @@ dependencies = [ "semver", "serde", "serde_json", + "smol_str", "thiserror", "tokio", "url", @@ -1648,6 +1722,26 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex" version = "1.10.6" @@ -1904,6 +1998,15 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.23" @@ -2095,6 +2198,12 @@ dependencies = [ "libc", ] +[[package]] +name = "similar" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" + [[package]] name = "slab" version = "0.4.9" @@ -2694,6 +2803,16 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -2821,6 +2940,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index baaf773..b2d2d24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,10 @@ members = [ ] resolver = "2" -package.version = "1.0.2" +package.version = "1.0.3" package.edition = "2021" + +# insta performs better in release mode +[profile.dev.package] +insta.opt-level = 3 +similar.opt-level = 3 diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index ee7b01a..1be8e3b 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -6,6 +6,8 @@ edition.workspace = true [dependencies] bytes = "1.6.0" peg = "0.8.2" +indexmap = "2.1.0" +ndc-models = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.6" } reqwest = { version = "0.12.3", features = [ "json", "rustls-tls", @@ -13,4 +15,9 @@ reqwest = { version = "0.12.3", features = [ schemars = "0.8.16" serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.114" +strum = { version = "0.26.3", features = ["derive"] } tracing = "0.1.40" + +[dev-dependencies] +insta = { version = "1.40.0", features = ["yaml", "glob", "json"] } +schemars = "0.8.16" diff --git a/crates/common/src/capabilities.rs b/crates/common/src/capabilities.rs new file mode 100644 index 0000000..ac0f749 --- /dev/null +++ b/crates/common/src/capabilities.rs @@ -0,0 +1,37 @@ +use ndc_models::{ + Capabilities, CapabilitiesResponse, ExistsCapabilities, LeafCapability, MutationCapabilities, + NestedFieldCapabilities, QueryCapabilities, RelationshipCapabilities, VERSION, +}; + +pub fn capabilities() -> Capabilities { + Capabilities { + query: QueryCapabilities { + aggregates: Some(LeafCapability {}), + variables: Some(LeafCapability {}), + explain: Some(LeafCapability {}), + nested_fields: NestedFieldCapabilities { + filter_by: None, + order_by: None, + aggregates: None, + }, + exists: ExistsCapabilities { + nested_collections: None, + }, + }, + mutation: MutationCapabilities { + transactional: None, + explain: None, + }, + relationships: Some(RelationshipCapabilities { + relation_comparisons: Some(LeafCapability {}), + order_by_aggregate: Some(LeafCapability {}), + }), + } +} + +pub fn capabilities_response() -> CapabilitiesResponse { + CapabilitiesResponse { + version: VERSION.into(), + capabilities: capabilities(), + } +} diff --git a/crates/common/src/client.rs b/crates/common/src/client.rs index 289ae44..904d643 100644 --- a/crates/common/src/client.rs +++ b/crates/common/src/client.rs @@ -8,7 +8,7 @@ use crate::config::ConnectionConfig; pub fn get_http_client( _connection_config: &ConnectionConfig, -) -> Result> { +) -> Result { // todo: we could make client come preconfigured with some headers such as for username and password? let client = reqwest::Client::builder().build()?; Ok(client) @@ -19,7 +19,7 @@ pub async fn execute_query( connection_config: &ConnectionConfig, statement: &str, parameters: &Vec<(String, String)>, -) -> Result> { +) -> Result { let response = client .post(&connection_config.url) .header("X-ClickHouse-User", &connection_config.username) @@ -33,11 +33,8 @@ pub async fn execute_query( )) .await?; - if response.error_for_status_ref().is_err() { - return Err(response.text().await?.into()); - } - let response = response + .error_for_status()? .bytes() .instrument(tracing::info_span!( "Read HTTP response", @@ -53,7 +50,7 @@ pub async fn execute_json_query( connection_config: &ConnectionConfig, statement: &str, parameters: &Vec<(String, String)>, -) -> Result, Box> { +) -> Result, reqwest::Error> { let response = client .post(&connection_config.url) .header("X-ClickHouse-User", &connection_config.username) @@ -64,11 +61,8 @@ pub async fn execute_json_query( .instrument(tracing::info_span!("Execute HTTP request")) .await?; - if response.error_for_status_ref().is_err() { - return Err(response.text().await?.into()); - } - let payload: ClickHouseResponse = response + .error_for_status()? .json() .instrument(tracing::info_span!("Parse HTTP response")) .await?; diff --git a/crates/common/src/config.rs b/crates/common/src/config.rs index 329d26d..b7ca1c5 100644 --- a/crates/common/src/config.rs +++ b/crates/common/src/config.rs @@ -1,5 +1,7 @@ use std::collections::BTreeMap; +use ndc_models::{ArgumentName, CollectionName, FieldName, ObjectTypeName}; + use crate::{ clickhouse_parser::{datatype::ClickHouseDataType, parameterized_query::ParameterizedQuery}, config_file::{ParameterizedQueryExposedAs, PrimaryKey}, @@ -11,15 +13,15 @@ pub struct ServerConfig { /// the connection part of the config is not part of the config file pub connection: ConnectionConfig, pub namespace_separator: String, - pub table_types: BTreeMap, - pub tables: BTreeMap, - pub queries: BTreeMap, + pub table_types: BTreeMap, + pub tables: BTreeMap, + pub queries: BTreeMap, } #[derive(Debug, Clone)] pub struct TableType { pub comment: Option, - pub columns: BTreeMap, + pub columns: BTreeMap, } #[derive(Debug, Default, Clone)] @@ -38,9 +40,9 @@ pub struct TableConfig { /// Comments are sourced from the database table comment pub comment: Option, pub primary_key: Option, - pub arguments: BTreeMap, + pub arguments: BTreeMap, // this key coresponds to a return type definition in the config table types - pub return_type: ReturnTypeRef, + pub return_type: ObjectTypeName, } #[derive(Debug, Clone)] @@ -48,7 +50,5 @@ pub struct ParameterizedQueryConfig { pub exposed_as: ParameterizedQueryExposedAs, pub comment: Option, pub query: ParameterizedQuery, - pub return_type: ReturnTypeRef, + pub return_type: ObjectTypeName, } - -type ReturnTypeRef = String; diff --git a/crates/common/src/config_file.rs b/crates/common/src/config_file.rs index d79e600..e26ff43 100644 --- a/crates/common/src/config_file.rs +++ b/crates/common/src/config_file.rs @@ -1,5 +1,6 @@ use std::collections::BTreeMap; +use ndc_models::{ArgumentName, CollectionName, FieldName}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -15,11 +16,11 @@ pub struct ServerConfigFile { /// This is the name exposed to the engine, and may be configured by users. /// When the configuration is updated, the table is identified by name and schema, and changes to the alias are preserved. #[serde(skip_serializing_if = "BTreeMap::is_empty", default)] - pub tables: BTreeMap, + pub tables: BTreeMap, /// Optionally define custom parameterized queries here /// Note the names must not match table names #[serde(skip_serializing_if = "BTreeMap::is_empty", default)] - pub queries: BTreeMap, + pub queries: BTreeMap, } impl Default for ServerConfigFile { @@ -44,7 +45,7 @@ pub struct TableConfigFile { #[serde(skip_serializing_if = "Option::is_none")] pub primary_key: Option, #[serde(skip_serializing_if = "BTreeMap::is_empty", default)] - pub arguments: BTreeMap, + pub arguments: BTreeMap, /// The map key is a column alias identifying the table and may be customized. /// It defaults to the table name. /// When the configuration is updated, the column is identified by name, and changes to the alias are preserved. @@ -55,7 +56,7 @@ pub struct TableConfigFile { pub struct PrimaryKey { pub name: String, /// The names of columns in this primary key - pub columns: Vec, + pub columns: Vec, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] @@ -63,18 +64,20 @@ pub struct PrimaryKey { pub enum ReturnType { /// A custom return type definition /// The keys are column names, the values are parsable clichouse datatypes - Definition { columns: BTreeMap }, + Definition { + columns: BTreeMap, + }, /// the same as the return type for another table TableReference { /// the table alias must match a key in `tables`, and the query must return the same type as that table /// alternatively, the alias may reference another parameterized query which has a return type definition, - table_name: String, + table_name: CollectionName, }, /// The same as the return type for another query QueryReference { /// the table alias must match a key in `tables`, and the query must return the same type as that table /// alternatively, the alias may reference another parameterized query which has a return type definition, - query_name: String, + query_name: CollectionName, }, } diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 712db38..7dad1fd 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -1,4 +1,6 @@ +pub mod capabilities; pub mod clickhouse_parser; pub mod client; pub mod config; pub mod config_file; +pub mod schema; diff --git a/crates/ndc-clickhouse/src/connector/handler/schema.rs b/crates/common/src/schema.rs similarity index 87% rename from crates/ndc-clickhouse/src/connector/handler/schema.rs rename to crates/common/src/schema.rs index c0312f2..9e20036 100644 --- a/crates/ndc-clickhouse/src/connector/handler/schema.rs +++ b/crates/common/src/schema.rs @@ -1,5 +1,4 @@ -use crate::schema::{ClickHouseTypeDefinition, SchemaTypeDefinitions}; -use common::{ +use crate::{ clickhouse_parser::{ datatype::ClickHouseDataType, parameterized_query::{Parameter, ParameterType, ParameterizedQueryElement}, @@ -7,18 +6,18 @@ use common::{ config::ServerConfig, config_file::{ParameterizedQueryExposedAs, PrimaryKey}, }; -use ndc_sdk::{connector::SchemaError, json_response::JsonResponse, models}; +use ndc_models::{self as models, ObjectTypeName, ScalarTypeName}; use std::collections::BTreeMap; - -pub async fn schema( - configuration: &ServerConfig, -) -> Result, SchemaError> { - Ok(JsonResponse::Value(schema_response(configuration))) -} +use type_definition::{ClickHouseTypeDefinition, SchemaTypeDefinitions}; +pub mod binary_comparison_operator; +pub mod single_column_aggregate_function; +pub mod type_definition; pub fn schema_response(configuration: &ServerConfig) -> models::SchemaResponse { - let mut scalar_type_definitions = BTreeMap::new(); - let mut object_type_definitions = vec![]; + let mut scalar_type_definitions: BTreeMap = + BTreeMap::new(); + let mut object_type_definitions: BTreeMap = + BTreeMap::new(); for (type_name, table_type) in &configuration.table_types { let mut fields = vec![]; @@ -33,7 +32,7 @@ pub fn schema_response(configuration: &ServerConfig) -> models::SchemaResponse { let SchemaTypeDefinitions { scalars, objects } = type_definition.type_definitions(); for (name, definition) in objects { - object_type_definitions.push((name, definition)); + object_type_definitions.insert(name, definition); } for (name, definition) in scalars { // silently dropping duplicate scalar definitions @@ -52,27 +51,27 @@ pub fn schema_response(configuration: &ServerConfig) -> models::SchemaResponse { )); } - object_type_definitions.push(( + object_type_definitions.insert( type_name.to_owned(), models::ObjectType { description: table_type.comment.to_owned(), fields: fields.into_iter().collect(), }, - )); + ); } for (table_alias, table_config) in &configuration.tables { for (argument_name, argument_type) in &table_config.arguments { let type_definition = ClickHouseTypeDefinition::from_query_argument( argument_type, - argument_name, - table_alias, + argument_name.inner(), + table_alias.inner(), &configuration.namespace_separator, ); let SchemaTypeDefinitions { scalars, objects } = type_definition.type_definitions(); for (name, definition) in objects { - object_type_definitions.push((name, definition)); + object_type_definitions.insert(name, definition); } for (name, definition) in scalars { // silently dropping duplicate scalar definitions @@ -93,14 +92,14 @@ pub fn schema_response(configuration: &ServerConfig) -> models::SchemaResponse { let type_definition = ClickHouseTypeDefinition::from_query_argument( data_type, name.value(), - query_alias, + query_alias.inner(), &configuration.namespace_separator, ); let SchemaTypeDefinitions { scalars, objects } = type_definition.type_definitions(); for (name, definition) in objects { - object_type_definitions.push((name, definition)); + object_type_definitions.insert(name, definition); } for (name, definition) in scalars { // silently dropping duplicate scalar definitions @@ -124,8 +123,8 @@ pub fn schema_response(configuration: &ServerConfig) -> models::SchemaResponse { .map(|(argument_name, argument_type)| { let type_definition = ClickHouseTypeDefinition::from_query_argument( argument_type, - argument_name, - table_alias, + argument_name.inner(), + table_alias.inner(), &configuration.namespace_separator, ); ( @@ -175,12 +174,12 @@ pub fn schema_response(configuration: &ServerConfig) -> models::SchemaResponse { let type_definition = ClickHouseTypeDefinition::from_query_argument( data_type, name.value(), - query_alias, + query_alias.inner(), &configuration.namespace_separator, ); Some(( - name.value().to_owned(), + name.value().to_owned().into(), models::ArgumentInfo { description: None, argument_type: type_definition.type_identifier(), @@ -206,7 +205,7 @@ pub fn schema_response(configuration: &ServerConfig) -> models::SchemaResponse { scalar_types: scalar_type_definitions, // converting vector to map drops any duplicate definitions // this could be an issue if there are name collisions - object_types: object_type_definitions.into_iter().collect(), + object_types: object_type_definitions, collections, functions: vec![], procedures: vec![], diff --git a/crates/common/src/schema/binary_comparison_operator.rs b/crates/common/src/schema/binary_comparison_operator.rs new file mode 100644 index 0000000..e028f42 --- /dev/null +++ b/crates/common/src/schema/binary_comparison_operator.rs @@ -0,0 +1,31 @@ +use strum::{Display, EnumIter, EnumString}; + +#[derive(Debug, Clone, EnumString, Display, EnumIter)] +pub enum ClickHouseBinaryComparisonOperator { + #[strum(to_string = "_eq")] + Eq, + #[strum(to_string = "_gt")] + Gt, + #[strum(to_string = "_lt")] + Lt, + #[strum(to_string = "_gte")] + GtEq, + #[strum(to_string = "_lte")] + LtEq, + #[strum(to_string = "_neq")] + NotEq, + #[strum(to_string = "_like")] + Like, + #[strum(to_string = "_nlike")] + NotLike, + #[strum(to_string = "_ilike")] + ILike, + #[strum(to_string = "_nilike")] + NotILike, + #[strum(to_string = "_in")] + In, + #[strum(to_string = "_nin")] + NotIn, + #[strum(to_string = "_match")] + Match, +} diff --git a/crates/common/src/schema/single_column_aggregate_function.rs b/crates/common/src/schema/single_column_aggregate_function.rs new file mode 100644 index 0000000..41ae602 --- /dev/null +++ b/crates/common/src/schema/single_column_aggregate_function.rs @@ -0,0 +1,14 @@ +use strum::{Display, EnumIter, EnumString}; + +#[derive(Debug, Clone, EnumString, Display, EnumIter, PartialEq, Eq)] +#[strum(serialize_all = "snake_case")] +pub enum ClickHouseSingleColumnAggregateFunction { + Max, + Min, + Sum, + Avg, + StddevPop, + StddevSamp, + VarPop, + VarSamp, +} diff --git a/crates/ndc-clickhouse/src/schema/type_definition.rs b/crates/common/src/schema/type_definition.rs similarity index 94% rename from crates/ndc-clickhouse/src/schema/type_definition.rs rename to crates/common/src/schema/type_definition.rs index b8cec15..b5a2f87 100644 --- a/crates/ndc-clickhouse/src/schema/type_definition.rs +++ b/crates/common/src/schema/type_definition.rs @@ -1,9 +1,12 @@ -use common::clickhouse_parser::datatype::{ClickHouseDataType, Identifier, SingleQuotedString}; +use crate::clickhouse_parser::datatype::{ClickHouseDataType, Identifier, SingleQuotedString}; use indexmap::IndexMap; -use ndc_sdk::models; +use ndc_models::{self as models, FieldName, ObjectTypeName, ScalarTypeName}; use std::{collections::BTreeMap, iter}; -use super::{ClickHouseBinaryComparisonOperator, ClickHouseSingleColumnAggregateFunction}; +use super::{ + binary_comparison_operator::ClickHouseBinaryComparisonOperator, + single_column_aggregate_function::ClickHouseSingleColumnAggregateFunction, +}; #[derive(Debug, Clone)] struct NameSpace<'a> { @@ -35,8 +38,8 @@ impl<'a> NameSpace<'a> { pub struct ClickHouseScalar(ClickHouseDataType); impl ClickHouseScalar { - fn type_name(&self) -> String { - self.0.to_string() + fn type_name(&self) -> ScalarTypeName { + self.0.to_string().into() } fn cast_type(&self) -> ClickHouseDataType { // todo: recusively map large number types to string here @@ -50,10 +53,10 @@ impl ClickHouseScalar { .into_iter() .map(|(function, result_type)| { ( - function.to_string(), + function.to_string().into(), models::AggregateFunctionDefinition { result_type: models::Type::Named { - name: result_type.to_string(), + name: result_type.to_string().into(), }, }, ) @@ -74,7 +77,7 @@ impl ClickHouseScalar { models::ComparisonOperatorDefinition::Custom { argument_type: models::Type::Array { element_type: Box::new(models::Type::Named { - name: self.type_name(), + name: self.type_name().into_inner(), }), }, } @@ -91,12 +94,12 @@ impl ClickHouseScalar { | ClickHouseBinaryComparisonOperator::Match => { models::ComparisonOperatorDefinition::Custom { argument_type: models::Type::Named { - name: self.type_name(), + name: self.type_name().into_inner(), }, } } }; - (operator.to_string(), definition) + (operator.to_string().into(), definition) }) .collect(), } @@ -416,8 +419,8 @@ pub enum ClickHouseTypeDefinition { element_type: Box, }, Object { - name: String, - fields: IndexMap, + name: ObjectTypeName, + fields: IndexMap, }, } @@ -425,11 +428,14 @@ impl ClickHouseTypeDefinition { /// Table alias is guaranteed unique across the database, and by default includes the schema name for non default schemas pub fn from_table_column( data_type: &ClickHouseDataType, - column_alias: &str, - table_alias: &str, + column_alias: &FieldName, + return_type: &ObjectTypeName, separator: &str, ) -> Self { - let namespace = NameSpace::new(vec![table_alias, column_alias], separator); + let namespace = NameSpace::new( + vec![return_type.inner().inner(), column_alias.inner()], + separator, + ); Self::new(data_type, &namespace) } pub fn from_query_return_type( @@ -468,7 +474,7 @@ impl ClickHouseTypeDefinition { let field_definition = Self::new(field_data_type, &field_namespace); if fields - .insert(name.value().to_owned(), field_definition) + .insert(name.value().to_owned().into(), field_definition) .is_some() { // on duplicate field names, fall back to unknown type @@ -478,7 +484,7 @@ impl ClickHouseTypeDefinition { Self::Array { element_type: Box::new(Self::Object { - name: namespace.value(), + name: namespace.value().into(), fields, }), } @@ -502,7 +508,7 @@ impl ClickHouseTypeDefinition { let field_definition = Self::new(field_data_type, &field_namespace); if fields - .insert(field_name.to_owned(), field_definition) + .insert(field_name.to_owned().into(), field_definition) .is_some() { // on duplicate field names, fall back to unknown type @@ -511,7 +517,7 @@ impl ClickHouseTypeDefinition { } Self::Object { - name: namespace.value(), + name: namespace.value().into(), fields, } } @@ -548,7 +554,7 @@ impl ClickHouseTypeDefinition { pub fn type_identifier(&self) -> models::Type { match self { ClickHouseTypeDefinition::Scalar(scalar) => models::Type::Named { - name: scalar.type_name(), + name: scalar.type_name().into_inner(), }, ClickHouseTypeDefinition::Nullable { inner } => models::Type::Nullable { underlying_type: Box::new(inner.type_identifier()), @@ -557,7 +563,7 @@ impl ClickHouseTypeDefinition { element_type: Box::new(element_type.type_identifier()), }, ClickHouseTypeDefinition::Object { name, fields: _ } => models::Type::Named { - name: name.to_owned(), + name: name.to_owned().into(), }, } } @@ -577,7 +583,7 @@ impl ClickHouseTypeDefinition { .map(|(key, value)| { // todo: prevent issues where the key contains unescaped double quotes ( - Some(Identifier::DoubleQuoted(key.to_owned())), + Some(Identifier::DoubleQuoted(key.to_owned().into())), value.cast_type(), ) }) @@ -600,7 +606,7 @@ impl ClickHouseTypeDefinition { name: namespace, fields, } => { - let mut object_type_fields = vec![]; + let mut object_type_fields = BTreeMap::new(); let mut object_type_definitions = vec![]; let mut scalar_type_definitions = vec![]; @@ -613,18 +619,18 @@ impl ClickHouseTypeDefinition { scalar_type_definitions.append(&mut scalars); object_type_definitions.append(&mut objects); - object_type_fields.push(( + object_type_fields.insert( field_name.to_owned(), models::ObjectField { description: None, r#type: field.type_identifier(), arguments: BTreeMap::new(), }, - )); + ); } object_type_definitions.push(( - namespace.to_string(), + namespace.to_string().into(), models::ObjectType { description: None, fields: object_type_fields.into_iter().collect(), @@ -660,6 +666,6 @@ impl ClickHouseTypeDefinition { } pub struct SchemaTypeDefinitions { - pub scalars: Vec<(String, models::ScalarType)>, - pub objects: Vec<(String, models::ObjectType)>, + pub scalars: Vec<(ScalarTypeName, models::ScalarType)>, + pub objects: Vec<(ObjectTypeName, models::ObjectType)>, } diff --git a/crates/common/tests/common.rs b/crates/common/tests/common.rs new file mode 100644 index 0000000..f71025e --- /dev/null +++ b/crates/common/tests/common.rs @@ -0,0 +1,13 @@ +use common::{capabilities::capabilities_response, config_file::ServerConfigFile}; +use insta::assert_yaml_snapshot; +use schemars::schema_for; + +#[test] +fn test_capabilities() { + assert_yaml_snapshot!("Capabilities", capabilities_response()) +} + +#[test] +fn test_configuration_schema() { + assert_yaml_snapshot!("Server Configuration File", schema_for!(ServerConfigFile)) +} diff --git a/crates/common/tests/snapshots/common__Capabilities.snap b/crates/common/tests/snapshots/common__Capabilities.snap new file mode 100644 index 0000000..7396705 --- /dev/null +++ b/crates/common/tests/snapshots/common__Capabilities.snap @@ -0,0 +1,16 @@ +--- +source: crates/common/tests/common.rs +expression: capabilities_response() +--- +version: 0.1.6 +capabilities: + query: + aggregates: {} + variables: {} + explain: {} + nested_fields: {} + exists: {} + mutation: {} + relationships: + relation_comparisons: {} + order_by_aggregate: {} diff --git a/crates/common/tests/snapshots/common__Server Configuration File.snap b/crates/common/tests/snapshots/common__Server Configuration File.snap new file mode 100644 index 0000000..906528a --- /dev/null +++ b/crates/common/tests/snapshots/common__Server Configuration File.snap @@ -0,0 +1,137 @@ +--- +source: crates/common/tests/common.rs +expression: schema_for!(ServerConfigFile) +--- +$schema: "http://json-schema.org/draft-07/schema#" +title: ServerConfigFile +description: the main configuration file +type: object +required: + - $schema +properties: + $schema: + type: string + tables: + description: "A list of tables available in this database\n\nThe map key is a unique table alias that defaults to defaults to \"_\", except for tables in the \"default\" schema where the table name is used This is the name exposed to the engine, and may be configured by users. When the configuration is updated, the table is identified by name and schema, and changes to the alias are preserved." + type: object + additionalProperties: + $ref: "#/definitions/TableConfigFile" + queries: + description: Optionally define custom parameterized queries here Note the names must not match table names + type: object + additionalProperties: + $ref: "#/definitions/ParameterizedQueryConfigFile" +definitions: + TableConfigFile: + type: object + required: + - name + - return_type + - schema + properties: + name: + description: The table name + type: string + schema: + description: The table schema + type: string + comment: + description: Comments are sourced from the database table comment + type: + - string + - "null" + primary_key: + anyOf: + - $ref: "#/definitions/PrimaryKey" + - type: "null" + arguments: + type: object + additionalProperties: + type: string + return_type: + description: "The map key is a column alias identifying the table and may be customized. It defaults to the table name. When the configuration is updated, the column is identified by name, and changes to the alias are preserved." + allOf: + - $ref: "#/definitions/ReturnType" + PrimaryKey: + type: object + required: + - columns + - name + properties: + name: + type: string + columns: + description: The names of columns in this primary key + type: array + items: + type: string + ReturnType: + oneOf: + - description: "A custom return type definition The keys are column names, the values are parsable clichouse datatypes" + type: object + required: + - columns + - kind + properties: + kind: + type: string + enum: + - definition + columns: + type: object + additionalProperties: + type: string + - description: the same as the return type for another table + type: object + required: + - kind + - table_name + properties: + kind: + type: string + enum: + - table_reference + table_name: + description: "the table alias must match a key in `tables`, and the query must return the same type as that table alternatively, the alias may reference another parameterized query which has a return type definition," + type: string + - description: The same as the return type for another query + type: object + required: + - kind + - query_name + properties: + kind: + type: string + enum: + - query_reference + query_name: + description: "the table alias must match a key in `tables`, and the query must return the same type as that table alternatively, the alias may reference another parameterized query which has a return type definition," + type: string + ParameterizedQueryConfigFile: + type: object + required: + - exposed_as + - file + - return_type + properties: + exposed_as: + description: Whether this query should be exposed as a procedure (mutating) or collection (non-mutating) + allOf: + - $ref: "#/definitions/ParameterizedQueryExposedAs" + comment: + description: A comment that will be exposed in the schema + type: + - string + - "null" + file: + description: A relative path to a sql file + type: string + return_type: + description: "Either a type definition for the return type for this query, or a reference to another return type: either a table's alias, or another query's alias. If another query, that query must have a return type definition." + allOf: + - $ref: "#/definitions/ReturnType" + ParameterizedQueryExposedAs: + type: string + enum: + - collection + - procedure diff --git a/crates/ndc-clickhouse-cli/Cargo.toml b/crates/ndc-clickhouse-cli/Cargo.toml index 05d8572..e5ad093 100644 --- a/crates/ndc-clickhouse-cli/Cargo.toml +++ b/crates/ndc-clickhouse-cli/Cargo.toml @@ -6,7 +6,15 @@ edition.workspace = true [dependencies] clap = { version = "4.5.3", features = ["derive", "env"] } common = { path = "../common" } +ndc-models = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.6" } +reqwest = { version = "0.12.3", features = [ + "json", + "rustls-tls", +], default-features = false } schemars = "0.8.16" serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.114" tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread", "fs"] } + +[dev-dependencies] +insta = { version = "1.40.0", features = ["yaml", "glob", "json"] } diff --git a/crates/ndc-clickhouse-cli/src/database_introspection.rs b/crates/ndc-clickhouse-cli/src/database_introspection.rs index 04fc67b..37a4a2d 100644 --- a/crates/ndc-clickhouse-cli/src/database_introspection.rs +++ b/crates/ndc-clickhouse-cli/src/database_introspection.rs @@ -1,11 +1,8 @@ -use std::error::Error; - -use serde::Deserialize; - use common::{ client::{execute_json_query, get_http_client}, config::ConnectionConfig, }; +use serde::Deserialize; #[derive(Debug, Deserialize)] pub struct TableInfo { @@ -44,7 +41,7 @@ pub enum TableType { pub async fn introspect_database( connection_config: &ConnectionConfig, -) -> Result, Box> { +) -> Result, reqwest::Error> { let introspection_sql = include_str!("./database_introspection.sql"); let client = get_http_client(connection_config)?; execute_json_query::(&client, connection_config, introspection_sql, &vec![]).await diff --git a/crates/ndc-clickhouse-cli/src/main.rs b/crates/ndc-clickhouse-cli/src/main.rs index 015723f..f8c3ff5 100644 --- a/crates/ndc-clickhouse-cli/src/main.rs +++ b/crates/ndc-clickhouse-cli/src/main.rs @@ -19,6 +19,7 @@ use common::{ }, }; use database_introspection::{introspect_database, TableInfo}; +use ndc_models::{CollectionName, FieldName}; use schemars::schema_for; use tokio::fs; mod database_introspection; @@ -182,7 +183,7 @@ async fn update_tables_config( .filter_map(|element| match element { ParameterizedQueryElement::String(_) => None, ParameterizedQueryElement::Parameter(Parameter { name, r#type }) => { - Some((name.to_string(), r#type.to_string())) + Some((name.value().into(), r#type.to_string())) } }) .collect(); @@ -198,7 +199,7 @@ async fn update_tables_config( .iter() .filter_map(|column| { if column.is_in_primary_key { - Some(column.column_name.to_owned()) + Some(column.column_name.to_owned().into()) } else { None } @@ -408,7 +409,7 @@ async fn validate_table_config( fn get_old_table_config<'a>( table: &TableInfo, old_config: &'a Option, -) -> Option<(&'a String, &'a TableConfigFile)> { +) -> Option<(&'a CollectionName, &'a TableConfigFile)> { old_config.as_ref().and_then(|old_config| { old_config.tables.iter().find(|(_, old_table)| { old_table.name == table.table_name && old_table.schema == table.table_schema @@ -419,7 +420,10 @@ fn get_old_table_config<'a>( /// Table aliases default to _, /// except for tables in the default schema where the table name is used. /// Prefer existing, old aliases over creating a new one -fn get_table_alias(table: &TableInfo, old_table: &Option<(&String, &TableConfigFile)>) -> String { +fn get_table_alias( + table: &TableInfo, + old_table: &Option<(&CollectionName, &TableConfigFile)>, +) -> CollectionName { // to preserve any customization, aliases are kept throught updates if let Some((old_table_alias, _)) = old_table { old_table_alias.to_string() @@ -428,6 +432,7 @@ fn get_table_alias(table: &TableInfo, old_table: &Option<(&String, &TableConfigF } else { format!("{}_{}", table.table_schema, table.table_name) } + .into() } /// Given table info, and optionally old table info, get the return type for this table @@ -437,7 +442,7 @@ fn get_table_alias(table: &TableInfo, old_table: &Option<(&String, &TableConfigF /// to a query: check that query still exists, and that it returns the same type as this table fn get_table_return_type( table: &TableInfo, - old_table: &Option<(&String, &TableConfigFile)>, + old_table: &Option<(&CollectionName, &TableConfigFile)>, old_config: &Option, introspection: &[TableInfo], ) -> ReturnType { @@ -515,10 +520,15 @@ fn get_table_return_type( }) } -fn get_return_type_columns(table: &TableInfo) -> BTreeMap { +fn get_return_type_columns(table: &TableInfo) -> BTreeMap { table .columns .iter() - .map(|column| (column.column_name.to_owned(), column.data_type.to_owned())) + .map(|column| { + ( + column.column_name.to_string().into(), + column.data_type.to_owned(), + ) + }) .collect() } diff --git a/crates/ndc-clickhouse/Cargo.toml b/crates/ndc-clickhouse/Cargo.toml index f448e13..03b848d 100644 --- a/crates/ndc-clickhouse/Cargo.toml +++ b/crates/ndc-clickhouse/Cargo.toml @@ -7,8 +7,9 @@ edition.workspace = true async-trait = "0.1.78" bytes = "1.6.0" common = { path = "../common" } +http = "0.2" indexmap = "2.1.0" -ndc-sdk = { git = "https://github.com/hasura/ndc-sdk-rs", tag = "v0.1.5", package = "ndc-sdk" } +ndc-sdk = { git = "https://github.com/hasura/ndc-sdk-rs", tag = "v0.4.0", package = "ndc-sdk" } prometheus = "0.13.3" reqwest = { version = "0.12.3", features = [ "json", @@ -21,3 +22,7 @@ sqlformat = "0.2.3" strum = { version = "0.26.3", features = ["derive"] } tokio = "1.36.0" tracing = "0.1.40" + +[dev-dependencies] +insta = { version = "1.40.0", features = ["yaml", "glob", "json"] } +schemars = "0.8.16" diff --git a/crates/ndc-clickhouse/src/connector.rs b/crates/ndc-clickhouse/src/connector.rs index aab40dc..0b5fcdb 100644 --- a/crates/ndc-clickhouse/src/connector.rs +++ b/crates/ndc-clickhouse/src/connector.rs @@ -4,12 +4,10 @@ pub mod state; use self::state::ServerState; use async_trait::async_trait; -use common::config::ServerConfig; +use common::{capabilities::capabilities, config::ServerConfig, schema::schema_response}; +use http::StatusCode; use ndc_sdk::{ - connector::{ - Connector, ExplainError, FetchMetricsError, HealthError, MutationError, QueryError, - SchemaError, - }, + connector::{Connector, ErrorResponse, Result}, json_response::JsonResponse, models, }; @@ -22,44 +20,25 @@ impl Connector for ClickhouseConnector { type Configuration = ServerConfig; type State = ServerState; - fn fetch_metrics( - _configuration: &Self::Configuration, - _state: &Self::State, - ) -> Result<(), FetchMetricsError> { - Ok(()) - } - - async fn health_check( - configuration: &Self::Configuration, - state: &Self::State, - ) -> Result<(), HealthError> { - let client = state - .client(configuration) - .await - .map_err(HealthError::new)?; - - common::client::ping(&client, &configuration.connection) - .await - .map_err(HealthError::new)?; - + fn fetch_metrics(_configuration: &Self::Configuration, _state: &Self::State) -> Result<()> { Ok(()) } - async fn get_capabilities() -> JsonResponse { - JsonResponse::Value(handler::capabilities()) + async fn get_capabilities() -> models::Capabilities { + capabilities() } async fn get_schema( configuration: &Self::Configuration, - ) -> Result, SchemaError> { - handler::schema(configuration).await + ) -> Result> { + Ok(JsonResponse::Value(schema_response(configuration))) } async fn query_explain( configuration: &Self::Configuration, state: &Self::State, request: models::QueryRequest, - ) -> Result, ExplainError> { + ) -> Result> { handler::explain(configuration, state, request).await } @@ -67,9 +46,11 @@ impl Connector for ClickhouseConnector { _configuration: &Self::Configuration, _state: &Self::State, _request: models::MutationRequest, - ) -> Result, ExplainError> { - Err(ExplainError::new_unsupported_operation( - &"mutation explain not supported", + ) -> Result> { + Err(ErrorResponse::new( + StatusCode::NOT_IMPLEMENTED, + "mutation explain not supported".to_string(), + serde_json::Value::Null, )) } @@ -77,9 +58,11 @@ impl Connector for ClickhouseConnector { _configuration: &Self::Configuration, _state: &Self::State, _request: models::MutationRequest, - ) -> Result, MutationError> { - Err(MutationError::new_unsupported_operation( - &"mutation not supported", + ) -> Result> { + Err(ErrorResponse::new( + StatusCode::NOT_IMPLEMENTED, + "mutation not supported".to_string(), + serde_json::Value::Null, )) } @@ -87,7 +70,7 @@ impl Connector for ClickhouseConnector { configuration: &Self::Configuration, state: &Self::State, request: models::QueryRequest, - ) -> Result, QueryError> { + ) -> Result> { handler::query(configuration, state, request).await } } diff --git a/crates/ndc-clickhouse/src/connector/handler.rs b/crates/ndc-clickhouse/src/connector/handler.rs index 16c3abd..e582a8f 100644 --- a/crates/ndc-clickhouse/src/connector/handler.rs +++ b/crates/ndc-clickhouse/src/connector/handler.rs @@ -1,9 +1,5 @@ -mod capabilities; mod explain; mod query; -mod schema; -pub use capabilities::*; pub use explain::*; pub use query::*; -pub use schema::*; diff --git a/crates/ndc-clickhouse/src/connector/handler/capabilities.rs b/crates/ndc-clickhouse/src/connector/handler/capabilities.rs deleted file mode 100644 index 107ec4d..0000000 --- a/crates/ndc-clickhouse/src/connector/handler/capabilities.rs +++ /dev/null @@ -1,30 +0,0 @@ -use ndc_sdk::models::{ - Capabilities, CapabilitiesResponse, LeafCapability, MutationCapabilities, - NestedFieldCapabilities, QueryCapabilities, RelationshipCapabilities, -}; - -pub fn capabilities() -> CapabilitiesResponse { - CapabilitiesResponse { - version: "0.1.4".to_owned(), - capabilities: Capabilities { - query: QueryCapabilities { - aggregates: Some(LeafCapability {}), - variables: Some(LeafCapability {}), - explain: Some(LeafCapability {}), - nested_fields: NestedFieldCapabilities { - filter_by: None, - order_by: None, - aggregates: None, - }, - }, - mutation: MutationCapabilities { - transactional: None, - explain: None, - }, - relationships: Some(RelationshipCapabilities { - relation_comparisons: Some(LeafCapability {}), - order_by_aggregate: Some(LeafCapability {}), - }), - }, - } -} diff --git a/crates/ndc-clickhouse/src/connector/handler/explain.rs b/crates/ndc-clickhouse/src/connector/handler/explain.rs index 665c812..4abc479 100644 --- a/crates/ndc-clickhouse/src/connector/handler/explain.rs +++ b/crates/ndc-clickhouse/src/connector/handler/explain.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use common::{client::execute_json_query, config::ServerConfig}; -use ndc_sdk::{connector::ExplainError, json_response::JsonResponse, models}; +use ndc_sdk::{connector::ErrorResponse, json_response::JsonResponse, models}; use serde::{Deserialize, Serialize}; use crate::{connector::state::ServerState, sql::QueryBuilder}; @@ -15,7 +15,7 @@ pub async fn explain( configuration: &ServerConfig, state: &ServerState, request: models::QueryRequest, -) -> Result, ExplainError> { +) -> Result, ErrorResponse> { let inlined_statement = QueryBuilder::new(&request, configuration) .build_inlined()? .explain() @@ -24,7 +24,10 @@ pub async fn explain( QueryBuilder::new(&request, configuration).build_parameterized()?; let parameterized_statement = parameterized_statement.explain().to_string(); - let client = state.client(configuration).await?; + let client = state + .client(configuration) + .await + .map_err(ErrorResponse::from_error)?; let explain = execute_json_query::( &client, @@ -52,7 +55,7 @@ pub async fn explain( ), ( "Parameters".to_string(), - serde_json::to_string(¶meters).map_err(ExplainError::new)?, + serde_json::to_string(¶meters).map_err(ErrorResponse::from_error)?, ), ("Execution Plan".to_string(), explain), ]); diff --git a/crates/ndc-clickhouse/src/connector/handler/query.rs b/crates/ndc-clickhouse/src/connector/handler/query.rs index 896e9d8..7cdb9b1 100644 --- a/crates/ndc-clickhouse/src/connector/handler/query.rs +++ b/crates/ndc-clickhouse/src/connector/handler/query.rs @@ -1,5 +1,5 @@ use common::{client::execute_query, config::ServerConfig}; -use ndc_sdk::{connector::QueryError, json_response::JsonResponse, models}; +use ndc_sdk::{connector::ErrorResponse, json_response::JsonResponse, models}; use tracing::{Instrument, Level}; use crate::{connector::state::ServerState, sql::QueryBuilder}; @@ -8,18 +8,18 @@ pub async fn query( configuration: &ServerConfig, state: &ServerState, request: models::QueryRequest, -) -> Result, QueryError> { +) -> Result, ErrorResponse> { #[cfg(debug_assertions)] { // this block only present in debug builds, to avoid leaking sensitive information - let request_string = serde_json::to_string(&request).map_err(QueryError::new)?; + let request_string = serde_json::to_string(&request).map_err(ErrorResponse::from_error)?; tracing::event!(Level::DEBUG, "Incoming IR" = request_string); } let (statement_string, parameters) = tracing::info_span!("Build SQL Query", internal.visibility = "user").in_scope( - || -> Result<_, QueryError> { + || -> Result<_, ErrorResponse> { let (statement, parameters) = QueryBuilder::new(&request, configuration).build_parameterized()?; @@ -39,7 +39,10 @@ pub async fn query( }, )?; - let client = state.client(configuration).await.map_err(QueryError::new)?; + let client = state + .client(configuration) + .await + .map_err(ErrorResponse::from_error)?; let execution_span = tracing::info_span!( "Execute SQL query", @@ -57,12 +60,12 @@ pub async fn query( ) .instrument(execution_span) .await - .map_err(QueryError::new)?; + .map_err(ErrorResponse::from_error)?; #[cfg(debug_assertions)] { // this block only present in debug builds, to avoid leaking sensitive information - let result_string = std::str::from_utf8(&rowsets).map_err(QueryError::new)?; + let result_string = std::str::from_utf8(&rowsets).map_err(ErrorResponse::from_error)?; tracing::event!(Level::DEBUG, "Response" = result_string); } diff --git a/crates/ndc-clickhouse/src/connector/setup.rs b/crates/ndc-clickhouse/src/connector/setup.rs index 845af7d..6a878ba 100644 --- a/crates/ndc-clickhouse/src/connector/setup.rs +++ b/crates/ndc-clickhouse/src/connector/setup.rs @@ -7,14 +7,17 @@ use common::{ CONFIG_FILE_NAME, }, }; -use ndc_sdk::connector::{ - Connector, ConnectorSetup, InitializationError, InvalidNode, InvalidNodes, KeyOrIndex, - LocatedError, ParseError, +use ndc_sdk::{ + connector::{ + self, Connector, ConnectorSetup, InvalidNode, InvalidNodes, KeyOrIndex, LocatedError, + ParseError, + }, + models::FieldName, }; use std::{ collections::{BTreeMap, HashMap}, env, - path::Path, + path::{Path, PathBuf}, str::FromStr, }; use tokio::fs; @@ -34,15 +37,16 @@ impl ConnectorSetup for ClickhouseConnectorSetup { async fn parse_configuration( &self, configuration_dir: impl AsRef + Send, - ) -> Result<::Configuration, ParseError> { - self.read_server_config(configuration_dir).await + ) -> connector::Result<::Configuration> { + // we wrap read_server_config so the ParseError is implicitly converted into an ErrorResponse + Ok(self.read_server_config(configuration_dir).await?) } async fn try_init_state( &self, configuration: &::Configuration, _metrics: &mut prometheus::Registry, - ) -> Result<::State, InitializationError> { + ) -> connector::Result<::State> { Ok(ServerState::new(configuration)) } } @@ -69,10 +73,10 @@ impl ClickhouseConnectorSetup { &self, configuration_dir: impl AsRef + Send, ) -> Result { - let connection = self.get_connection_config()?; - let file_path = configuration_dir.as_ref().join(CONFIG_FILE_NAME); + let connection = self.get_connection_config(&file_path)?; + let config_file = fs::read_to_string(&file_path) .await .map_err(|err| match err.kind() { @@ -100,11 +104,11 @@ impl ClickhouseConnectorSetup { &table_config.return_type, &config, &file_path, - &["tables", table_alias, "return_type"], + &["tables", table_alias.inner(), "return_type"], )? .map(|columns| { ( - table_alias.to_owned(), + table_alias.to_string().into(), TableType { comment: table_config.comment.to_owned(), columns, @@ -120,11 +124,11 @@ impl ClickhouseConnectorSetup { &query_config.return_type, &config, &file_path, - &["query", query_alias, "return_type"], + &["query", query_alias.inner(), "return_type"], )? .map(|columns| { ( - query_alias.to_owned(), + query_alias.to_string().into(), TableType { comment: query_config.comment.to_owned(), columns, @@ -149,13 +153,13 @@ impl ClickhouseConnectorSetup { comment: table_config.comment.to_owned(), primary_key: table_config.primary_key.to_owned(), return_type: match &table_config.return_type { - ReturnType::Definition { .. } => table_alias.to_owned(), + ReturnType::Definition { .. } => table_alias.to_string().into(), ReturnType::TableReference { table_name: target_alias, } | ReturnType::QueryReference { query_name: target_alias, - } => target_alias.to_owned(), + } => target_alias.to_string().into(), }, arguments: table_config .arguments @@ -167,9 +171,9 @@ impl ClickhouseConnectorSetup { file_path: file_path.to_owned(), node_path: vec![ KeyOrIndex::Key("tables".to_string()), - KeyOrIndex::Key(table_alias.to_owned()), + KeyOrIndex::Key(table_alias.to_string()), KeyOrIndex::Key("arguments".to_string()), - KeyOrIndex::Key(name.to_owned()), + KeyOrIndex::Key(name.to_string()), ], message: "Unable to parse data type".to_string(), }])) @@ -200,7 +204,7 @@ impl ClickhouseConnectorSetup { file_path: query_file_path.clone(), node_path: vec![ KeyOrIndex::Key("queries".to_string()), - KeyOrIndex::Key(query_alias.clone()), + KeyOrIndex::Key(query_alias.to_string()), ], message: format!("Unable to parse parameterized query: {}", err), }])) @@ -211,13 +215,13 @@ impl ClickhouseConnectorSetup { comment: query_config.comment.to_owned(), query, return_type: match query_config.return_type { - ReturnType::Definition { .. } => query_alias.to_owned(), + ReturnType::Definition { .. } => query_alias.to_string().into(), ReturnType::TableReference { table_name: target_alias, } | ReturnType::QueryReference { query_name: target_alias, - } => target_alias.to_owned(), + } => target_alias.to_string().into(), }, }; @@ -236,16 +240,31 @@ impl ClickhouseConnectorSetup { Ok(config) } - fn get_connection_config(&self) -> Result { - let url = self.url.to_owned().ok_or(ParseError::Other( - "CLICKHOUSE_URL env var must be set".into(), - ))?; - let username = self.username.to_owned().ok_or(ParseError::Other( - "CLICKHOUSE_USERNAME env var must be set".into(), - ))?; - let password = self.password.to_owned().ok_or(ParseError::Other( - "CLICKHOUSE_PASSWORD env var must be set".into(), - ))?; + fn get_connection_config(&self, file_path: &PathBuf) -> Result { + let url = self + .url + .to_owned() + .ok_or(ParseError::ValidateError(InvalidNodes(vec![InvalidNode { + file_path: file_path.to_owned(), + node_path: vec![], + message: "CLICKHOUSE_URL env var must be set".into(), + }])))?; + let username = self + .username + .to_owned() + .ok_or(ParseError::ValidateError(InvalidNodes(vec![InvalidNode { + file_path: file_path.to_owned(), + node_path: vec![], + message: "CLICKHOUSE_USERNAME env var must be set".into(), + }])))?; + let password = self + .password + .to_owned() + .ok_or(ParseError::ValidateError(InvalidNodes(vec![InvalidNode { + file_path: file_path.to_owned(), + node_path: vec![], + message: "CLICKHOUSE_PASSWORD env var must be set".into(), + }])))?; Ok(ConnectionConfig { url, @@ -259,7 +278,7 @@ impl ClickhouseConnectorSetup { config: &ServerConfigFile, file_path: &Path, node_path: &[&str], - ) -> Result>, ParseError> { + ) -> Result>, ParseError> { let get_node_path = |extra_segments: &[&str]| { node_path .iter() @@ -333,25 +352,24 @@ impl ClickhouseConnectorSetup { } } ReturnType::Definition { columns } => Ok(Some( - columns - .iter() - .map(|(field_alias, field_type)| { - let data_type = ClickHouseDataType::from_str(field_type).map_err(|err| { - ParseError::ValidateError(InvalidNodes(vec![InvalidNode { - file_path: file_path.to_path_buf(), - node_path: get_node_path(&["columns", field_alias]), - message: format!( - "Unable to parse data type \"{}\": {}", - field_type, err - ), - }])) - })?; - Ok((field_alias.to_owned(), data_type)) - }) - .collect::, ParseError>>()? - - )) + .iter() + .map(|(field_alias, field_type)| { + let data_type = + ClickHouseDataType::from_str(field_type).map_err(|err| { + ParseError::ValidateError(InvalidNodes(vec![InvalidNode { + file_path: file_path.to_path_buf(), + node_path: get_node_path(&["columns", field_alias.inner()]), + message: format!( + "Unable to parse data type \"{}\": {}", + field_type, err + ), + }])) + })?; + Ok((field_alias.to_owned(), data_type)) + }) + .collect::, ParseError>>()?, + )), } } } diff --git a/crates/ndc-clickhouse/src/connector/state.rs b/crates/ndc-clickhouse/src/connector/state.rs index 9d114b4..41d341e 100644 --- a/crates/ndc-clickhouse/src/connector/state.rs +++ b/crates/ndc-clickhouse/src/connector/state.rs @@ -1,6 +1,5 @@ -use std::{error::Error, sync::Arc}; - use common::{client::get_http_client, config::ServerConfig}; +use std::sync::Arc; use tokio::sync::RwLock; #[derive(Debug, Clone)] @@ -17,7 +16,7 @@ impl ServerState { client: Arc::new(RwLock::new(client)), } } - pub async fn client(&self, config: &ServerConfig) -> Result> { + pub async fn client(&self, config: &ServerConfig) -> Result { if let Some(client) = &*self.client.read().await { Ok(client.clone()) } else { diff --git a/crates/ndc-clickhouse/src/lib.rs b/crates/ndc-clickhouse/src/lib.rs index 3e7192a..63cc8fe 100644 --- a/crates/ndc-clickhouse/src/lib.rs +++ b/crates/ndc-clickhouse/src/lib.rs @@ -1,3 +1,2 @@ pub mod connector; -pub mod schema; pub mod sql; diff --git a/crates/ndc-clickhouse/src/main.rs b/crates/ndc-clickhouse/src/main.rs index 5920887..2b64860 100644 --- a/crates/ndc-clickhouse/src/main.rs +++ b/crates/ndc-clickhouse/src/main.rs @@ -1,9 +1,7 @@ use ndc_clickhouse::connector::setup::ClickhouseConnectorSetup; -use ndc_sdk::default_main::default_main; - -use std::error::Error; +use ndc_sdk::{connector::ErrorResponse, default_main::default_main}; #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> Result<(), ErrorResponse> { default_main::().await } diff --git a/crates/ndc-clickhouse/src/schema.rs b/crates/ndc-clickhouse/src/schema.rs deleted file mode 100644 index 817a905..0000000 --- a/crates/ndc-clickhouse/src/schema.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod binary_comparison_operator; -mod single_column_aggregate_function; -mod type_definition; - -pub use binary_comparison_operator::*; -pub use single_column_aggregate_function::*; -pub use type_definition::*; diff --git a/crates/ndc-clickhouse/src/schema/binary_comparison_operator.rs b/crates/ndc-clickhouse/src/schema/binary_comparison_operator.rs deleted file mode 100644 index 75b1d2e..0000000 --- a/crates/ndc-clickhouse/src/schema/binary_comparison_operator.rs +++ /dev/null @@ -1,67 +0,0 @@ -use strum::{Display, EnumIter, EnumString}; - -use crate::sql::ast::{BinaryOperator, Expr, Function}; - -#[derive(Debug, Clone, EnumString, Display, EnumIter)] -pub enum ClickHouseBinaryComparisonOperator { - #[strum(to_string = "_eq")] - Eq, - #[strum(to_string = "_gt")] - Gt, - #[strum(to_string = "_lt")] - Lt, - #[strum(to_string = "_gte")] - GtEq, - #[strum(to_string = "_lte")] - LtEq, - #[strum(to_string = "_neq")] - NotEq, - #[strum(to_string = "_like")] - Like, - #[strum(to_string = "_nlike")] - NotLike, - #[strum(to_string = "_ilike")] - ILike, - #[strum(to_string = "_nilike")] - NotILike, - #[strum(to_string = "_in")] - In, - #[strum(to_string = "_nin")] - NotIn, - #[strum(to_string = "_match")] - Match, -} - -impl ClickHouseBinaryComparisonOperator { - pub fn apply(&self, left: Expr, right: Expr) -> Expr { - fn apply_operator(op: BinaryOperator, left: Expr, right: Expr) -> Expr { - Expr::BinaryOp { - left: left.into_box(), - op, - right: right.into_box(), - } - } - fn apply_function(name: &str, left: Expr, right: Expr) -> Expr { - Function::new_unquoted(name) - .args(vec![left.into_arg(), right.into_arg()]) - .into_expr() - } - use ClickHouseBinaryComparisonOperator as CBO; - - match self { - CBO::Eq => apply_operator(BinaryOperator::Eq, left, right), - CBO::Gt => apply_operator(BinaryOperator::Gt, left, right), - CBO::Lt => apply_operator(BinaryOperator::Lt, left, right), - CBO::GtEq => apply_operator(BinaryOperator::GtEq, left, right), - CBO::LtEq => apply_operator(BinaryOperator::LtEq, left, right), - CBO::NotEq => apply_operator(BinaryOperator::NotEq, left, right), - CBO::Like => apply_operator(BinaryOperator::Like, left, right), - CBO::NotLike => apply_operator(BinaryOperator::NotLike, left, right), - CBO::ILike => apply_operator(BinaryOperator::ILike, left, right), - CBO::NotILike => apply_operator(BinaryOperator::NotILike, left, right), - CBO::In => apply_operator(BinaryOperator::In, left, right), - CBO::NotIn => apply_operator(BinaryOperator::NotIn, left, right), - CBO::Match => apply_function("match", left, right), - } - } -} diff --git a/crates/ndc-clickhouse/src/schema/single_column_aggregate_function.rs b/crates/ndc-clickhouse/src/schema/single_column_aggregate_function.rs deleted file mode 100644 index 3a13ced..0000000 --- a/crates/ndc-clickhouse/src/schema/single_column_aggregate_function.rs +++ /dev/null @@ -1,37 +0,0 @@ -use strum::{Display, EnumIter, EnumString}; - -use crate::sql::ast::{Expr, Function}; - -#[derive(Debug, Clone, EnumString, Display, EnumIter, PartialEq, Eq)] -#[strum(serialize_all = "snake_case")] -pub enum ClickHouseSingleColumnAggregateFunction { - Max, - Min, - Sum, - Avg, - StddevPop, - StddevSamp, - VarPop, - VarSamp, -} - -impl ClickHouseSingleColumnAggregateFunction { - pub fn as_expr(&self, column: Expr) -> Expr { - use ClickHouseSingleColumnAggregateFunction::*; - let sql_fn = |name: &str, arg: Expr| { - Function::new_unquoted(name) - .args(vec![arg.into_arg()]) - .into_expr() - }; - match self { - Max => sql_fn("max", column), - Min => sql_fn("min", column), - Sum => sql_fn("sum", column), - Avg => sql_fn("avg", column), - StddevPop => sql_fn("stddevPop", column), - StddevSamp => sql_fn("stddevSamp", column), - VarPop => sql_fn("varPop", column), - VarSamp => sql_fn("varSamp", column), - } - } -} diff --git a/crates/ndc-clickhouse/src/sql/query_builder.rs b/crates/ndc-clickhouse/src/sql/query_builder.rs index 8f026fd..9c32138 100644 --- a/crates/ndc-clickhouse/src/sql/query_builder.rs +++ b/crates/ndc-clickhouse/src/sql/query_builder.rs @@ -1,25 +1,32 @@ +mod binary_comparison_expression; mod collection_context; mod comparison_column; mod error; +mod function_expression; pub mod parameter; mod typecasting; - use self::{collection_context::CollectionContext, typecasting::RowsetTypeString}; use super::ast::*; -use crate::schema::{ - ClickHouseBinaryComparisonOperator, ClickHouseSingleColumnAggregateFunction, - ClickHouseTypeDefinition, -}; +use binary_comparison_expression::apply_binary_operator; use common::{ clickhouse_parser::{ datatype::ClickHouseDataType, parameterized_query::ParameterizedQueryElement, }, config::ServerConfig, + schema::{ + binary_comparison_operator::ClickHouseBinaryComparisonOperator, + single_column_aggregate_function::ClickHouseSingleColumnAggregateFunction, + type_definition::ClickHouseTypeDefinition, + }, }; use comparison_column::ComparisonColumn; pub use error::QueryBuilderError; +use function_expression::apply_function; use indexmap::IndexMap; -use ndc_sdk::models; +use ndc_sdk::models::{ + self, AggregateFunctionName, ArgumentName, CollectionName, FieldName, ObjectTypeName, + RelationshipName, VariableName, +}; use parameter::ParameterBuilder; use std::{collections::BTreeMap, iter, str::FromStr}; @@ -175,7 +182,7 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { fn rowset_subquery( &self, current_collection: &CollectionContext, - relkeys: &Vec<&String>, + relkeys: &Vec<&FieldName>, query: &models::Query, parameters: &mut ParameterBuilder, ) -> Result { @@ -239,7 +246,7 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { Ident::new_quoted("_row"), Ident::new_quoted(format!("_agg_{alias}")), ]); - aggregate_function(function)?.as_expr(column) + apply_function(&aggregate_function(function)?, column) } } .into_arg()) @@ -297,7 +304,7 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { fn row_subquery( &self, current_collection: &CollectionContext, - relkeys: &Vec<&String>, + relkeys: &Vec<&FieldName>, query: &models::Query, parameters: &mut ParameterBuilder, ) -> Result { @@ -332,10 +339,12 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { arguments: _, } => { let data_type = self.column_data_type(column, current_collection)?; + let return_type = + get_return_type(current_collection.alias(), self.configuration)?; let column_definition = ClickHouseTypeDefinition::from_table_column( &data_type, column, - current_collection.alias(), + return_type, &self.configuration.namespace_separator, ); @@ -743,8 +752,7 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { self.column_ident(column), ]); select.push( - aggregate_function(function)? - .as_expr(column) + apply_function(&aggregate_function(function)?, column) .into_select(Some("_order_by_value")), ); } @@ -851,12 +859,12 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { #[allow(clippy::too_many_arguments)] fn field_relationship( &self, - field_alias: &str, + field_alias: &FieldName, name_index: &mut u32, target_path: &[Ident], query: &models::Query, - relationship: &str, - arguments: &BTreeMap, + relationship: &RelationshipName, + arguments: &BTreeMap, parameters: &mut ParameterBuilder, ) -> Result<(Expr, Join), QueryBuilderError> { let join_alias = format!("_rel_{name_index}_{field_alias}"); @@ -874,7 +882,7 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { target_path .iter() .cloned() - .chain(iter::once(Ident::new_quoted(source_col))) + .chain(iter::once(Ident::new_quoted(source_col.to_string()))) .collect(), ) .into_box(), @@ -1041,8 +1049,8 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { operator, value, } => { - let operator = - ClickHouseBinaryComparisonOperator::from_str(operator).map_err(|_err| { + let operator = ClickHouseBinaryComparisonOperator::from_str(operator.inner()) + .map_err(|_err| { QueryBuilderError::UnknownBinaryComparisonOperator(operator.to_owned()) })?; @@ -1097,7 +1105,7 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { let (expression, expression_joins) = right_col.apply(|right_col| { left_col.apply(|left_col| { - let expression = operator.apply(left_col, right_col); + let expression = apply_binary_operator(&operator, left_col, right_col); (expression, vec![]) }) }); @@ -1140,6 +1148,15 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { collection, arguments, } => CollectionContext::new_unrelated(collection, arguments), + models::ExistsInCollection::NestedCollection { + column_name: _, + arguments: _, + field_path: _, + } => { + return Err(QueryBuilderError::NotSupported( + "Nested Collection exists".to_string(), + )) + } }; let subquery_origin_alias = Ident::new_quoted(format!("_exists_{}", name_index)); @@ -1268,6 +1285,15 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { collection: _, arguments: _, } => vec![], + models::ExistsInCollection::NestedCollection { + column_name: _, + arguments: _, + field_path: _, + } => { + return Err(QueryBuilderError::NotSupported( + "Nested Collection exists".to_string(), + )) + } }; if self.request.variables.is_some() { @@ -1715,13 +1741,13 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { } fn collection_relationship( &self, - relationship: &str, + relationship: &RelationshipName, ) -> Result<&models::Relationship, QueryBuilderError> { self.request .collection_relationships .get(relationship) .ok_or(QueryBuilderError::MissingRelationship( - relationship.to_string(), + relationship.to_owned(), )) } fn collection_ident( @@ -1730,7 +1756,7 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { parameters: &mut ParameterBuilder, ) -> Result { if let Some(table) = self.configuration.tables.get(collection.alias()) { - let table_argument_type = |argument_name: &str| { + let table_argument_type = |argument_name: &ArgumentName| { table.arguments.get(argument_name).ok_or_else(|| { QueryBuilderError::UnknownTableArgument { table: collection.alias().to_owned(), @@ -1738,13 +1764,14 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { } }) }; - let variable_argument = |arg_name: &String, variable_name: &String| { + let variable_argument = |arg_name: &ArgumentName, variable_name: &VariableName| { let argument_type = table_argument_type(arg_name)?; let column_ident = Expr::CompoundIdentifier(vec![ Ident::new_quoted("_vars"), Ident::new_quoted(format!("_var_{variable_name}")), ]); + // todo: review whether this is actually needed now, given we now have proper serialization of parameters. I think this is unrelated. let column_ident = if is_uuid(argument_type) { Function::new_unquoted("toUUID") .args(vec![column_ident.into_arg()]) @@ -1752,13 +1779,15 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { } else { column_ident }; - Ok(column_ident.into_arg().name(Ident::new_quoted(arg_name))) + Ok(column_ident + .into_arg() + .name(Ident::new_quoted(arg_name.to_string()))) }; - let mut literal_argument = |arg_name: &String, value: &serde_json::Value| { + let mut literal_argument = |arg_name: &ArgumentName, value: &serde_json::Value| { Ok(parameters .bind_json(value, table_argument_type(arg_name)?.to_owned().into())? .into_arg() - .name(Ident::new_quoted(arg_name))) + .name(Ident::new_quoted(arg_name.to_string()))) }; let table_name = ObjectName(vec![ Ident::new_quoted(&table.schema), @@ -1887,7 +1916,7 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { .transpose()? .ok_or_else(|| QueryBuilderError::MissingNativeQueryArgument { query: collection.alias().to_owned(), - argument: p.name.value().to_owned(), + argument: p.name.value().to_owned().into(), }) .and_then(|value| { Ok(NativeQueryElement::Expr( @@ -1904,12 +1933,12 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { )) } } - fn column_ident(&self, column_alias: &str) -> Ident { - Ident::new_quoted(column_alias) + fn column_ident(&self, column_alias: &FieldName) -> Ident { + Ident::new_quoted(column_alias.to_string()) } fn column_data_type( &self, - column_alias: &str, + column_alias: &FieldName, collection: &CollectionContext, ) -> Result { let return_type = self @@ -1932,7 +1961,7 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { .ok_or_else(|| QueryBuilderError::UnknownTableType(return_type.to_owned()))?; let column_type = table_type.columns.get(column_alias).ok_or_else(|| { - QueryBuilderError::UnknownColumn(column_alias.to_owned(), collection.alias().to_owned()) + QueryBuilderError::UnknownColumn(column_alias.to_owned(), return_type.to_owned()) })?; Ok(column_type.to_owned()) @@ -1996,11 +2025,11 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { } }; - let chain_ident = |i: &str| -> Vec { + let chain_ident = |i: &FieldName| -> Vec { column_ident .clone() .into_iter() - .chain(iter::once(Ident::new_quoted(i))) + .chain(iter::once(Ident::new_quoted(i.to_string()))) .collect() }; @@ -2021,7 +2050,7 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { object_type_fields.get(column).ok_or_else(|| { QueryBuilderError::UnknownSubField { field_name: column.to_owned(), - data_type: type_definition.cast_type().to_string(), + data_type: type_definition.cast_type(), } })?; @@ -2094,11 +2123,28 @@ impl<'r, 'c> QueryBuilder<'r, 'c> { } } +fn get_return_type<'a>( + table_alias: &CollectionName, + config: &'a ServerConfig, +) -> Result<&'a ObjectTypeName, QueryBuilderError> { + config + .tables + .get(table_alias) + .map(|table| &table.return_type) + .or_else(|| { + config + .queries + .get(table_alias) + .map(|query| &query.return_type) + }) + .ok_or_else(|| QueryBuilderError::UnknownTable(table_alias.to_owned())) +} + fn aggregate_function( - name: &str, + name: &AggregateFunctionName, ) -> Result { - ClickHouseSingleColumnAggregateFunction::from_str(name) - .map_err(|_err| QueryBuilderError::UnknownSingleColumnAggregateFunction(name.to_string())) + ClickHouseSingleColumnAggregateFunction::from_str(name.inner()) + .map_err(|_err| QueryBuilderError::UnknownSingleColumnAggregateFunction(name.to_owned())) } fn and_reducer(left: Expr, right: Expr) -> Expr { diff --git a/crates/ndc-clickhouse/src/sql/query_builder/binary_comparison_expression.rs b/crates/ndc-clickhouse/src/sql/query_builder/binary_comparison_expression.rs new file mode 100644 index 0000000..42cb232 --- /dev/null +++ b/crates/ndc-clickhouse/src/sql/query_builder/binary_comparison_expression.rs @@ -0,0 +1,38 @@ +use crate::sql::ast::{BinaryOperator, Expr, Function}; +use common::schema::binary_comparison_operator::ClickHouseBinaryComparisonOperator; + +pub fn apply_binary_operator( + operator: &ClickHouseBinaryComparisonOperator, + left: Expr, + right: Expr, +) -> Expr { + fn apply_operator(op: BinaryOperator, left: Expr, right: Expr) -> Expr { + Expr::BinaryOp { + left: left.into_box(), + op, + right: right.into_box(), + } + } + fn apply_function(name: &str, left: Expr, right: Expr) -> Expr { + Function::new_unquoted(name) + .args(vec![left.into_arg(), right.into_arg()]) + .into_expr() + } + use ClickHouseBinaryComparisonOperator as CBO; + + match operator { + CBO::Eq => apply_operator(BinaryOperator::Eq, left, right), + CBO::Gt => apply_operator(BinaryOperator::Gt, left, right), + CBO::Lt => apply_operator(BinaryOperator::Lt, left, right), + CBO::GtEq => apply_operator(BinaryOperator::GtEq, left, right), + CBO::LtEq => apply_operator(BinaryOperator::LtEq, left, right), + CBO::NotEq => apply_operator(BinaryOperator::NotEq, left, right), + CBO::Like => apply_operator(BinaryOperator::Like, left, right), + CBO::NotLike => apply_operator(BinaryOperator::NotLike, left, right), + CBO::ILike => apply_operator(BinaryOperator::ILike, left, right), + CBO::NotILike => apply_operator(BinaryOperator::NotILike, left, right), + CBO::In => apply_operator(BinaryOperator::In, left, right), + CBO::NotIn => apply_operator(BinaryOperator::NotIn, left, right), + CBO::Match => apply_function("match", left, right), + } +} diff --git a/crates/ndc-clickhouse/src/sql/query_builder/collection_context.rs b/crates/ndc-clickhouse/src/sql/query_builder/collection_context.rs index da0c1a8..e3b9a13 100644 --- a/crates/ndc-clickhouse/src/sql/query_builder/collection_context.rs +++ b/crates/ndc-clickhouse/src/sql/query_builder/collection_context.rs @@ -1,34 +1,37 @@ use std::collections::BTreeMap; -use ndc_sdk::models::{Argument, Relationship, RelationshipArgument}; +use ndc_sdk::models::{Argument, ArgumentName, CollectionName, Relationship, RelationshipArgument}; #[derive(Debug, Clone)] pub enum CollectionContext<'a, 'b> { Base { - collection_alias: &'a str, - arguments: &'b BTreeMap, + collection_alias: &'a CollectionName, + arguments: &'b BTreeMap, }, Relationship { - collection_alias: &'a str, - arguments: &'b BTreeMap, - relationship_arguments: &'a BTreeMap, + collection_alias: &'a CollectionName, + arguments: &'b BTreeMap, + relationship_arguments: &'a BTreeMap, }, UnrelatedRelationship { - collection_alias: &'a str, - arguments: &'b BTreeMap, + collection_alias: &'a CollectionName, + arguments: &'b BTreeMap, }, } impl<'a, 'b> CollectionContext<'a, 'b> { - pub fn new(collection_alias: &'a str, arguments: &'b BTreeMap) -> Self { + pub fn new( + collection_alias: &'a CollectionName, + arguments: &'b BTreeMap, + ) -> Self { Self::Base { collection_alias, arguments, } } pub fn new_unrelated( - collection_alias: &'a str, - arguments: &'b BTreeMap, + collection_alias: &'a CollectionName, + arguments: &'b BTreeMap, ) -> Self { Self::UnrelatedRelationship { collection_alias, @@ -37,7 +40,7 @@ impl<'a, 'b> CollectionContext<'a, 'b> { } pub fn from_relationship( relationship: &'a Relationship, - arguments: &'b BTreeMap, + arguments: &'b BTreeMap, ) -> Self { Self::Relationship { collection_alias: &relationship.target_collection, @@ -45,7 +48,7 @@ impl<'a, 'b> CollectionContext<'a, 'b> { arguments, } } - pub fn alias(&self) -> &str { + pub fn alias(&self) -> &CollectionName { match self { CollectionContext::Base { collection_alias, .. diff --git a/crates/ndc-clickhouse/src/sql/query_builder/error.rs b/crates/ndc-clickhouse/src/sql/query_builder/error.rs index 3a281f6..78783f8 100644 --- a/crates/ndc-clickhouse/src/sql/query_builder/error.rs +++ b/crates/ndc-clickhouse/src/sql/query_builder/error.rs @@ -1,36 +1,51 @@ -use common::clickhouse_parser::parameterized_query::ParameterType; -use ndc_sdk::connector::{ExplainError, QueryError}; -use std::fmt; - use super::typecasting::TypeStringError; +use common::clickhouse_parser::{datatype::ClickHouseDataType, parameterized_query::ParameterType}; +use http::StatusCode; +use ndc_sdk::{ + connector::ErrorResponse, + models::{ + AggregateFunctionName, ArgumentName, CollectionName, ComparisonOperatorName, FieldName, + ObjectTypeName, RelationshipName, + }, +}; +use std::fmt; #[derive(Debug, PartialEq)] pub enum QueryBuilderError { /// A relationship referenced in the query is missing from the collection_relationships map - MissingRelationship(String), + MissingRelationship(RelationshipName), /// An argument required for a native query was not supplied - MissingNativeQueryArgument { query: String, argument: String }, + MissingNativeQueryArgument { + query: CollectionName, + argument: ArgumentName, + }, /// A table was referenced but not found in configuration - UnknownTable(String), + UnknownTable(CollectionName), /// An argument was supplied for a table that does not have that argument - UnknownTableArgument { table: String, argument: String }, + UnknownTableArgument { + table: CollectionName, + argument: ArgumentName, + }, /// An argument was supplied for a table that does not have that argument - UnknownQueryArgument { query: String, argument: String }, + UnknownQueryArgument { + query: CollectionName, + argument: ArgumentName, + }, /// A table in configuration referenced a table type that could not be found - UnknownTableType(String), + UnknownTableType(ObjectTypeName), /// A column was referenced but not found in configuration - UnknownColumn(String, String), + UnknownColumn(FieldName, ObjectTypeName), /// A field was referenced but not found in configuration UnknownSubField { - field_name: String, - data_type: String, + field_name: FieldName, + data_type: ClickHouseDataType, }, /// Unable to serialize variables into a json string CannotSerializeVariables(String), /// An unknown single column aggregate function was referenced - UnknownSingleColumnAggregateFunction(String), + UnknownSingleColumnAggregateFunction(AggregateFunctionName), /// An unknown binary comparison operator was referenced - UnknownBinaryComparisonOperator(String), + UnknownBinaryComparisonOperator(ComparisonOperatorName), /// A feature is not supported NotSupported(String), /// An error that should never happen, and indicates a bug if triggered @@ -137,7 +152,7 @@ impl fmt::Display for QueryBuilderError { impl std::error::Error for QueryBuilderError {} -impl From for QueryError { +impl From for ErrorResponse { fn from(value: QueryBuilderError) -> Self { match value { QueryBuilderError::MissingRelationship(_) @@ -157,40 +172,21 @@ impl From for QueryError { | QueryBuilderError::ExpectedAnonymousTuple { .. } | QueryBuilderError::ExpectedNamedTuple { .. } | QueryBuilderError::MissingNamedField { .. } - | QueryBuilderError::TupleLengthMismatch { .. } => { - QueryError::new_invalid_request(&value) - } - QueryBuilderError::NotSupported(_) => QueryError::new_unsupported_operation(&value), - QueryBuilderError::Unexpected(_) => QueryError::new(value), - } - } -} - -impl From for ExplainError { - fn from(value: QueryBuilderError) -> Self { - match value { - QueryBuilderError::MissingRelationship(_) - | QueryBuilderError::MissingNativeQueryArgument { .. } - | QueryBuilderError::UnknownTable(_) - | QueryBuilderError::UnknownTableArgument { .. } - | QueryBuilderError::UnknownQueryArgument { .. } - | QueryBuilderError::UnknownTableType(_) - | QueryBuilderError::UnknownColumn(_, _) - | QueryBuilderError::UnknownSubField { .. } - | QueryBuilderError::CannotSerializeVariables(_) - | QueryBuilderError::UnknownSingleColumnAggregateFunction(_) - | QueryBuilderError::UnknownBinaryComparisonOperator(_) - | QueryBuilderError::Typecasting(_) - | QueryBuilderError::ColumnTypeMismatch { .. } - | QueryBuilderError::UnsupportedParameterCast { .. } - | QueryBuilderError::ExpectedAnonymousTuple { .. } - | QueryBuilderError::ExpectedNamedTuple { .. } - | QueryBuilderError::MissingNamedField { .. } - | QueryBuilderError::TupleLengthMismatch { .. } => { - ExplainError::new_invalid_request(&value) - } - QueryBuilderError::NotSupported(_) => ExplainError::new_unsupported_operation(&value), - QueryBuilderError::Unexpected(_) => ExplainError::new(Box::new(value)), + | QueryBuilderError::TupleLengthMismatch { .. } => ErrorResponse::new( + StatusCode::BAD_REQUEST, + value.to_string(), + serde_json::Value::Null, + ), + QueryBuilderError::NotSupported(_) => ErrorResponse::new( + StatusCode::NOT_IMPLEMENTED, + value.to_string(), + serde_json::Value::Null, + ), + QueryBuilderError::Unexpected(_) => ErrorResponse::new( + StatusCode::INTERNAL_SERVER_ERROR, + value.to_string(), + serde_json::Value::Null, + ), } } } diff --git a/crates/ndc-clickhouse/src/sql/query_builder/function_expression.rs b/crates/ndc-clickhouse/src/sql/query_builder/function_expression.rs new file mode 100644 index 0000000..70f739d --- /dev/null +++ b/crates/ndc-clickhouse/src/sql/query_builder/function_expression.rs @@ -0,0 +1,21 @@ +use crate::sql::ast::{Expr, Function}; +use common::schema::single_column_aggregate_function::ClickHouseSingleColumnAggregateFunction; + +pub fn apply_function(function: &ClickHouseSingleColumnAggregateFunction, column: Expr) -> Expr { + use ClickHouseSingleColumnAggregateFunction::*; + let sql_fn = |name: &str, arg: Expr| { + Function::new_unquoted(name) + .args(vec![arg.into_arg()]) + .into_expr() + }; + match function { + Max => sql_fn("max", column), + Min => sql_fn("min", column), + Sum => sql_fn("sum", column), + Avg => sql_fn("avg", column), + StddevPop => sql_fn("stddevPop", column), + StddevSamp => sql_fn("stddevSamp", column), + VarPop => sql_fn("varPop", column), + VarSamp => sql_fn("varSamp", column), + } +} diff --git a/crates/ndc-clickhouse/src/sql/query_builder/parameter.rs b/crates/ndc-clickhouse/src/sql/query_builder/parameter.rs index de42d5f..f5d84a8 100644 --- a/crates/ndc-clickhouse/src/sql/query_builder/parameter.rs +++ b/crates/ndc-clickhouse/src/sql/query_builder/parameter.rs @@ -148,7 +148,7 @@ mod tests { for (value, data_type, printed) in test_cases { let data_type = - ClickHouseDataType::from_str(&data_type).expect("Should parse data type"); + ClickHouseDataType::from_str(data_type).expect("Should parse data type"); let value = Value::try_from_json(&value, &data_type) .expect("Should convert type based on data type"); diff --git a/crates/ndc-clickhouse/src/sql/query_builder/typecasting.rs b/crates/ndc-clickhouse/src/sql/query_builder/typecasting.rs index edb7b06..cb0c85b 100644 --- a/crates/ndc-clickhouse/src/sql/query_builder/typecasting.rs +++ b/crates/ndc-clickhouse/src/sql/query_builder/typecasting.rs @@ -3,11 +3,16 @@ use std::{collections::BTreeMap, fmt::Display, str::FromStr}; use common::{ clickhouse_parser::datatype::{ClickHouseDataType, Identifier}, config::ServerConfig, + schema::{ + single_column_aggregate_function::ClickHouseSingleColumnAggregateFunction, + type_definition::ClickHouseTypeDefinition, + }, }; use indexmap::IndexMap; -use ndc_sdk::models::{self, NestedField}; - -use crate::schema::{ClickHouseSingleColumnAggregateFunction, ClickHouseTypeDefinition}; +use ndc_sdk::models::{ + self, AggregateFunctionName, CollectionName, FieldName, NestedField, ObjectTypeName, + RelationshipName, +}; use super::QueryBuilderError; @@ -18,24 +23,24 @@ pub struct RowsetTypeString { } /// Tuple("a1" T1, "a2" T2) pub struct AggregatesTypeString { - aggregates: Vec<(String, ClickHouseDataType)>, + aggregates: Vec<(FieldName, ClickHouseDataType)>, } /// Tuple("f1" T1, "f2" ) pub struct RowTypeString { - fields: Vec<(String, FieldTypeString)>, + fields: Vec<(FieldName, FieldTypeString)>, } pub enum FieldTypeString { Relationship(RowsetTypeString), Array(Box), - Object(Vec<(String, FieldTypeString)>), + Object(Vec<(FieldName, FieldTypeString)>), Scalar(ClickHouseDataType), } impl RowsetTypeString { pub fn new( - table_alias: &str, + table_alias: &CollectionName, query: &models::Query, - relationships: &BTreeMap, + relationships: &BTreeMap, config: &ServerConfig, ) -> Result { let rows = if let Some(fields) = &query.fields { @@ -86,8 +91,8 @@ impl RowsetTypeString { impl AggregatesTypeString { fn new( - table_alias: &str, - aggregates: &IndexMap, + table_alias: &CollectionName, + aggregates: &IndexMap, config: &ServerConfig, ) -> Result { Ok(Self { @@ -95,30 +100,30 @@ impl AggregatesTypeString { .iter() .map(|(alias, aggregate)| match aggregate { models::Aggregate::StarCount {} | models::Aggregate::ColumnCount { .. } => { - Ok((alias.to_string(), ClickHouseDataType::UInt32)) + Ok((alias.to_owned(), ClickHouseDataType::UInt32)) } models::Aggregate::SingleColumn { column: column_alias, function, field_path: _, } => { - let column_type = get_column(column_alias, table_alias, config)?; + let return_type = get_return_type(table_alias, config)?; + let column_type = get_column(column_alias, return_type, config)?; let type_definition = ClickHouseTypeDefinition::from_table_column( column_type, column_alias, - table_alias, + return_type, &config.namespace_separator, ); let aggregate_function = - ClickHouseSingleColumnAggregateFunction::from_str(function).map_err( - |_err| TypeStringError::UnknownAggregateFunction { + ClickHouseSingleColumnAggregateFunction::from_str(function.inner()) + .map_err(|_err| TypeStringError::UnknownAggregateFunction { table: table_alias.to_owned(), column: column_alias.to_owned(), data_type: column_type.to_owned(), function: function.to_owned(), - }, - )?; + })?; let aggregate_functions = type_definition.aggregate_functions(); @@ -149,7 +154,7 @@ impl AggregatesTypeString { ClickHouseDataType::Tuple( self.aggregates .into_iter() - .map(|(alias, t)| (Some(Identifier::DoubleQuoted(alias)), t)) + .map(|(alias, t)| (Some(Identifier::DoubleQuoted(alias.into())), t)) .collect(), ) } @@ -158,9 +163,9 @@ impl AggregatesTypeString { impl RowTypeString { fn new( - table_alias: &str, - fields: &IndexMap, - relationships: &BTreeMap, + table_alias: &CollectionName, + fields: &IndexMap, + relationships: &BTreeMap, config: &ServerConfig, ) -> Result { Ok(Self { @@ -168,18 +173,19 @@ impl RowTypeString { .iter() .map(|(alias, field)| { Ok(( - alias.to_string(), + alias.to_owned(), match field { models::Field::Column { column: column_alias, fields, arguments: _, } => { - let column_type = get_column(column_alias, table_alias, config)?; + let return_type = get_return_type(table_alias, config)?; + let column_type = get_column(column_alias, return_type, config)?; let type_definition = ClickHouseTypeDefinition::from_table_column( column_type, column_alias, - table_alias, + return_type, &config.namespace_separator, ); @@ -229,7 +235,7 @@ impl RowTypeString { .into_iter() .map(|(alias, field)| { ( - Some(Identifier::DoubleQuoted(alias)), + Some(Identifier::DoubleQuoted(alias.into())), field.into_cast_type(), ) }) @@ -243,7 +249,7 @@ impl FieldTypeString { fn new( type_definition: &ClickHouseTypeDefinition, fields: Option<&NestedField>, - relationships: &BTreeMap, + relationships: &BTreeMap, config: &ServerConfig, ) -> Result { if let Some(fields) = fields { @@ -275,7 +281,10 @@ impl FieldTypeString { let type_definition = fields.get(column).ok_or_else(|| { TypeStringError::MissingNestedField { field_name: column.to_owned(), - object_type: type_definition.cast_type().to_string(), + object_type: type_definition + .cast_type() + .to_string() + .into(), } })?; @@ -371,7 +380,7 @@ impl FieldTypeString { .into_iter() .map(|(alias, field)| { ( - Some(Identifier::DoubleQuoted(alias)), + Some(Identifier::DoubleQuoted(alias.into())), field.into_cast_type(), ) }) @@ -383,24 +392,10 @@ impl FieldTypeString { } fn get_column<'a>( - column_alias: &str, - table_alias: &str, + column_alias: &FieldName, + return_type: &ObjectTypeName, config: &'a ServerConfig, ) -> Result<&'a ClickHouseDataType, TypeStringError> { - let return_type = config - .tables - .get(table_alias) - .map(|table| &table.return_type) - .or_else(|| { - config - .queries - .get(table_alias) - .map(|query| &query.return_type) - }) - .ok_or_else(|| TypeStringError::UnknownTable { - table: table_alias.to_owned(), - })?; - let table_type = config .table_types @@ -414,40 +409,59 @@ fn get_column<'a>( .columns .get(column_alias) .ok_or_else(|| TypeStringError::UnknownColumn { - table: table_alias.to_owned(), + table: return_type.to_owned(), column: column_alias.to_owned(), })?; Ok(column) } +fn get_return_type<'a>( + table_alias: &CollectionName, + config: &'a ServerConfig, +) -> Result<&'a ObjectTypeName, TypeStringError> { + config + .tables + .get(table_alias) + .map(|table| &table.return_type) + .or_else(|| { + config + .queries + .get(table_alias) + .map(|query| &query.return_type) + }) + .ok_or_else(|| TypeStringError::UnknownTable { + table: table_alias.to_owned(), + }) +} + #[derive(Debug, PartialEq)] pub enum TypeStringError { UnknownTable { - table: String, + table: CollectionName, }, UnknownTableType { - table: String, + table: ObjectTypeName, }, UnknownColumn { - table: String, - column: String, + table: ObjectTypeName, + column: FieldName, }, UnknownAggregateFunction { - table: String, - column: String, + table: CollectionName, + column: FieldName, data_type: ClickHouseDataType, - function: String, + function: AggregateFunctionName, }, - MissingRelationship(String), + MissingRelationship(RelationshipName), NotSupported(String), NestedFieldTypeMismatch { expected: String, got: String, }, MissingNestedField { - field_name: String, - object_type: String, + field_name: FieldName, + object_type: ObjectTypeName, }, } diff --git a/crates/ndc-clickhouse/tests/capabilities.rs b/crates/ndc-clickhouse/tests/capabilities.rs deleted file mode 100644 index d700a93..0000000 --- a/crates/ndc-clickhouse/tests/capabilities.rs +++ /dev/null @@ -1,42 +0,0 @@ -use ndc_clickhouse::connector::handler::capabilities; -use ndc_sdk::models::CapabilitiesResponse; -use std::path::PathBuf; -use tokio::fs; - -#[tokio::test] -async fn prints_expected_capabilities() { - let expected_capabilities_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests") - .join("capabilities") - .join("capabilities.json"); - let expected_capabilities_file = fs::read_to_string(expected_capabilities_path) - .await - .expect("Capabilities file should be present"); - let expected_capabilities: CapabilitiesResponse = - serde_json::from_str(&expected_capabilities_file) - .expect("Expected capabilities shoudl be valid capabilities response"); - - let capabilities = capabilities(); - - assert_eq!( - expected_capabilities, capabilities, - "Capabilities response should match snapshot" - ); -} - -#[tokio::test] -// update the expected capabilities. We only want thise called explicitly when capabilities have changed -#[ignore] -async fn update_expected_capabilities() { - let capabilities = serde_json::to_string_pretty(&capabilities()) - .expect("Capabilities should serialize to json"); - - let capabilities_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests") - .join("capabilities") - .join("capabilities.json"); - - fs::write(capabilities_path, capabilities) - .await - .expect("Should write out capabilities"); -} diff --git a/crates/ndc-clickhouse/tests/capabilities/capabilities.json b/crates/ndc-clickhouse/tests/capabilities/capabilities.json deleted file mode 100644 index 9cce6ea..0000000 --- a/crates/ndc-clickhouse/tests/capabilities/capabilities.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version": "0.1.4", - "capabilities": { - "query": { - "aggregates": {}, - "variables": {}, - "explain": {}, - "nested_fields": {} - }, - "mutation": {}, - "relationships": { - "relation_comparisons": {}, - "order_by_aggregate": {} - } - } -} \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder.rs b/crates/ndc-clickhouse/tests/query_builder.rs index b4a192a..ec746fe 100644 --- a/crates/ndc-clickhouse/tests/query_builder.rs +++ b/crates/ndc-clickhouse/tests/query_builder.rs @@ -1,249 +1,105 @@ -use common::config_file::ServerConfigFile; -use ndc_clickhouse::sql::QueryBuilderError; +use common::{config::ServerConfig, config_file::ServerConfigFile, schema::schema_response}; +use insta::{assert_snapshot, assert_yaml_snapshot, glob}; +use ndc_clickhouse::{connector::setup::ClickhouseConnectorSetup, sql::QueryBuilder}; use ndc_sdk::models; use schemars::schema_for; -use std::error::Error; -use tokio::fs; +use std::{collections::HashMap, error::Error, fs, path::PathBuf}; -mod test_utils { - use common::config::ServerConfig; - use ndc_clickhouse::{ - connector::{handler::schema_response, setup::ClickhouseConnectorSetup}, - sql::{QueryBuilder, QueryBuilderError}, - }; - use ndc_sdk::models::{self, SchemaResponse}; - use std::{collections::HashMap, env, error::Error, path::PathBuf}; - use tokio::fs; - - /// when running tests locally, this can be set to true to update reference files - /// this allows us to view diffs between commited samples and fresh samples - /// we don't want that behavior when running CI, so this value should be false in commited code - const UPDATE_SNAPSHOTS: bool = false; - - fn base_path(schema_dir: &str) -> PathBuf { - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests") - .join("query_builder") - .join(schema_dir) - } - fn tests_dir_path(schema_dir: &str, group_dir: &str) -> PathBuf { - base_path(schema_dir).join(group_dir) - } - fn config_dir_path(schema_dir: &str) -> PathBuf { - base_path(schema_dir).join("_config") - } - fn expected_schema_path(schema_dir: &str) -> PathBuf { - base_path(schema_dir).join("_schema").join("schema.json") - } - async fn read_mock_configuration(schema_dir: &str) -> Result> { - // set mock values for required env vars, we won't be reading these anyways - let env = HashMap::from_iter(vec![ - ("CLICKHOUSE_URL".to_owned(), "".to_owned()), - ("CLICKHOUSE_USERNAME".to_owned(), "".to_owned()), - ("CLICKHOUSE_PASSWORD".to_owned(), "".to_owned()), - ]); - let setup = ClickhouseConnectorSetup::new_from_env(env); - let config_dir = config_dir_path(schema_dir); - let configuration = setup.read_server_config(config_dir).await?; - Ok(configuration) - } - async fn read_request( - schema_dir: &str, - group_dir: &str, - test_name: &str, - ) -> Result> { - let request_path = - tests_dir_path(schema_dir, group_dir).join(format!("{test_name}.request.json")); - - let file_content = fs::read_to_string(request_path).await?; - let request: models::QueryRequest = serde_json::from_str(&file_content)?; - - Ok(request) - } - async fn read_expected_sql( - schema_dir: &str, - group_dir: &str, - test_name: &str, - ) -> Result> { - let statement_path = - tests_dir_path(schema_dir, group_dir).join(format!("{test_name}.statement.sql")); - let expected_statement = fs::read_to_string(&statement_path).await?; - Ok(expected_statement) - } - async fn read_expected_parameterized_sql( - schema_dir: &str, - group_dir: &str, - test_name: &str, - ) -> Result> { - let statement_path = tests_dir_path(schema_dir, group_dir) - .join(format!("{test_name}.parameterized_statement.sql")); - let expected_statement = fs::read_to_string(&statement_path).await?; - Ok(expected_statement) - } - async fn read_expected_parameters( - schema_dir: &str, - group_dir: &str, - test_name: &str, - ) -> Result> { - let parameters_path = - tests_dir_path(schema_dir, group_dir).join(format!("{test_name}.parameters.txt")); - let expected_parameters = fs::read_to_string(¶meters_path).await?; - Ok(expected_parameters) - } - async fn write_expected_sql( - schema_dir: &str, - group_dir: &str, - test_name: &str, - generated_statement: &str, - ) -> Result<(), Box> { - let statement_path = - tests_dir_path(schema_dir, group_dir).join(format!("{test_name}.statement.sql")); - fs::write(&statement_path, &generated_statement).await?; - Ok(()) - } - async fn write_expected_parameterized_sql( - schema_dir: &str, - group_dir: &str, - test_name: &str, - generated_statement: &str, - parameters: &str, - ) -> Result<(), Box> { - let statement_path = tests_dir_path(schema_dir, group_dir) - .join(format!("{test_name}.parameterized_statement.sql")); - let parameters_path = - tests_dir_path(schema_dir, group_dir).join(format!("{test_name}.parameters.txt")); - fs::write(&statement_path, &generated_statement).await?; - fs::write(¶meters_path, ¶meters).await?; - - Ok(()) - } - fn pretty_print_sql(query: &str) -> String { - use sqlformat::{format, FormatOptions, Indent, QueryParams}; - let params = QueryParams::None; - let options = FormatOptions { - indent: Indent::Spaces(2), - uppercase: false, - lines_between_queries: 1, - }; - - format(query, ¶ms, options) - } - fn generate_sql( - configuration: &ServerConfig, - request: &models::QueryRequest, - ) -> Result { - let generated_statement = pretty_print_sql( - &QueryBuilder::new(request, configuration) - .build_inlined()? - .to_string(), - ); - Ok(generated_statement) - } - fn generate_parameterized_sql( - configuration: &ServerConfig, - request: &models::QueryRequest, - ) -> Result<(String, String), QueryBuilderError> { - let (statement, parameters) = - QueryBuilder::new(request, configuration).build_parameterized()?; - let pretty_statement = pretty_print_sql(&statement.to_string()); - let printed_parameters = - parameters - .into_iter() - .fold(String::new(), |mut acc, (name, value)| { - acc.reserve(name.len() + value.len() + 2); - acc.push_str(&name); - acc.push('='); - acc.push_str(&value); - acc.push('\n'); - acc - }); - Ok((pretty_statement, printed_parameters)) - } - pub async fn test_generated_sql( - schema_dir: &str, - group_dir: &str, - test_name: &str, - ) -> Result<(), Box> { - let configuration = read_mock_configuration(schema_dir).await?; - let request = read_request(schema_dir, group_dir, test_name).await?; - - let generated_sql = generate_sql(&configuration, &request)?; - let (parameterized_sql, parameters) = generate_parameterized_sql(&configuration, &request)?; - - if UPDATE_SNAPSHOTS { - write_expected_sql(schema_dir, group_dir, test_name, &generated_sql).await?; - write_expected_parameterized_sql( - schema_dir, - group_dir, - test_name, - ¶meterized_sql, - ¶meters, - ) - .await?; - } else { - let expected_sql = read_expected_sql(schema_dir, group_dir, test_name).await?; - - assert_eq!( - generated_sql, expected_sql, - "Inlined SQL should match snapshot" - ); - - let expected_parameterized_sql = - read_expected_parameterized_sql(schema_dir, group_dir, test_name).await?; +fn base_path() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests") + .join("query_builder") +} - assert_eq!( - parameterized_sql, expected_parameterized_sql, - "Parameterized SQL should match snapshot" - ); +async fn read_mock_configuration(schema_dir: &str) -> ServerConfig { + // set mock values for required env vars, we won't be reading these anyways + let env = HashMap::from_iter(vec![ + ("CLICKHOUSE_URL".to_owned(), "".to_owned()), + ("CLICKHOUSE_USERNAME".to_owned(), "".to_owned()), + ("CLICKHOUSE_PASSWORD".to_owned(), "".to_owned()), + ]); + let setup = ClickhouseConnectorSetup::new_from_env(env); + let config_dir = base_path().join(schema_dir).join("_config"); + setup + .read_server_config(config_dir) + .await + .expect("Should be able to read configuration") +} - let expected_parameters = - read_expected_parameters(schema_dir, group_dir, test_name).await?; +fn pretty_print_sql(query: &str) -> String { + use sqlformat::{format, FormatOptions, Indent, QueryParams}; + let params = QueryParams::None; + let options = FormatOptions { + indent: Indent::Spaces(2), + uppercase: false, + lines_between_queries: 1, + }; - assert_eq!( - parameters, expected_parameters, - "Parameters should match snapshot" - ); + format(query, ¶ms, options) +} - if expected_parameters.is_empty() { - assert_eq!( - generated_sql, parameterized_sql, - "If no parameters are present, parameterized sql should match inlined sql" - ); +#[tokio::test] +async fn test_sql_generation() { + for schema_dir in ["chinook", "complex_columns", "star_schema"] { + let configuration = read_mock_configuration(schema_dir).await; + + glob!( + base_path().join(schema_dir), + "*.request.json", + |file_path| { + let file = fs::read_to_string(file_path).expect("Should read request file"); + let request: models::QueryRequest = + serde_json::from_str(&file).expect("File should be valid query request"); + + let inlined_sql = match QueryBuilder::new(&request, &configuration).build_inlined() + { + Err(err) => { + assert_snapshot!(format!("{schema_dir} Expected Error"), err); + return; + } + Ok(inlined_sql) => pretty_print_sql(&inlined_sql.to_string()), + }; + + assert_snapshot!(format!("{schema_dir} Inlined SQL"), inlined_sql); + + let (parameterized_sql, parameters) = QueryBuilder::new(&request, &configuration) + .build_parameterized() + .expect("Should build parameterized SQL"); + let parameterized_sql = pretty_print_sql(¶meterized_sql.to_string()); + + if parameters.is_empty() { + assert_eq!( + inlined_sql, parameterized_sql, + "If no parameters are present, parameterized sql should match inlined sql" + ) + } else { + let printed_parameters = + parameters + .into_iter() + .fold(String::new(), |mut acc, (name, value)| { + acc.reserve(name.len() + value.len() + 2); + acc.push_str(&name); + acc.push('='); + acc.push_str(&value); + acc.push('\n'); + acc + }); + + assert_snapshot!(format!("{schema_dir} Parameterized SQL"), parameterized_sql); + assert_snapshot!(format!("{schema_dir} Parameters"), printed_parameters); + } } - } - - Ok(()) + ) } - pub async fn test_error( - schema_dir: &str, - group_dir: &str, - test_name: &str, - err: QueryBuilderError, - ) -> Result<(), Box> { - let configuration = read_mock_configuration(schema_dir).await?; - let request = read_request(schema_dir, group_dir, test_name).await?; - - let result = generate_sql(&configuration, &request); +} - assert_eq!(result, Err(err)); +#[tokio::test] +async fn test_schemas() { + for schema_dir in ["chinook", "complex_columns", "star_schema"] { + let configuration = read_mock_configuration(schema_dir).await; - Ok(()) - } - pub async fn test_schema(schema_dir: &str) -> Result<(), Box> { - let configuration = read_mock_configuration(schema_dir).await?; let schema = schema_response(&configuration); - let expected_schema_path = expected_schema_path(schema_dir); - - if UPDATE_SNAPSHOTS { - fs::write(expected_schema_path, serde_json::to_string_pretty(&schema)?).await?; - } else { - let expected_schema_file = fs::read_to_string(expected_schema_path).await?; - let expected_schema: SchemaResponse = serde_json::from_str(&expected_schema_file)?; - - assert_eq!(schema, expected_schema, "Schema should match snapshot") - } - - Ok(()) + assert_yaml_snapshot!(format!("{schema_dir} Schema Response"), schema); } } @@ -253,203 +109,11 @@ async fn update_json_schema() -> Result<(), Box> { fs::write( "./tests/query_builder/request.schema.json", serde_json::to_string_pretty(&schema_for!(models::QueryRequest))?, - ) - .await?; + )?; fs::write( "./tests/query_builder/configuration.schema.json", serde_json::to_string_pretty(&schema_for!(ServerConfigFile))?, - ) - .await?; + )?; Ok(()) } - -#[cfg(test)] -mod schemas { - use super::*; - - #[tokio::test] - async fn chinook_schema() -> Result<(), Box> { - test_utils::test_schema("chinook").await - } - #[tokio::test] - async fn complex_columns_schema() -> Result<(), Box> { - test_utils::test_schema("complex_columns").await - } - #[tokio::test] - async fn star_schema_schema() -> Result<(), Box> { - test_utils::test_schema("star_schema").await - } -} - -#[cfg(test)] -mod simple_queries { - use super::*; - - async fn test_generated_sql(name: &str) -> Result<(), Box> { - super::test_utils::test_generated_sql("chinook", "01_simple_queries", name).await - } - - #[tokio::test] - async fn select_rows() -> Result<(), Box> { - test_generated_sql("01_select_rows").await - } - #[tokio::test] - async fn with_predicate() -> Result<(), Box> { - test_generated_sql("02_with_predicate").await - } - #[tokio::test] - async fn larger_predicate() -> Result<(), Box> { - test_generated_sql("03_larger_predicate").await - } - #[tokio::test] - async fn limit() -> Result<(), Box> { - test_generated_sql("04_limit").await - } - #[tokio::test] - async fn offset() -> Result<(), Box> { - test_generated_sql("05_offset").await - } - #[tokio::test] - async fn limit_offset() -> Result<(), Box> { - test_generated_sql("06_limit_offset").await - } - - #[tokio::test] - async fn order_by() -> Result<(), Box> { - test_generated_sql("07_order_by").await - } - #[tokio::test] - async fn predicate_limit_offset_order_by() -> Result<(), Box> { - test_generated_sql("08_predicate_limit_offset_order_by").await - } -} - -#[cfg(test)] -mod relationships { - use super::*; - - async fn test_generated_sql(name: &str) -> Result<(), Box> { - super::test_utils::test_generated_sql("chinook", "02_relationships", name).await - } - - #[tokio::test] - async fn object_relationship() -> Result<(), Box> { - test_generated_sql("01_object_relationship").await - } - #[tokio::test] - async fn array_relationship() -> Result<(), Box> { - test_generated_sql("02_array_relationship").await - } - #[tokio::test] - async fn parent_predicate() -> Result<(), Box> { - test_generated_sql("03_parent_predicate").await - } - #[tokio::test] - async fn child_predicate() -> Result<(), Box> { - test_generated_sql("04_child_predicate").await - } - #[tokio::test] - async fn traverse_relationship_in_predicate() -> Result<(), Box> { - test_generated_sql("05_traverse_relationship_in_predicate").await - } - #[tokio::test] - async fn traverse_relationship_in_order_by() -> Result<(), Box> { - test_generated_sql("06_traverse_relationship_in_order_by").await - } - #[tokio::test] - async fn order_by_aggregate_across_relationships() -> Result<(), Box> { - test_generated_sql("07_order_by_aggregate_across_relationships").await - } -} - -#[cfg(test)] -mod variables { - use super::*; - - async fn test_generated_sql(name: &str) -> Result<(), Box> { - super::test_utils::test_generated_sql("chinook", "03_variables", name).await - } - - #[tokio::test] - async fn simple_predicate() -> Result<(), Box> { - test_generated_sql("01_simple_predicate").await - } - #[tokio::test] - async fn empty_variable_sets() -> Result<(), Box> { - test_generated_sql("02_empty_variable_sets").await - } - #[tokio::test] - async fn singe_set() -> Result<(), Box> { - test_generated_sql("03_single_set").await - } -} - -#[cfg(test)] -mod native_queries { - use super::*; - - async fn test_generated_sql(name: &str) -> Result<(), Box> { - super::test_utils::test_generated_sql("star_schema", "01_native_queries", name).await - } - - #[tokio::test] - async fn native_query() -> Result<(), Box> { - test_generated_sql("01_native_query").await - } -} - -#[cfg(test)] -mod field_selector { - use super::*; - - async fn test_generated_sql(name: &str) -> Result<(), Box> { - super::test_utils::test_generated_sql("complex_columns", "field_selector", name).await - } - async fn test_error(name: &str, err: QueryBuilderError) -> Result<(), Box> { - super::test_utils::test_error("complex_columns", "field_selector", name, err).await - } - - #[tokio::test] - async fn generate_column_accessor() -> Result<(), Box> { - test_generated_sql("01_generate_column_accessor").await - } - #[tokio::test] - async fn skip_if_not_required() -> Result<(), Box> { - test_generated_sql("02_skip_if_not_required").await - } - #[tokio::test] - async fn support_relationships_on_nested_field() -> Result<(), Box> { - test_generated_sql("03_support_relationships_on_nested_field").await - } - /// We do not support relationships on nested fileds if an array has been traversed - #[tokio::test] - async fn error_on_relationships_on_array_nested_field() -> Result<(), Box> { - let err = QueryBuilderError::NotSupported( - "Relationships with fields nested in arrays".to_string(), - ); - test_error("04_error_on_relationships_on_array_nested_field", err).await - } - #[tokio::test] - async fn complex_example() -> Result<(), Box> { - test_generated_sql("05_complex_example").await - } - #[tokio::test] - async fn no_useless_nested_accessors() -> Result<(), Box> { - test_generated_sql("06_no_useless_nested_accessors").await - } -} - -#[cfg(test)] -mod bound_parameters { - use super::*; - - async fn test_generated_sql(name: &str) -> Result<(), Box> { - super::test_utils::test_generated_sql("complex_columns", "bound_parameters", name).await - } - - #[tokio::test] - async fn bind_complex_parameters() -> Result<(), Box> { - test_generated_sql("01_bind_complex_parameters").await - } -} diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.statement.sql b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.statement.sql deleted file mode 100644 index 6d3e6f9..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.statement.sql +++ /dev/null @@ -1,31 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("albumId" Int32, "artistId" Int32, "title" String)))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_albumId", - "_row"."_field_artistId", - "_row"."_field_title" - ) - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."AlbumId" AS "_field_albumId", - "_origin"."ArtistId" AS "_field_artistId", - "_origin"."Title" AS "_field_title" - FROM - "Chinook"."Album" AS "_origin" - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.parameters.txt deleted file mode 100644 index d4dcdf8..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.parameters.txt +++ /dev/null @@ -1 +0,0 @@ -param_p0=1 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.parameters.txt deleted file mode 100644 index e30b664..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.parameters.txt +++ /dev/null @@ -1,2 +0,0 @@ -param_p0=1 -param_p1=2 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.statement.sql b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.statement.sql deleted file mode 100644 index 3063baa..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.statement.sql +++ /dev/null @@ -1,33 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("albumId" Int32, "artistId" Int32, "title" String)))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_albumId", - "_row"."_field_artistId", - "_row"."_field_title" - ) - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."AlbumId" AS "_field_albumId", - "_origin"."ArtistId" AS "_field_artistId", - "_origin"."Title" AS "_field_title" - FROM - "Chinook"."Album" AS "_origin" - LIMIT - 10 - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.statement.sql b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.statement.sql deleted file mode 100644 index c54bca3..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.statement.sql +++ /dev/null @@ -1,31 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("albumId" Int32, "artistId" Int32, "title" String)))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_albumId", - "_row"."_field_artistId", - "_row"."_field_title" - ) - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."AlbumId" AS "_field_albumId", - "_origin"."ArtistId" AS "_field_artistId", - "_origin"."Title" AS "_field_title" - FROM - "Chinook"."Album" AS "_origin" OFFSET 10 - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.statement.sql b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.statement.sql deleted file mode 100644 index 20d8f04..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.statement.sql +++ /dev/null @@ -1,33 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("albumId" Int32, "artistId" Int32, "title" String)))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_albumId", - "_row"."_field_artistId", - "_row"."_field_title" - ) - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."AlbumId" AS "_field_albumId", - "_origin"."ArtistId" AS "_field_artistId", - "_origin"."Title" AS "_field_title" - FROM - "Chinook"."Album" AS "_origin" - LIMIT - 10 OFFSET 10 - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.statement.sql b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.statement.sql deleted file mode 100644 index d9df4f4..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.statement.sql +++ /dev/null @@ -1,33 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("albumId" Int32, "artistId" Int32, "title" String)))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_albumId", - "_row"."_field_artistId", - "_row"."_field_title" - ) - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."AlbumId" AS "_field_albumId", - "_origin"."ArtistId" AS "_field_artistId", - "_origin"."Title" AS "_field_title" - FROM - "Chinook"."Album" AS "_origin" - ORDER BY - "_origin"."ArtistId" ASC - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.parameters.txt deleted file mode 100644 index 4214a1e..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.parameters.txt +++ /dev/null @@ -1 +0,0 @@ -param_p0=10 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_01_select_rows.request.json similarity index 92% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_01_select_rows.request.json index 44df377..01885a2 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_01_select_rows.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_02_with_predicate.request.json similarity index 96% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_02_with_predicate.request.json index a2d33af..92f5846 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_02_with_predicate.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_03_larger_predicate.request.json similarity index 98% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_03_larger_predicate.request.json index 6a89bee..a41e8fe 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_03_larger_predicate.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_04_limit.request.json similarity index 93% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_04_limit.request.json index f5b55eb..acb33fa 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_04_limit.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_05_offset.request.json similarity index 93% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_05_offset.request.json index 426c9c2..63d6984 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_05_offset.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_06_limit_offset.request.json similarity index 93% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_06_limit_offset.request.json index 4b9bce7..b69b6c4 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_06_limit_offset.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_07_order_by.request.json similarity index 95% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_07_order_by.request.json index 413cb08..27b8008 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_07_order_by.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_08_predicate_limit_offset_order_by.request.json similarity index 97% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_08_predicate_limit_offset_order_by.request.json index ba6fdd1..c1275db 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_08_predicate_limit_offset_order_by.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.statement.sql b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.statement.sql deleted file mode 100644 index 80d4b9a..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.statement.sql +++ /dev/null @@ -1,53 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("albumId" Int32, "artistId" Int32, "title" String, "Artist" Tuple(rows Array(Tuple("artistId" Int32, "name" Nullable(String)))))))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_albumId", - "_row"."_field_artistId", - "_row"."_field_title", - "_row"."_field_Artist" - ) - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."AlbumId" AS "_field_albumId", - "_origin"."ArtistId" AS "_field_artistId", - "_origin"."Title" AS "_field_title", - "_rel_0_Artist"."_rowset" AS "_field_Artist" - FROM - "Chinook"."Album" AS "_origin" - LEFT JOIN ( - SELECT - tuple( - groupArray( - tuple("_row"."_field_artistId", "_row"."_field_name") - ) - ) AS "_rowset", - "_row"."_relkey_ArtistId" AS "_relkey_ArtistId" - FROM - ( - SELECT - "_origin"."ArtistId" AS "_field_artistId", - "_origin"."Name" AS "_field_name", - "_origin"."ArtistId" AS "_relkey_ArtistId" - FROM - "Chinook"."Artist" AS "_origin" - ) AS "_row" - GROUP BY - "_row"."_relkey_ArtistId" - ) AS "_rel_0_Artist" ON "_origin"."ArtistId" = "_rel_0_Artist"."_relkey_ArtistId" - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.parameterized_statement.sql b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.parameterized_statement.sql deleted file mode 100644 index ebf6a7d..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.parameterized_statement.sql +++ /dev/null @@ -1,58 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("albumId" Int32, "artistId" Int32, "title" String, "Tracks" Tuple(rows Array(Tuple("trackId" Int32, "name" String, "unitPrice" Float64))))))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_albumId", - "_row"."_field_artistId", - "_row"."_field_title", - "_row"."_field_Tracks" - ) - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."AlbumId" AS "_field_albumId", - "_origin"."ArtistId" AS "_field_artistId", - "_origin"."Title" AS "_field_title", - "_rel_0_Tracks"."_rowset" AS "_field_Tracks" - FROM - "Chinook"."Album" AS "_origin" - LEFT JOIN ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_trackId", - "_row"."_field_name", - "_row"."_field_unitPrice" - ) - ) - ) AS "_rowset", - "_row"."_relkey_AlbumId" AS "_relkey_AlbumId" - FROM - ( - SELECT - "_origin"."TrackId" AS "_field_trackId", - "_origin"."Name" AS "_field_name", - "_origin"."UnitPrice" AS "_field_unitPrice", - "_origin"."AlbumId" AS "_relkey_AlbumId" - FROM - "Chinook"."Track" AS "_origin" - ) AS "_row" - GROUP BY - "_row"."_relkey_AlbumId" - ) AS "_rel_0_Tracks" ON "_origin"."AlbumId" = "_rel_0_Tracks"."_relkey_AlbumId" - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.statement copy.sql b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.statement copy.sql deleted file mode 100644 index ebf6a7d..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.statement copy.sql +++ /dev/null @@ -1,58 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("albumId" Int32, "artistId" Int32, "title" String, "Tracks" Tuple(rows Array(Tuple("trackId" Int32, "name" String, "unitPrice" Float64))))))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_albumId", - "_row"."_field_artistId", - "_row"."_field_title", - "_row"."_field_Tracks" - ) - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."AlbumId" AS "_field_albumId", - "_origin"."ArtistId" AS "_field_artistId", - "_origin"."Title" AS "_field_title", - "_rel_0_Tracks"."_rowset" AS "_field_Tracks" - FROM - "Chinook"."Album" AS "_origin" - LEFT JOIN ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_trackId", - "_row"."_field_name", - "_row"."_field_unitPrice" - ) - ) - ) AS "_rowset", - "_row"."_relkey_AlbumId" AS "_relkey_AlbumId" - FROM - ( - SELECT - "_origin"."TrackId" AS "_field_trackId", - "_origin"."Name" AS "_field_name", - "_origin"."UnitPrice" AS "_field_unitPrice", - "_origin"."AlbumId" AS "_relkey_AlbumId" - FROM - "Chinook"."Track" AS "_origin" - ) AS "_row" - GROUP BY - "_row"."_relkey_AlbumId" - ) AS "_rel_0_Tracks" ON "_origin"."AlbumId" = "_rel_0_Tracks"."_relkey_AlbumId" - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.parameters.txt deleted file mode 100644 index 4214a1e..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.parameters.txt +++ /dev/null @@ -1 +0,0 @@ -param_p0=10 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.parameters.txt deleted file mode 100644 index 44205cd..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.parameters.txt +++ /dev/null @@ -1,2 +0,0 @@ -param_p0=10 -param_p1=10 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.parameters.txt deleted file mode 100644 index 6f1520b..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.parameters.txt +++ /dev/null @@ -1 +0,0 @@ -param_p0=AC/DC diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.statement.sql b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.statement.sql deleted file mode 100644 index 0839ad6..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.statement.sql +++ /dev/null @@ -1,80 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("trackId" Int32, "name" String, "Album" Tuple(rows Array(Tuple("Artist" Tuple(rows Array(Tuple("name" Nullable(String))))))))))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple( - "_row"."_field_trackId", - "_row"."_field_name", - "_row"."_field_Album" - ) - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."TrackId" AS "_field_trackId", - "_origin"."Name" AS "_field_name", - "_rel_0_Album"."_rowset" AS "_field_Album" - FROM - "Chinook"."Track" AS "_origin" - LEFT JOIN ( - SELECT - tuple(groupArray(tuple("_row"."_field_Artist"))) AS "_rowset", - "_row"."_relkey_AlbumId" AS "_relkey_AlbumId" - FROM - ( - SELECT - "_rel_0_Artist"."_rowset" AS "_field_Artist", - "_origin"."AlbumId" AS "_relkey_AlbumId" - FROM - "Chinook"."Album" AS "_origin" - LEFT JOIN ( - SELECT - tuple(groupArray(tuple("_row"."_field_name"))) AS "_rowset", - "_row"."_relkey_ArtistId" AS "_relkey_ArtistId" - FROM - ( - SELECT - "_origin"."Name" AS "_field_name", - "_origin"."ArtistId" AS "_relkey_ArtistId" - FROM - "Chinook"."Artist" AS "_origin" - ) AS "_row" - GROUP BY - "_row"."_relkey_ArtistId" - ) AS "_rel_0_Artist" ON "_origin"."ArtistId" = "_rel_0_Artist"."_relkey_ArtistId" - ) AS "_row" - GROUP BY - "_row"."_relkey_AlbumId" - ) AS "_rel_0_Album" ON "_origin"."AlbumId" = "_rel_0_Album"."_relkey_AlbumId" - LEFT JOIN ( - SELECT - "_order_by_0"."AlbumId" AS "_relkey_AlbumId", - "_order_by_1"."Name" AS "_order_by_value" - FROM - "Chinook"."Album" AS "_order_by_0" - JOIN "Chinook"."Artist" AS "_order_by_1" ON "_order_by_0"."ArtistId" = "_order_by_1"."ArtistId" - WHERE - TRUE - AND TRUE - GROUP BY - "_order_by_0"."AlbumId", - "_order_by_1"."Name" - LIMIT - 1 BY "_order_by_0"."AlbumId" - ) AS "_order_by_0" ON "_origin"."AlbumId" = "_order_by_0"."_relkey_AlbumId" - ORDER BY - "_order_by_0"."_order_by_value" ASC, - "_origin"."Name" ASC - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.statement.sql b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.statement.sql deleted file mode 100644 index db6585a..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.statement.sql +++ /dev/null @@ -1,76 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("trackId" Int32, "name" String)))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple("_row"."_field_trackId", "_row"."_field_name") - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."TrackId" AS "_field_trackId", - "_origin"."Name" AS "_field_name" - FROM - "Chinook"."Track" AS "_origin" - LEFT JOIN ( - SELECT - "_order_by_0"."AlbumId" AS "_relkey_AlbumId", - "_order_by_1"."Name" AS "_order_by_value" - FROM - "Chinook"."Album" AS "_order_by_0" - JOIN "Chinook"."Artist" AS "_order_by_1" ON "_order_by_0"."ArtistId" = "_order_by_1"."ArtistId" - WHERE - TRUE - AND TRUE - GROUP BY - "_order_by_0"."AlbumId", - "_order_by_1"."Name" - LIMIT - 1 BY "_order_by_0"."AlbumId" - ) AS "_order_by_0" ON "_origin"."AlbumId" = "_order_by_0"."_relkey_AlbumId" - LEFT JOIN ( - SELECT - "_order_by_0"."AlbumId" AS "_relkey_AlbumId", - COUNT(*) AS "_order_by_value" - FROM - "Chinook"."Album" AS "_order_by_0" - JOIN "Chinook"."Artist" AS "_order_by_1" ON "_order_by_0"."ArtistId" = "_order_by_1"."ArtistId" - WHERE - TRUE - AND TRUE - GROUP BY - "_order_by_0"."AlbumId" - LIMIT - 1 BY "_order_by_0"."AlbumId" - ) AS "_order_by_1" ON "_origin"."AlbumId" = "_order_by_1"."_relkey_AlbumId" - LEFT JOIN ( - SELECT - "_order_by_0"."AlbumId" AS "_relkey_AlbumId", - max("_order_by_1"."Name") AS "_order_by_value" - FROM - "Chinook"."Album" AS "_order_by_0" - JOIN "Chinook"."Artist" AS "_order_by_1" ON "_order_by_0"."ArtistId" = "_order_by_1"."ArtistId" - WHERE - TRUE - AND TRUE - GROUP BY - "_order_by_0"."AlbumId" - LIMIT - 1 BY "_order_by_0"."AlbumId" - ) AS "_order_by_2" ON "_origin"."AlbumId" = "_order_by_2"."_relkey_AlbumId" - ORDER BY - "_order_by_0"."_order_by_value" ASC, - "_order_by_1"."_order_by_value" ASC, - "_order_by_2"."_order_by_value" ASC - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_01_object_relationship.request.json similarity index 97% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_01_object_relationship.request.json index 99c578e..cdd4d0e 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_01_object_relationship.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_02_array_relationship.request.json similarity index 97% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_02_array_relationship.request.json index 895b14a..2f716d7 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_02_array_relationship.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_03_parent_predicate.request.json similarity index 98% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_03_parent_predicate.request.json index 8065a62..cc21951 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_03_parent_predicate.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_04_child_predicate.request.json similarity index 98% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_04_child_predicate.request.json index 929e20d..7d8d512 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_04_child_predicate.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_05_traverse_relationship_in_predicate.request.json similarity index 98% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_05_traverse_relationship_in_predicate.request.json index 75521ff..7b739c1 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_05_traverse_relationship_in_predicate.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_06_traverse_relationship_in_order_by.request.json similarity index 98% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_06_traverse_relationship_in_order_by.request.json index 38b4a79..5ebfefb 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_06_traverse_relationship_in_order_by.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Track", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_07_order_by_aggregate_across_relationships.request.json similarity index 99% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_07_order_by_aggregate_across_relationships.request.json index 5c30d2b..c7c0f45 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_07_order_by_aggregate_across_relationships.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Track", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.parameters.txt deleted file mode 100644 index 693abaf..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.parameters.txt +++ /dev/null @@ -1 +0,0 @@ -param_p0={"_varset_id":[1,2],"_var_ArtistId":[1,2]} diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.parameters.txt deleted file mode 100644 index a71a904..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.parameters.txt +++ /dev/null @@ -1 +0,0 @@ -param_p0={"_varset_id":[]} diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.parameters.txt deleted file mode 100644 index 8df3aeb..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.parameters.txt +++ /dev/null @@ -1 +0,0 @@ -param_p0={"_varset_id":[1],"_var_ArtistId":[1]} diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_01_simple_predicate.request.json similarity index 97% rename from crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_01_simple_predicate.request.json index 571946a..7d6406f 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_01_simple_predicate.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "variables": [ { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_02_empty_variable_sets.request.json similarity index 96% rename from crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_02_empty_variable_sets.request.json index 18327db..81a0fd5 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_02_empty_variable_sets.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "variables": [], "query": { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.request.json b/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_03_single_set.request.json similarity index 97% rename from crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.request.json rename to crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_03_single_set.request.json index eacd229..5f494ac 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_03_single_set.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "Chinook_Album", "variables": [ { diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/_schema/schema.json b/crates/ndc-clickhouse/tests/query_builder/chinook/_schema/schema.json deleted file mode 100644 index 0390cb7..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/_schema/schema.json +++ /dev/null @@ -1,1160 +0,0 @@ -{ - "scalar_types": { - "Date32": { - "representation": { - "type": "string" - }, - "aggregate_functions": { - "max": { - "result_type": { - "type": "named", - "name": "Date32" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "Date32" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Date32" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Date32" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Date32" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Date32" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Date32" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "Date32" - } - } - } - } - }, - "DateTime64(9)": { - "representation": { - "type": "string" - }, - "aggregate_functions": { - "max": { - "result_type": { - "type": "named", - "name": "DateTime64(9)" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "DateTime64(9)" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "DateTime64(9)" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "DateTime64(9)" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "DateTime64(9)" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "DateTime64(9)" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "DateTime64(9)" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "DateTime64(9)" - } - } - } - } - }, - "Float64": { - "representation": { - "type": "float64" - }, - "aggregate_functions": { - "avg": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "max": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "stddev_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "stddev_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "sum": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "var_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "var_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Float64" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Float64" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Float64" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Float64" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Float64" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "Float64" - } - } - } - } - }, - "Int32": { - "representation": { - "type": "int32" - }, - "aggregate_functions": { - "avg": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "max": { - "result_type": { - "type": "named", - "name": "Int32" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "Int32" - } - }, - "stddev_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "stddev_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "sum": { - "result_type": { - "type": "named", - "name": "Int64" - } - }, - "var_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "var_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Int32" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Int32" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Int32" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Int32" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Int32" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "Int32" - } - } - } - } - }, - "String": { - "representation": { - "type": "string" - }, - "aggregate_functions": {}, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_ilike": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_in": { - "type": "in" - }, - "_like": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_match": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_nilike": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "String" - } - } - }, - "_nlike": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - } - } - } - }, - "object_types": { - "Chinook_Album": { - "description": "", - "fields": { - "AlbumId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "ArtistId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "Title": { - "type": { - "type": "named", - "name": "String" - } - } - } - }, - "Chinook_Artist": { - "description": "", - "fields": { - "ArtistId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "Name": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - } - } - }, - "Chinook_Customer": { - "description": "", - "fields": { - "Address": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "City": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "Company": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "Country": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "CustomerId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "Email": { - "type": { - "type": "named", - "name": "String" - } - }, - "Fax": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "FirstName": { - "type": { - "type": "named", - "name": "String" - } - }, - "LastName": { - "type": { - "type": "named", - "name": "String" - } - }, - "Phone": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "PostalCode": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "State": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "SupportRepId": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "Int32" - } - } - } - } - }, - "Chinook_Employee": { - "description": "", - "fields": { - "Address": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "BirthDate": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "Date32" - } - } - }, - "City": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "Country": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "Email": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "EmployeeId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "Fax": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "FirstName": { - "type": { - "type": "named", - "name": "String" - } - }, - "HireDate": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "Date32" - } - } - }, - "LastName": { - "type": { - "type": "named", - "name": "String" - } - }, - "Phone": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "PostalCode": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "ReportsTo": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "Int32" - } - } - }, - "State": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "Title": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - } - } - }, - "Chinook_Genre": { - "description": "", - "fields": { - "GenreId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "Name": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - } - } - }, - "Chinook_Invoice": { - "description": "", - "fields": { - "BillingAddress": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "BillingCity": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "BillingCountry": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "BillingPostalCode": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "BillingState": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "CustomerId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "InvoiceDate": { - "type": { - "type": "named", - "name": "DateTime64(9)" - } - }, - "InvoiceId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "Total": { - "type": { - "type": "named", - "name": "Float64" - } - } - } - }, - "Chinook_InvoiceLine": { - "description": "", - "fields": { - "InvoiceId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "InvoiceLineId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "Quantity": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "TrackId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "UnitPrice": { - "type": { - "type": "named", - "name": "Float64" - } - } - } - }, - "Chinook_MediaType": { - "description": "", - "fields": { - "MediaTypeId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "Name": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - } - } - }, - "Chinook_Playlist": { - "description": "", - "fields": { - "Name": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "PlaylistId": { - "type": { - "type": "named", - "name": "Int32" - } - } - } - }, - "Chinook_PlaylistTrack": { - "description": "", - "fields": { - "PlaylistId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "TrackId": { - "type": { - "type": "named", - "name": "Int32" - } - } - } - }, - "Chinook_Track": { - "description": "", - "fields": { - "AlbumId": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "Int32" - } - } - }, - "Bytes": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "Int32" - } - } - }, - "Composer": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "GenreId": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "Int32" - } - } - }, - "MediaTypeId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "Milliseconds": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "Name": { - "type": { - "type": "named", - "name": "String" - } - }, - "TrackId": { - "type": { - "type": "named", - "name": "Int32" - } - }, - "UnitPrice": { - "type": { - "type": "named", - "name": "Float64" - } - } - } - } - }, - "collections": [ - { - "name": "Chinook_Album", - "description": "", - "arguments": {}, - "type": "Chinook_Album", - "uniqueness_constraints": { - "AlbumId": { - "unique_columns": [ - "AlbumId" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "Chinook_Artist", - "description": "", - "arguments": {}, - "type": "Chinook_Artist", - "uniqueness_constraints": { - "ArtistId": { - "unique_columns": [ - "ArtistId" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "Chinook_Customer", - "description": "", - "arguments": {}, - "type": "Chinook_Customer", - "uniqueness_constraints": { - "CustomerId": { - "unique_columns": [ - "CustomerId" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "Chinook_Employee", - "description": "", - "arguments": {}, - "type": "Chinook_Employee", - "uniqueness_constraints": { - "EmployeeId": { - "unique_columns": [ - "EmployeeId" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "Chinook_Genre", - "description": "", - "arguments": {}, - "type": "Chinook_Genre", - "uniqueness_constraints": { - "GenreId": { - "unique_columns": [ - "GenreId" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "Chinook_Invoice", - "description": "", - "arguments": {}, - "type": "Chinook_Invoice", - "uniqueness_constraints": { - "InvoiceId": { - "unique_columns": [ - "InvoiceId" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "Chinook_InvoiceLine", - "description": "", - "arguments": {}, - "type": "Chinook_InvoiceLine", - "uniqueness_constraints": { - "InvoiceLineId": { - "unique_columns": [ - "InvoiceLineId" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "Chinook_MediaType", - "description": "", - "arguments": {}, - "type": "Chinook_MediaType", - "uniqueness_constraints": { - "MediaTypeId": { - "unique_columns": [ - "MediaTypeId" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "Chinook_Playlist", - "description": "", - "arguments": {}, - "type": "Chinook_Playlist", - "uniqueness_constraints": { - "PlaylistId": { - "unique_columns": [ - "PlaylistId" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "Chinook_PlaylistTrack", - "description": "", - "arguments": {}, - "type": "Chinook_PlaylistTrack", - "uniqueness_constraints": { - "PlaylistId, TrackId": { - "unique_columns": [ - "PlaylistId", - "TrackId" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "Chinook_Track", - "description": "", - "arguments": {}, - "type": "Chinook_Track", - "uniqueness_constraints": { - "TrackId": { - "unique_columns": [ - "TrackId" - ] - } - }, - "foreign_keys": {} - } - ], - "functions": [], - "procedures": [] -} \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.request.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/01_bind_complex_parameters.request.json similarity index 98% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.request.json rename to crates/ndc-clickhouse/tests/query_builder/complex_columns/01_bind_complex_parameters.request.json index e3d2f52..e5123cd 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/complex_columns/01_bind_complex_parameters.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "TableOne", "collection_relationships": {}, "arguments": {}, diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_01_bind.request.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_01_bind.request.json new file mode 100644 index 0000000..e5123cd --- /dev/null +++ b/crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_01_bind.request.json @@ -0,0 +1,148 @@ +{ + "$schema": "../request.schema.json", + "collection": "TableOne", + "collection_relationships": {}, + "arguments": {}, + "query": { + "fields": { + "field1": { + "type": "column", + "column": "ColumnA" + } + }, + "predicate": { + "type": "and", + "expressions": [ + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnB", + "path": [] + }, + "value": { + "type": "scalar", + "value": [ + { + "field1": "foo", + "field2": "bar" + } + ] + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnC", + "path": [] + }, + "value": { + "type": "scalar", + "value": [ + { + "field1": "foo", + "field2": "bar" + } + ] + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnD", + "path": [] + }, + "value": { + "type": "scalar", + "value": { + "child": { + "id": 1, + "name": "foo" + } + } + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnE", + "path": [] + }, + "value": { + "type": "scalar", + "value": { + "child": [ + { + "id": 1, + "name": "foo" + } + ] + } + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnF", + "path": [] + }, + "value": { + "type": "scalar", + "value": { + "child": { + "id": 1, + "name": "foo", + "toys": [ + { + "id": 2, + "name": "bar" + } + ] + } + } + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnG", + "path": [] + }, + "value": { + "type": "scalar", + "value": { + "a": null, + "b": { + "foo": "bar" + }, + "c": [ + { + "a": "foo", + "b": [ + "foo", + "bar" + ] + } + ], + "d": { + "a": "foo", + "b": "bar" + } + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_02_variables.request.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_02_variables.request.json new file mode 100644 index 0000000..bccdf34 --- /dev/null +++ b/crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_02_variables.request.json @@ -0,0 +1,217 @@ +{ + "$schema": "../request.schema.json", + "collection": "TableOne", + "collection_relationships": {}, + "arguments": {}, + "variables": [ + { + "var1": [ + { + "field1": "foo", + "field2": "bar" + } + ], + "var2": [ + { + "field1": "foo", + "field2": "bar" + } + ], + "var3": { + "child": { + "id": 1, + "name": "foo" + } + }, + "var4": { + "child": [ + { + "id": 1, + "name": "foo" + } + ] + }, + "var5": { + "child": { + "id": 1, + "name": "foo", + "toys": [ + { + "id": 2, + "name": "bar" + } + ] + } + }, + "var6": { + "a": null, + "b": { + "foo": "bar" + }, + "c": [ + { + "a": "foo", + "b": [ + "foo", + "bar" + ] + } + ], + "d": { + "a": "foo", + "b": "bar" + } + } + }, + { + "var1": [ + { + "field1": "foo", + "field2": "bar" + } + ], + "var2": [ + { + "field1": "foo", + "field2": "bar" + } + ], + "var3": { + "child": { + "id": 1, + "name": "foo" + } + }, + "var4": { + "child": [ + { + "id": 1, + "name": "foo" + } + ] + }, + "var5": { + "child": { + "id": 1, + "name": "foo", + "toys": [ + { + "id": 2, + "name": "bar" + } + ] + } + }, + "var6": { + "a": null, + "b": { + "foo": "bar" + }, + "c": [ + { + "a": "foo", + "b": [ + "foo", + "bar" + ] + } + ], + "d": { + "a": "foo", + "b": "bar" + } + } + } + ], + "query": { + "fields": { + "field1": { + "type": "column", + "column": "ColumnA" + } + }, + "predicate": { + "type": "and", + "expressions": [ + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnB", + "path": [] + }, + "value": { + "type": "variable", + "name": "var1" + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnC", + "path": [] + }, + "value": { + "type": "variable", + "name": "var2" + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnD", + "path": [] + }, + "value": { + "type": "variable", + "name": "var3" + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnE", + "path": [] + }, + "value": { + "type": "variable", + "name": "var4" + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnF", + "path": [] + }, + "value": { + "type": "variable", + "name": "var5" + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnG", + "path": [] + }, + "value": { + "type": "variable", + "name": "var6" + } + } + ] + } + } +} \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.request.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_01_generate_column_accessor.request.json similarity index 91% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.request.json rename to crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_01_generate_column_accessor.request.json index 7ed762b..edb02bb 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_01_generate_column_accessor.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "TableOne", "collection_relationships": {}, "arguments": {}, diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.request.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_02_skip_if_not_required.request.json similarity index 93% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.request.json rename to crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_02_skip_if_not_required.request.json index 47f1350..407157f 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_02_skip_if_not_required.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "TableOne", "collection_relationships": {}, "arguments": {}, diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.request.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_03_support_relationships_on_nested_field.request.json similarity index 98% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.request.json rename to crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_03_support_relationships_on_nested_field.request.json index dccd395..8157137 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_03_support_relationships_on_nested_field.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "TableOne", "collection_relationships": { "rel1": { diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/04_error_on_relationships_on_array_nested_field.request.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_04_error_on_relationships_on_array_nested_field.request.json similarity index 98% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/04_error_on_relationships_on_array_nested_field.request.json rename to crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_04_error_on_relationships_on_array_nested_field.request.json index 4d8034b..e0a3145 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/04_error_on_relationships_on_array_nested_field.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_04_error_on_relationships_on_array_nested_field.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "TableOne", "collection_relationships": { "rel1": { diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.request.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_05_complex_example.request.json similarity index 98% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.request.json rename to crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_05_complex_example.request.json index c3d86c0..5b18093 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_05_complex_example.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "TableOne", "collection_relationships": { "rel1": { diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.request.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_06_no_useless_nested_accessors.request.json similarity index 98% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.request.json rename to crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_06_no_useless_nested_accessors.request.json index d1c0dd0..78c98f0 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_06_no_useless_nested_accessors.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "TableOne", "collection_relationships": { "rel1": { diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_variables_with_complex_parameters.request.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_variables_with_complex_parameters.request.json new file mode 100644 index 0000000..bccdf34 --- /dev/null +++ b/crates/ndc-clickhouse/tests/query_builder/complex_columns/02_variables_with_complex_parameters.request.json @@ -0,0 +1,217 @@ +{ + "$schema": "../request.schema.json", + "collection": "TableOne", + "collection_relationships": {}, + "arguments": {}, + "variables": [ + { + "var1": [ + { + "field1": "foo", + "field2": "bar" + } + ], + "var2": [ + { + "field1": "foo", + "field2": "bar" + } + ], + "var3": { + "child": { + "id": 1, + "name": "foo" + } + }, + "var4": { + "child": [ + { + "id": 1, + "name": "foo" + } + ] + }, + "var5": { + "child": { + "id": 1, + "name": "foo", + "toys": [ + { + "id": 2, + "name": "bar" + } + ] + } + }, + "var6": { + "a": null, + "b": { + "foo": "bar" + }, + "c": [ + { + "a": "foo", + "b": [ + "foo", + "bar" + ] + } + ], + "d": { + "a": "foo", + "b": "bar" + } + } + }, + { + "var1": [ + { + "field1": "foo", + "field2": "bar" + } + ], + "var2": [ + { + "field1": "foo", + "field2": "bar" + } + ], + "var3": { + "child": { + "id": 1, + "name": "foo" + } + }, + "var4": { + "child": [ + { + "id": 1, + "name": "foo" + } + ] + }, + "var5": { + "child": { + "id": 1, + "name": "foo", + "toys": [ + { + "id": 2, + "name": "bar" + } + ] + } + }, + "var6": { + "a": null, + "b": { + "foo": "bar" + }, + "c": [ + { + "a": "foo", + "b": [ + "foo", + "bar" + ] + } + ], + "d": { + "a": "foo", + "b": "bar" + } + } + } + ], + "query": { + "fields": { + "field1": { + "type": "column", + "column": "ColumnA" + } + }, + "predicate": { + "type": "and", + "expressions": [ + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnB", + "path": [] + }, + "value": { + "type": "variable", + "name": "var1" + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnC", + "path": [] + }, + "value": { + "type": "variable", + "name": "var2" + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnD", + "path": [] + }, + "value": { + "type": "variable", + "name": "var3" + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnE", + "path": [] + }, + "value": { + "type": "variable", + "name": "var4" + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnF", + "path": [] + }, + "value": { + "type": "variable", + "name": "var5" + } + }, + { + "type": "binary_comparison_operator", + "operator": "_eq", + "column": { + "type": "column", + "name": "ColumnG", + "path": [] + }, + "value": { + "type": "variable", + "name": "var6" + } + } + ] + } + } +} \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/_schema/schema.json b/crates/ndc-clickhouse/tests/query_builder/complex_columns/_schema/schema.json deleted file mode 100644 index c277af9..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/_schema/schema.json +++ /dev/null @@ -1,506 +0,0 @@ -{ - "scalar_types": { - "Map(String, String)": { - "aggregate_functions": {}, - "comparison_operators": {} - }, - "String": { - "representation": { - "type": "string" - }, - "aggregate_functions": {}, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_ilike": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_in": { - "type": "in" - }, - "_like": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_match": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_nilike": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "String" - } - } - }, - "_nlike": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - } - } - }, - "Tuple(String, String)": { - "aggregate_functions": {}, - "comparison_operators": {} - }, - "UInt32": { - "representation": { - "type": "int64" - }, - "aggregate_functions": { - "avg": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "max": { - "result_type": { - "type": "named", - "name": "UInt32" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "UInt32" - } - }, - "stddev_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "stddev_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "sum": { - "result_type": { - "type": "named", - "name": "UInt64" - } - }, - "var_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "var_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt32" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt32" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt32" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt32" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt32" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "UInt32" - } - } - } - } - } - }, - "object_types": { - "TableOne": { - "fields": { - "ColumnA": { - "type": { - "type": "named", - "name": "String" - } - }, - "ColumnB": { - "type": { - "type": "array", - "element_type": { - "type": "named", - "name": "TableOne.ColumnB" - } - } - }, - "ColumnC": { - "type": { - "type": "array", - "element_type": { - "type": "named", - "name": "TableOne.ColumnC" - } - } - }, - "ColumnD": { - "type": { - "type": "named", - "name": "TableOne.ColumnD" - } - }, - "ColumnE": { - "type": { - "type": "named", - "name": "TableOne.ColumnE" - } - }, - "ColumnF": { - "type": { - "type": "named", - "name": "TableOne.ColumnF" - } - }, - "ColumnG": { - "type": { - "type": "named", - "name": "TableOne.ColumnG" - } - } - } - }, - "TableOne.ColumnB": { - "fields": { - "field1": { - "type": { - "type": "named", - "name": "String" - } - }, - "field2": { - "type": { - "type": "named", - "name": "String" - } - } - } - }, - "TableOne.ColumnC": { - "fields": { - "field1": { - "type": { - "type": "named", - "name": "String" - } - }, - "field2": { - "type": { - "type": "named", - "name": "String" - } - } - } - }, - "TableOne.ColumnD": { - "fields": { - "child": { - "type": { - "type": "named", - "name": "TableOne.ColumnD.child" - } - } - } - }, - "TableOne.ColumnD.child": { - "fields": { - "id": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "name": { - "type": { - "type": "named", - "name": "String" - } - } - } - }, - "TableOne.ColumnE": { - "fields": { - "child": { - "type": { - "type": "array", - "element_type": { - "type": "named", - "name": "TableOne.ColumnE.child" - } - } - } - } - }, - "TableOne.ColumnE.child": { - "fields": { - "id": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "name": { - "type": { - "type": "named", - "name": "String" - } - } - } - }, - "TableOne.ColumnF": { - "fields": { - "child": { - "type": { - "type": "named", - "name": "TableOne.ColumnF.child" - } - } - } - }, - "TableOne.ColumnF.child": { - "fields": { - "id": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "name": { - "type": { - "type": "named", - "name": "String" - } - }, - "toys": { - "type": { - "type": "array", - "element_type": { - "type": "named", - "name": "TableOne.ColumnF.child.toys" - } - } - } - } - }, - "TableOne.ColumnF.child.toys": { - "fields": { - "id": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "name": { - "type": { - "type": "named", - "name": "String" - } - } - } - }, - "TableOne.ColumnG": { - "fields": { - "a": { - "type": { - "type": "nullable", - "underlying_type": { - "type": "named", - "name": "String" - } - } - }, - "b": { - "type": { - "type": "named", - "name": "Map(String, String)" - } - }, - "c": { - "type": { - "type": "array", - "element_type": { - "type": "named", - "name": "TableOne.ColumnG.c" - } - } - }, - "d": { - "type": { - "type": "named", - "name": "TableOne.ColumnG.d" - } - } - } - }, - "TableOne.ColumnG.c": { - "fields": { - "a": { - "type": { - "type": "named", - "name": "String" - } - }, - "b": { - "type": { - "type": "named", - "name": "Tuple(String, String)" - } - } - } - }, - "TableOne.ColumnG.d": { - "fields": { - "a": { - "type": { - "type": "named", - "name": "String" - } - }, - "b": { - "type": { - "type": "named", - "name": "String" - } - } - } - }, - "TableTwo": { - "fields": { - "Id": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "Name": { - "type": { - "type": "named", - "name": "String" - } - } - } - } - }, - "collections": [ - { - "name": "TableOne", - "arguments": {}, - "type": "TableOne", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "TableTwo", - "arguments": {}, - "type": "TableTwo", - "uniqueness_constraints": {}, - "foreign_keys": {} - } - ], - "functions": [], - "procedures": [] -} \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.parameters.txt deleted file mode 100644 index 9f76ce0..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.parameters.txt +++ /dev/null @@ -1,6 +0,0 @@ -param_p0=[('foo','bar')] -param_p1=[('foo','bar')] -param_p2=((1,'foo')) -param_p3=([(1,'foo')]) -param_p4=((1,'foo',[(2,'bar')])) -param_p5=(\N,{'foo':'bar'},[('foo',('foo','bar'))],('foo','bar')) diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.statement.sql b/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.statement.sql deleted file mode 100644 index dae2c71..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.statement.sql +++ /dev/null @@ -1,24 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("field1" Array(Tuple("subfield1" String)))))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple(groupArray(tuple("_row"."_field_field1"))) AS "_rowset" - FROM - ( - SELECT - arrayMap( - (_value) -> tuple(_value."field1"), - "_origin"."ColumnB" - ) AS "_field_field1" - FROM - "Schema1"."Table1" AS "_origin" - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.statement.sql b/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.statement.sql deleted file mode 100644 index 6e6bb2f..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.statement.sql +++ /dev/null @@ -1,21 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("field1" Array(Tuple("subfield1" String, "subfield2" String)))))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple(groupArray(tuple("_row"."_field_field1"))) AS "_rowset" - FROM - ( - SELECT - "_origin"."ColumnB" AS "_field_field1" - FROM - "Schema1"."Table1" AS "_origin" - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.statement.sql b/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.statement.sql deleted file mode 100644 index c925ede..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.statement.sql +++ /dev/null @@ -1,47 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("field1" String, "field2" Tuple("child" Tuple("id" UInt32, "name" String, "child" Tuple(rows Array(Tuple("name" String))))))))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple("_row"."_field_field1", "_row"."_field_field2") - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."ColumnA" AS "_field_field1", - tuple( - tuple( - "_origin"."ColumnD"."child"."id", - "_origin"."ColumnD"."child"."name", - "_rel_0_child"."_rowset" - ) - ) AS "_field_field2" - FROM - "Schema1"."Table1" AS "_origin" - LEFT JOIN ( - SELECT - tuple(groupArray(tuple("_row"."_field_name"))) AS "_rowset", - "_row"."_relkey_Id" AS "_relkey_Id" - FROM - ( - SELECT - "_origin"."Name" AS "_field_name", - "_origin"."Id" AS "_relkey_Id" - FROM - "Schema1"."Table2" AS "_origin" - ) AS "_row" - GROUP BY - "_row"."_relkey_Id" - ) AS "_rel_0_child" ON "_origin"."ColumnD"."child"."id" = "_rel_0_child"."_relkey_Id" - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.statement.sql b/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.statement.sql deleted file mode 100644 index 5ce92c5..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.statement.sql +++ /dev/null @@ -1,51 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("field1" String, "field2" Tuple("child" Tuple("id" UInt32, "name" String, "child" Tuple(rows Array(Tuple("name" String))), "toys" Array(Tuple("name" String)))))))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple("_row"."_field_field1", "_row"."_field_field2") - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."ColumnA" AS "_field_field1", - tuple( - tuple( - "_origin"."ColumnF"."child"."id", - "_origin"."ColumnF"."child"."name", - "_rel_0_child"."_rowset", - arrayMap( - (_value) -> tuple(_value."name"), - "_origin"."ColumnF"."child"."toys" - ) - ) - ) AS "_field_field2" - FROM - "Schema1"."Table1" AS "_origin" - LEFT JOIN ( - SELECT - tuple(groupArray(tuple("_row"."_field_name"))) AS "_rowset", - "_row"."_relkey_Id" AS "_relkey_Id" - FROM - ( - SELECT - "_origin"."Name" AS "_field_name", - "_origin"."Id" AS "_relkey_Id" - FROM - "Schema1"."Table2" AS "_origin" - ) AS "_row" - GROUP BY - "_row"."_relkey_Id" - ) AS "_rel_0_child" ON "_origin"."ColumnF"."child"."id" = "_rel_0_child"."_relkey_Id" - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.statement.sql b/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.statement.sql deleted file mode 100644 index 4e3d084..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.statement.sql +++ /dev/null @@ -1,30 +0,0 @@ -SELECT - toJSONString( - groupArray( - cast( - "_rowset"."_rowset", - 'Tuple(rows Array(Tuple("field1" String, "field2" Tuple("b" Map(String, String), "c" Array(Tuple("a" String, "b" Tuple(String, String))), "d" Tuple("a" String, "b" String)))))' - ) - ) - ) AS "rowsets" -FROM - ( - SELECT - tuple( - groupArray( - tuple("_row"."_field_field1", "_row"."_field_field2") - ) - ) AS "_rowset" - FROM - ( - SELECT - "_origin"."ColumnA" AS "_field_field1", - tuple( - "_origin"."ColumnG"."b", - "_origin"."ColumnG"."c", - "_origin"."ColumnG"."d" - ) AS "_field_field2" - FROM - "Schema1"."Table1" AS "_origin" - ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.parameters.txt b/crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.parameters.txt deleted file mode 100644 index e69de29..0000000 diff --git a/crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.request.json b/crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_query.request.json similarity index 86% rename from crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.request.json rename to crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_query.request.json index 077877a..b7f17ae 100644 --- a/crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.request.json +++ b/crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_query.request.json @@ -1,5 +1,5 @@ { - "$schema": "../../request.schema.json", + "$schema": "../request.schema.json", "collection": "q11", "query": { "fields": { diff --git a/crates/ndc-clickhouse/tests/query_builder/star_schema/02_native_query_with_predicate.request.json b/crates/ndc-clickhouse/tests/query_builder/star_schema/02_native_query_with_predicate.request.json new file mode 100644 index 0000000..a00c528 --- /dev/null +++ b/crates/ndc-clickhouse/tests/query_builder/star_schema/02_native_query_with_predicate.request.json @@ -0,0 +1,28 @@ +{ + "$schema": "../request.schema.json", + "collection": "q12", + "query": { + "fields": { + "revenue": { + "type": "column", + "column": "revenue", + "fields": null + } + }, + "predicate": { + "type": "binary_comparison_operator", + "column": { + "type": "column", + "name": "revenue", + "path": [] + }, + "operator": "_gte", + "value": { + "type": "scalar", + "value": 1 + } + } + }, + "arguments": {}, + "collection_relationships": {} +} \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/star_schema/_schema/schema.json b/crates/ndc-clickhouse/tests/query_builder/star_schema/_schema/schema.json deleted file mode 100644 index 059073a..0000000 --- a/crates/ndc-clickhouse/tests/query_builder/star_schema/_schema/schema.json +++ /dev/null @@ -1,1654 +0,0 @@ -{ - "scalar_types": { - "Date": { - "representation": { - "type": "string" - }, - "aggregate_functions": { - "max": { - "result_type": { - "type": "named", - "name": "Date" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "Date" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Date" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Date" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Date" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Date" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Date" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "Date" - } - } - } - } - }, - "Int64": { - "representation": { - "type": "int64" - }, - "aggregate_functions": { - "avg": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "max": { - "result_type": { - "type": "named", - "name": "Int64" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "Int64" - } - }, - "stddev_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "stddev_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "sum": { - "result_type": { - "type": "named", - "name": "Int64" - } - }, - "var_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "var_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Int64" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Int64" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Int64" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Int64" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "Int64" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "Int64" - } - } - } - } - }, - "String": { - "representation": { - "type": "string" - }, - "aggregate_functions": {}, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_ilike": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_in": { - "type": "in" - }, - "_like": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_match": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_nilike": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "String" - } - } - }, - "_nlike": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "String" - } - } - } - }, - "UInt16": { - "representation": { - "type": "int32" - }, - "aggregate_functions": { - "avg": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "max": { - "result_type": { - "type": "named", - "name": "UInt16" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "UInt16" - } - }, - "stddev_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "stddev_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "sum": { - "result_type": { - "type": "named", - "name": "UInt64" - } - }, - "var_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "var_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt16" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt16" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt16" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt16" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt16" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "UInt16" - } - } - } - } - }, - "UInt32": { - "representation": { - "type": "int64" - }, - "aggregate_functions": { - "avg": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "max": { - "result_type": { - "type": "named", - "name": "UInt32" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "UInt32" - } - }, - "stddev_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "stddev_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "sum": { - "result_type": { - "type": "named", - "name": "UInt64" - } - }, - "var_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "var_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt32" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt32" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt32" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt32" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt32" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "UInt32" - } - } - } - } - }, - "UInt64": { - "representation": { - "type": "biginteger" - }, - "aggregate_functions": { - "avg": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "max": { - "result_type": { - "type": "named", - "name": "UInt64" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "UInt64" - } - }, - "stddev_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "stddev_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "sum": { - "result_type": { - "type": "named", - "name": "UInt64" - } - }, - "var_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "var_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt64" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt64" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt64" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt64" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt64" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "UInt64" - } - } - } - } - }, - "UInt8": { - "representation": { - "type": "int16" - }, - "aggregate_functions": { - "avg": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "max": { - "result_type": { - "type": "named", - "name": "UInt8" - } - }, - "min": { - "result_type": { - "type": "named", - "name": "UInt8" - } - }, - "stddev_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "stddev_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "sum": { - "result_type": { - "type": "named", - "name": "UInt64" - } - }, - "var_pop": { - "result_type": { - "type": "named", - "name": "Float64" - } - }, - "var_samp": { - "result_type": { - "type": "named", - "name": "Float64" - } - } - }, - "comparison_operators": { - "_eq": { - "type": "equal" - }, - "_gt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt8" - } - }, - "_gte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt8" - } - }, - "_in": { - "type": "in" - }, - "_lt": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt8" - } - }, - "_lte": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt8" - } - }, - "_neq": { - "type": "custom", - "argument_type": { - "type": "named", - "name": "UInt8" - } - }, - "_nin": { - "type": "custom", - "argument_type": { - "type": "array", - "element_type": { - "type": "named", - "name": "UInt8" - } - } - } - } - } - }, - "object_types": { - "q11": { - "fields": { - "revenue": { - "type": { - "type": "named", - "name": "UInt64" - } - } - } - }, - "q13": { - "fields": { - "revenue": { - "type": { - "type": "named", - "name": "UInt64" - } - } - } - }, - "q21": { - "fields": { - "P_BRAND": { - "type": { - "type": "named", - "name": "String" - } - }, - "sum(LO_REVENUE)": { - "type": { - "type": "named", - "name": "UInt64" - } - }, - "year": { - "type": { - "type": "named", - "name": "UInt16" - } - } - } - }, - "q22": { - "fields": { - "P_BRAND": { - "type": { - "type": "named", - "name": "String" - } - }, - "sum(LO_REVENUE)": { - "type": { - "type": "named", - "name": "UInt64" - } - }, - "year": { - "type": { - "type": "named", - "name": "UInt16" - } - } - } - }, - "q23": { - "fields": { - "P_BRAND": { - "type": { - "type": "named", - "name": "String" - } - }, - "sum(LO_REVENUE)": { - "type": { - "type": "named", - "name": "UInt64" - } - }, - "year": { - "type": { - "type": "named", - "name": "UInt16" - } - } - } - }, - "q31": { - "fields": { - "C_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "revenue": { - "type": { - "type": "named", - "name": "UInt64" - } - }, - "year": { - "type": { - "type": "named", - "name": "UInt16" - } - } - } - }, - "q32": { - "fields": { - "C_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "revenue": { - "type": { - "type": "named", - "name": "UInt64" - } - }, - "year": { - "type": { - "type": "named", - "name": "UInt16" - } - } - } - }, - "q33": { - "fields": { - "C_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "revenue": { - "type": { - "type": "named", - "name": "UInt64" - } - }, - "year": { - "type": { - "type": "named", - "name": "UInt16" - } - } - } - }, - "q34": { - "fields": { - "C_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "revenue": { - "type": { - "type": "named", - "name": "UInt64" - } - }, - "year": { - "type": { - "type": "named", - "name": "UInt16" - } - } - } - }, - "q41": { - "fields": { - "C_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "profit": { - "type": { - "type": "named", - "name": "Int64" - } - }, - "year": { - "type": { - "type": "named", - "name": "UInt16" - } - } - } - }, - "q42": { - "fields": { - "P_CATEGORY": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "profit": { - "type": { - "type": "named", - "name": "Int64" - } - }, - "year": { - "type": { - "type": "named", - "name": "UInt16" - } - } - } - }, - "q43": { - "fields": { - "P_BRAND": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_CITY": { - "type": { - "type": "named", - "name": "String" - } - }, - "profit": { - "type": { - "type": "named", - "name": "Int64" - } - }, - "year": { - "type": { - "type": "named", - "name": "UInt16" - } - } - } - }, - "star_customer": { - "description": "", - "fields": { - "C_ADDRESS": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_CITY": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_CUSTKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "C_MKTSEGMENT": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_NAME": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_PHONE": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_REGION": { - "type": { - "type": "named", - "name": "String" - } - } - } - }, - "star_lineorder": { - "description": "", - "fields": { - "LO_COMMITDATE": { - "type": { - "type": "named", - "name": "Date" - } - }, - "LO_CUSTKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_DISCOUNT": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "LO_EXTENDEDPRICE": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_LINENUMBER": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "LO_ORDERDATE": { - "type": { - "type": "named", - "name": "Date" - } - }, - "LO_ORDERKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_ORDERPRIORITY": { - "type": { - "type": "named", - "name": "String" - } - }, - "LO_ORDTOTALPRICE": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_PARTKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_QUANTITY": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "LO_REVENUE": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_SHIPMODE": { - "type": { - "type": "named", - "name": "String" - } - }, - "LO_SHIPPRIORITY": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "LO_SUPPKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_SUPPLYCOST": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_TAX": { - "type": { - "type": "named", - "name": "UInt8" - } - } - } - }, - "star_lineorder_flat": { - "description": "", - "fields": { - "C_ADDRESS": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_CITY": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_MKTSEGMENT": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_NAME": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_PHONE": { - "type": { - "type": "named", - "name": "String" - } - }, - "C_REGION": { - "type": { - "type": "named", - "name": "String" - } - }, - "LO_COMMITDATE": { - "type": { - "type": "named", - "name": "Date" - } - }, - "LO_CUSTKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_DISCOUNT": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "LO_EXTENDEDPRICE": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_LINENUMBER": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "LO_ORDERDATE": { - "type": { - "type": "named", - "name": "Date" - } - }, - "LO_ORDERKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_ORDERPRIORITY": { - "type": { - "type": "named", - "name": "String" - } - }, - "LO_ORDTOTALPRICE": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_PARTKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_QUANTITY": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "LO_REVENUE": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_SHIPMODE": { - "type": { - "type": "named", - "name": "String" - } - }, - "LO_SHIPPRIORITY": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "LO_SUPPKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_SUPPLYCOST": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "LO_TAX": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "P_BRAND": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_CATEGORY": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_COLOR": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_CONTAINER": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_MFGR": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_NAME": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_SIZE": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "P_TYPE": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_ADDRESS": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_CITY": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_NAME": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_PHONE": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_REGION": { - "type": { - "type": "named", - "name": "String" - } - } - } - }, - "star_part": { - "description": "", - "fields": { - "P_BRAND": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_CATEGORY": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_COLOR": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_CONTAINER": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_MFGR": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_NAME": { - "type": { - "type": "named", - "name": "String" - } - }, - "P_PARTKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - }, - "P_SIZE": { - "type": { - "type": "named", - "name": "UInt8" - } - }, - "P_TYPE": { - "type": { - "type": "named", - "name": "String" - } - } - } - }, - "star_supplier": { - "description": "", - "fields": { - "S_ADDRESS": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_CITY": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_NAME": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_NATION": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_PHONE": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_REGION": { - "type": { - "type": "named", - "name": "String" - } - }, - "S_SUPPKEY": { - "type": { - "type": "named", - "name": "UInt32" - } - } - } - } - }, - "collections": [ - { - "name": "star_customer", - "description": "", - "arguments": {}, - "type": "star_customer", - "uniqueness_constraints": { - "C_CUSTKEY": { - "unique_columns": [ - "C_CUSTKEY" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "star_lineorder", - "description": "", - "arguments": {}, - "type": "star_lineorder", - "uniqueness_constraints": { - "LO_ORDERDATE, LO_ORDERKEY": { - "unique_columns": [ - "LO_ORDERKEY", - "LO_ORDERDATE" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "star_lineorder_flat", - "description": "", - "arguments": {}, - "type": "star_lineorder_flat", - "uniqueness_constraints": { - "LO_ORDERDATE, LO_ORDERKEY": { - "unique_columns": [ - "LO_ORDERKEY", - "LO_ORDERDATE" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "star_part", - "description": "", - "arguments": {}, - "type": "star_part", - "uniqueness_constraints": { - "P_PARTKEY": { - "unique_columns": [ - "P_PARTKEY" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "star_supplier", - "description": "", - "arguments": {}, - "type": "star_supplier", - "uniqueness_constraints": { - "S_SUPPKEY": { - "unique_columns": [ - "S_SUPPKEY" - ] - } - }, - "foreign_keys": {} - }, - { - "name": "q11", - "arguments": {}, - "type": "q11", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q12", - "arguments": {}, - "type": "q11", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q13", - "arguments": {}, - "type": "q13", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q21", - "arguments": {}, - "type": "q21", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q22", - "arguments": {}, - "type": "q22", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q23", - "arguments": {}, - "type": "q23", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q31", - "arguments": {}, - "type": "q31", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q32", - "arguments": {}, - "type": "q32", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q33", - "arguments": {}, - "type": "q33", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q34", - "arguments": {}, - "type": "q34", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q41", - "arguments": {}, - "type": "q41", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q42", - "arguments": {}, - "type": "q42", - "uniqueness_constraints": {}, - "foreign_keys": {} - }, - { - "name": "q43", - "arguments": {}, - "type": "q43", - "uniqueness_constraints": {}, - "foreign_keys": {} - } - ], - "functions": [], - "procedures": [] -} \ No newline at end of file diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_01_select_rows.request.json.snap similarity index 74% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_01_select_rows.request.json.snap index 6d3e6f9..d903d46 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/01_select_rows.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_01_select_rows.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_01_select_rows.request.json +--- SELECT toJSONString( groupArray( @@ -28,4 +33,4 @@ FROM FROM "Chinook"."Album" AS "_origin" ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_02_with_predicate.request.json.snap similarity index 75% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_02_with_predicate.request.json.snap index f3a8cb4..a9fd95e 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_02_with_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_02_with_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -30,4 +35,4 @@ FROM WHERE "_origin"."ArtistId" = '1' ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_03_larger_predicate.request.json.snap similarity index 76% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_03_larger_predicate.request.json.snap index 146636b..85df50c 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_03_larger_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_03_larger_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -33,4 +38,4 @@ FROM AND NOT ("_origin"."ArtistId" = '2') ) ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_04_limit.request.json.snap similarity index 75% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_04_limit.request.json.snap index 3063baa..e3c34f0 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/04_limit.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_04_limit.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_04_limit.request.json +--- SELECT toJSONString( groupArray( @@ -30,4 +35,4 @@ FROM LIMIT 10 ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_05_offset.request.json.snap similarity index 74% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_05_offset.request.json.snap index c54bca3..6cdaff9 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/05_offset.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_05_offset.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_05_offset.request.json +--- SELECT toJSONString( groupArray( @@ -28,4 +33,4 @@ FROM FROM "Chinook"."Album" AS "_origin" OFFSET 10 ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_06_limit_offset.request.json.snap similarity index 75% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_06_limit_offset.request.json.snap index 20d8f04..bc54980 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/06_limit_offset.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_06_limit_offset.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_06_limit_offset.request.json +--- SELECT toJSONString( groupArray( @@ -30,4 +35,4 @@ FROM LIMIT 10 OFFSET 10 ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_07_order_by.request.json.snap similarity index 75% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_07_order_by.request.json.snap index d9df4f4..54b222f 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/07_order_by.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_07_order_by.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_07_order_by.request.json +--- SELECT toJSONString( groupArray( @@ -30,4 +35,4 @@ FROM ORDER BY "_origin"."ArtistId" ASC ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_08_predicate_limit_offset_order_by.request.json.snap similarity index 76% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_08_predicate_limit_offset_order_by.request.json.snap index 3e74d6d..49a6dd3 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@01_simple_queries_08_predicate_limit_offset_order_by.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_08_predicate_limit_offset_order_by.request.json +--- SELECT toJSONString( groupArray( @@ -34,4 +39,4 @@ FROM LIMIT 10 OFFSET 10 ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_01_object_relationship.request.json.snap similarity index 86% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_01_object_relationship.request.json.snap index 80d4b9a..23e1389 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/01_object_relationship.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_01_object_relationship.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_01_object_relationship.request.json +--- SELECT toJSONString( groupArray( @@ -50,4 +55,4 @@ FROM "_row"."_relkey_ArtistId" ) AS "_rel_0_Artist" ON "_origin"."ArtistId" = "_rel_0_Artist"."_relkey_ArtistId" ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_02_array_relationship.request.json.snap similarity index 88% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_02_array_relationship.request.json.snap index ebf6a7d..83250ef 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/02_array_relationship.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_02_array_relationship.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_02_array_relationship.request.json +--- SELECT toJSONString( groupArray( @@ -55,4 +60,4 @@ FROM "_row"."_relkey_AlbumId" ) AS "_rel_0_Tracks" ON "_origin"."AlbumId" = "_rel_0_Tracks"."_relkey_AlbumId" ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_03_parent_predicate.request.json.snap similarity index 88% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_03_parent_predicate.request.json.snap index 374b8b7..782d0b4 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_03_parent_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_03_parent_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -57,4 +62,4 @@ FROM WHERE "_origin"."ArtistId" > '10' ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_04_child_predicate.request.json.snap similarity index 88% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_04_child_predicate.request.json.snap index eea2e1e..bbf1176 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_04_child_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_04_child_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -59,4 +64,4 @@ FROM WHERE "_origin"."ArtistId" > '10' ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_05_traverse_relationship_in_predicate.request.json.snap similarity index 89% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_05_traverse_relationship_in_predicate.request.json.snap index ab269b8..6f86f28 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_05_traverse_relationship_in_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_05_traverse_relationship_in_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -68,4 +73,4 @@ FROM WHERE "_exists_0"."_exists_0" = TRUE ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_06_traverse_relationship_in_order_by.request.json.snap similarity index 91% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_06_traverse_relationship_in_order_by.request.json.snap index 0839ad6..a996d22 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/06_traverse_relationship_in_order_by.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_06_traverse_relationship_in_order_by.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_06_traverse_relationship_in_order_by.request.json +--- SELECT toJSONString( groupArray( @@ -77,4 +82,4 @@ FROM "_order_by_0"."_order_by_value" ASC, "_origin"."Name" ASC ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_07_order_by_aggregate_across_relationships.request.json.snap similarity index 90% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_07_order_by_aggregate_across_relationships.request.json.snap index db6585a..5f1b869 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/07_order_by_aggregate_across_relationships.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@02_relationships_07_order_by_aggregate_across_relationships.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_07_order_by_aggregate_across_relationships.request.json +--- SELECT toJSONString( groupArray( @@ -73,4 +78,4 @@ FROM "_order_by_1"."_order_by_value" ASC, "_order_by_2"."_order_by_value" ASC ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@03_variables_01_simple_predicate.request.json.snap similarity index 83% rename from crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@03_variables_01_simple_predicate.request.json.snap index f6a1260..bb73183 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@03_variables_01_simple_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_01_simple_predicate.request.json +--- WITH "_vars" AS ( SELECT * @@ -45,4 +50,4 @@ FROM ) AS "_row" GROUP BY "_row"."_varset_id" - ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@03_variables_02_empty_variable_sets.request.json.snap similarity index 83% rename from crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@03_variables_02_empty_variable_sets.request.json.snap index cd9a3a5..841bbc0 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@03_variables_02_empty_variable_sets.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_02_empty_variable_sets.request.json +--- WITH "_vars" AS ( SELECT * @@ -42,4 +47,4 @@ FROM ) AS "_row" GROUP BY "_row"."_varset_id" - ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@03_variables_03_single_set.request.json.snap similarity index 84% rename from crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@03_variables_03_single_set.request.json.snap index 4c8543a..cdabce5 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Inlined SQL@03_variables_03_single_set.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_03_single_set.request.json +--- WITH "_vars" AS ( SELECT * @@ -45,4 +50,4 @@ FROM ) AS "_row" GROUP BY "_row"."_varset_id" - ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@01_simple_queries_02_with_predicate.request.json.snap similarity index 75% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@01_simple_queries_02_with_predicate.request.json.snap index f93ae9e..2f915a6 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/02_with_predicate.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@01_simple_queries_02_with_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_02_with_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -30,4 +35,4 @@ FROM WHERE "_origin"."ArtistId" = { p0 :Int32 } ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@01_simple_queries_03_larger_predicate.request.json.snap similarity index 76% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@01_simple_queries_03_larger_predicate.request.json.snap index 5189ff6..c8a6f59 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/03_larger_predicate.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@01_simple_queries_03_larger_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_03_larger_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -33,4 +38,4 @@ FROM AND NOT ("_origin"."ArtistId" = { p1 :Int32 }) ) ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@01_simple_queries_08_predicate_limit_offset_order_by.request.json.snap similarity index 75% rename from crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@01_simple_queries_08_predicate_limit_offset_order_by.request.json.snap index 840f9a3..4dd7e94 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries/08_predicate_limit_offset_order_by.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@01_simple_queries_08_predicate_limit_offset_order_by.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_08_predicate_limit_offset_order_by.request.json +--- SELECT toJSONString( groupArray( @@ -34,4 +39,4 @@ FROM LIMIT 10 OFFSET 10 ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@02_relationships_03_parent_predicate.request.json.snap similarity index 88% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@02_relationships_03_parent_predicate.request.json.snap index eb4a050..0a4a490 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/03_parent_predicate.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@02_relationships_03_parent_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_03_parent_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -57,4 +62,4 @@ FROM WHERE "_origin"."ArtistId" > { p0 :Int32 } ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@02_relationships_04_child_predicate.request.json.snap similarity index 88% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@02_relationships_04_child_predicate.request.json.snap index f522d94..d5f3aa0 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/04_child_predicate.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@02_relationships_04_child_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_04_child_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -59,4 +64,4 @@ FROM WHERE "_origin"."ArtistId" > { p1 :Int32 } ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@02_relationships_05_traverse_relationship_in_predicate.request.json.snap similarity index 89% rename from crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@02_relationships_05_traverse_relationship_in_predicate.request.json.snap index c4c02e8..00fcc57 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships/05_traverse_relationship_in_predicate.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@02_relationships_05_traverse_relationship_in_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_05_traverse_relationship_in_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -68,4 +73,4 @@ FROM WHERE "_exists_0"."_exists_0" = TRUE ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@03_variables_01_simple_predicate.request.json.snap similarity index 82% rename from crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@03_variables_01_simple_predicate.request.json.snap index e3706da..41b84c1 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/03_single_set.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@03_variables_01_simple_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_01_simple_predicate.request.json +--- WITH "_vars" AS ( SELECT * @@ -42,4 +47,4 @@ FROM ) AS "_row" GROUP BY "_row"."_varset_id" - ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@03_variables_02_empty_variable_sets.request.json.snap similarity index 82% rename from crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@03_variables_02_empty_variable_sets.request.json.snap index e3706da..66df19b 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/02_empty_variable_sets.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@03_variables_02_empty_variable_sets.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_02_empty_variable_sets.request.json +--- WITH "_vars" AS ( SELECT * @@ -42,4 +47,4 @@ FROM ) AS "_row" GROUP BY "_row"."_varset_id" - ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@03_variables_03_single_set.request.json.snap similarity index 83% rename from crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@03_variables_03_single_set.request.json.snap index e3706da..efc349c 100644 --- a/crates/ndc-clickhouse/tests/query_builder/chinook/03_variables/01_simple_predicate.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameterized SQL@03_variables_03_single_set.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_03_single_set.request.json +--- WITH "_vars" AS ( SELECT * @@ -42,4 +47,4 @@ FROM ) AS "_row" GROUP BY "_row"."_varset_id" - ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@01_simple_queries_02_with_predicate.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@01_simple_queries_02_with_predicate.request.json.snap new file mode 100644 index 0000000..e55b642 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@01_simple_queries_02_with_predicate.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_02_with_predicate.request.json +--- +param_p0=1 diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@01_simple_queries_03_larger_predicate.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@01_simple_queries_03_larger_predicate.request.json.snap new file mode 100644 index 0000000..6e802d1 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@01_simple_queries_03_larger_predicate.request.json.snap @@ -0,0 +1,7 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_03_larger_predicate.request.json +--- +param_p0=1 +param_p1=2 diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@01_simple_queries_08_predicate_limit_offset_order_by.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@01_simple_queries_08_predicate_limit_offset_order_by.request.json.snap new file mode 100644 index 0000000..26a05aa --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@01_simple_queries_08_predicate_limit_offset_order_by.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/01_simple_queries_08_predicate_limit_offset_order_by.request.json +--- +param_p0=10 diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@02_relationships_03_parent_predicate.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@02_relationships_03_parent_predicate.request.json.snap new file mode 100644 index 0000000..3e346d0 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@02_relationships_03_parent_predicate.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_03_parent_predicate.request.json +--- +param_p0=10 diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@02_relationships_04_child_predicate.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@02_relationships_04_child_predicate.request.json.snap new file mode 100644 index 0000000..5c1bb73 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@02_relationships_04_child_predicate.request.json.snap @@ -0,0 +1,7 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_04_child_predicate.request.json +--- +param_p0=10 +param_p1=10 diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@02_relationships_05_traverse_relationship_in_predicate.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@02_relationships_05_traverse_relationship_in_predicate.request.json.snap new file mode 100644 index 0000000..8959d3c --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@02_relationships_05_traverse_relationship_in_predicate.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/02_relationships_05_traverse_relationship_in_predicate.request.json +--- +param_p0=AC/DC diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@03_variables_01_simple_predicate.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@03_variables_01_simple_predicate.request.json.snap new file mode 100644 index 0000000..d91bafc --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@03_variables_01_simple_predicate.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_01_simple_predicate.request.json +--- +param_p0={"_varset_id":[1,2],"_var_ArtistId":[1,2]} diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@03_variables_02_empty_variable_sets.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@03_variables_02_empty_variable_sets.request.json.snap new file mode 100644 index 0000000..04fc2ac --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@03_variables_02_empty_variable_sets.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_02_empty_variable_sets.request.json +--- +param_p0={"_varset_id":[]} diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@03_variables_03_single_set.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@03_variables_03_single_set.request.json.snap new file mode 100644 index 0000000..a2b87d7 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Parameters@03_variables_03_single_set.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/chinook/03_variables_03_single_set.request.json +--- +param_p0={"_varset_id":[1],"_var_ArtistId":[1]} diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Schema Response.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Schema Response.snap new file mode 100644 index 0000000..913c802 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__chinook Schema Response.snap @@ -0,0 +1,776 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: schema +--- +scalar_types: + Date32: + representation: + type: string + aggregate_functions: + max: + result_type: + type: named + name: Date32 + min: + result_type: + type: named + name: Date32 + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: Date32 + _gte: + type: custom + argument_type: + type: named + name: Date32 + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: Date32 + _lte: + type: custom + argument_type: + type: named + name: Date32 + _neq: + type: custom + argument_type: + type: named + name: Date32 + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: Date32 + DateTime64(9): + representation: + type: string + aggregate_functions: + max: + result_type: + type: named + name: DateTime64(9) + min: + result_type: + type: named + name: DateTime64(9) + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: DateTime64(9) + _gte: + type: custom + argument_type: + type: named + name: DateTime64(9) + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: DateTime64(9) + _lte: + type: custom + argument_type: + type: named + name: DateTime64(9) + _neq: + type: custom + argument_type: + type: named + name: DateTime64(9) + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: DateTime64(9) + Float64: + representation: + type: float64 + aggregate_functions: + avg: + result_type: + type: named + name: Float64 + max: + result_type: + type: named + name: Float64 + min: + result_type: + type: named + name: Float64 + stddev_pop: + result_type: + type: named + name: Float64 + stddev_samp: + result_type: + type: named + name: Float64 + sum: + result_type: + type: named + name: Float64 + var_pop: + result_type: + type: named + name: Float64 + var_samp: + result_type: + type: named + name: Float64 + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: Float64 + _gte: + type: custom + argument_type: + type: named + name: Float64 + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: Float64 + _lte: + type: custom + argument_type: + type: named + name: Float64 + _neq: + type: custom + argument_type: + type: named + name: Float64 + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: Float64 + Int32: + representation: + type: int32 + aggregate_functions: + avg: + result_type: + type: named + name: Float64 + max: + result_type: + type: named + name: Int32 + min: + result_type: + type: named + name: Int32 + stddev_pop: + result_type: + type: named + name: Float64 + stddev_samp: + result_type: + type: named + name: Float64 + sum: + result_type: + type: named + name: Int64 + var_pop: + result_type: + type: named + name: Float64 + var_samp: + result_type: + type: named + name: Float64 + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: Int32 + _gte: + type: custom + argument_type: + type: named + name: Int32 + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: Int32 + _lte: + type: custom + argument_type: + type: named + name: Int32 + _neq: + type: custom + argument_type: + type: named + name: Int32 + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: Int32 + String: + representation: + type: string + aggregate_functions: {} + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: String + _gte: + type: custom + argument_type: + type: named + name: String + _ilike: + type: custom + argument_type: + type: named + name: String + _in: + type: in + _like: + type: custom + argument_type: + type: named + name: String + _lt: + type: custom + argument_type: + type: named + name: String + _lte: + type: custom + argument_type: + type: named + name: String + _match: + type: custom + argument_type: + type: named + name: String + _neq: + type: custom + argument_type: + type: named + name: String + _nilike: + type: custom + argument_type: + type: named + name: String + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: String + _nlike: + type: custom + argument_type: + type: named + name: String +object_types: + Chinook_Album: + description: "" + fields: + AlbumId: + type: + type: named + name: Int32 + ArtistId: + type: + type: named + name: Int32 + Title: + type: + type: named + name: String + Chinook_Artist: + description: "" + fields: + ArtistId: + type: + type: named + name: Int32 + Name: + type: + type: nullable + underlying_type: + type: named + name: String + Chinook_Customer: + description: "" + fields: + Address: + type: + type: nullable + underlying_type: + type: named + name: String + City: + type: + type: nullable + underlying_type: + type: named + name: String + Company: + type: + type: nullable + underlying_type: + type: named + name: String + Country: + type: + type: nullable + underlying_type: + type: named + name: String + CustomerId: + type: + type: named + name: Int32 + Email: + type: + type: named + name: String + Fax: + type: + type: nullable + underlying_type: + type: named + name: String + FirstName: + type: + type: named + name: String + LastName: + type: + type: named + name: String + Phone: + type: + type: nullable + underlying_type: + type: named + name: String + PostalCode: + type: + type: nullable + underlying_type: + type: named + name: String + State: + type: + type: nullable + underlying_type: + type: named + name: String + SupportRepId: + type: + type: nullable + underlying_type: + type: named + name: Int32 + Chinook_Employee: + description: "" + fields: + Address: + type: + type: nullable + underlying_type: + type: named + name: String + BirthDate: + type: + type: nullable + underlying_type: + type: named + name: Date32 + City: + type: + type: nullable + underlying_type: + type: named + name: String + Country: + type: + type: nullable + underlying_type: + type: named + name: String + Email: + type: + type: nullable + underlying_type: + type: named + name: String + EmployeeId: + type: + type: named + name: Int32 + Fax: + type: + type: nullable + underlying_type: + type: named + name: String + FirstName: + type: + type: named + name: String + HireDate: + type: + type: nullable + underlying_type: + type: named + name: Date32 + LastName: + type: + type: named + name: String + Phone: + type: + type: nullable + underlying_type: + type: named + name: String + PostalCode: + type: + type: nullable + underlying_type: + type: named + name: String + ReportsTo: + type: + type: nullable + underlying_type: + type: named + name: Int32 + State: + type: + type: nullable + underlying_type: + type: named + name: String + Title: + type: + type: nullable + underlying_type: + type: named + name: String + Chinook_Genre: + description: "" + fields: + GenreId: + type: + type: named + name: Int32 + Name: + type: + type: nullable + underlying_type: + type: named + name: String + Chinook_Invoice: + description: "" + fields: + BillingAddress: + type: + type: nullable + underlying_type: + type: named + name: String + BillingCity: + type: + type: nullable + underlying_type: + type: named + name: String + BillingCountry: + type: + type: nullable + underlying_type: + type: named + name: String + BillingPostalCode: + type: + type: nullable + underlying_type: + type: named + name: String + BillingState: + type: + type: nullable + underlying_type: + type: named + name: String + CustomerId: + type: + type: named + name: Int32 + InvoiceDate: + type: + type: named + name: DateTime64(9) + InvoiceId: + type: + type: named + name: Int32 + Total: + type: + type: named + name: Float64 + Chinook_InvoiceLine: + description: "" + fields: + InvoiceId: + type: + type: named + name: Int32 + InvoiceLineId: + type: + type: named + name: Int32 + Quantity: + type: + type: named + name: Int32 + TrackId: + type: + type: named + name: Int32 + UnitPrice: + type: + type: named + name: Float64 + Chinook_MediaType: + description: "" + fields: + MediaTypeId: + type: + type: named + name: Int32 + Name: + type: + type: nullable + underlying_type: + type: named + name: String + Chinook_Playlist: + description: "" + fields: + Name: + type: + type: nullable + underlying_type: + type: named + name: String + PlaylistId: + type: + type: named + name: Int32 + Chinook_PlaylistTrack: + description: "" + fields: + PlaylistId: + type: + type: named + name: Int32 + TrackId: + type: + type: named + name: Int32 + Chinook_Track: + description: "" + fields: + AlbumId: + type: + type: nullable + underlying_type: + type: named + name: Int32 + Bytes: + type: + type: nullable + underlying_type: + type: named + name: Int32 + Composer: + type: + type: nullable + underlying_type: + type: named + name: String + GenreId: + type: + type: nullable + underlying_type: + type: named + name: Int32 + MediaTypeId: + type: + type: named + name: Int32 + Milliseconds: + type: + type: named + name: Int32 + Name: + type: + type: named + name: String + TrackId: + type: + type: named + name: Int32 + UnitPrice: + type: + type: named + name: Float64 +collections: + - name: Chinook_Album + description: "" + arguments: {} + type: Chinook_Album + uniqueness_constraints: + AlbumId: + unique_columns: + - AlbumId + foreign_keys: {} + - name: Chinook_Artist + description: "" + arguments: {} + type: Chinook_Artist + uniqueness_constraints: + ArtistId: + unique_columns: + - ArtistId + foreign_keys: {} + - name: Chinook_Customer + description: "" + arguments: {} + type: Chinook_Customer + uniqueness_constraints: + CustomerId: + unique_columns: + - CustomerId + foreign_keys: {} + - name: Chinook_Employee + description: "" + arguments: {} + type: Chinook_Employee + uniqueness_constraints: + EmployeeId: + unique_columns: + - EmployeeId + foreign_keys: {} + - name: Chinook_Genre + description: "" + arguments: {} + type: Chinook_Genre + uniqueness_constraints: + GenreId: + unique_columns: + - GenreId + foreign_keys: {} + - name: Chinook_Invoice + description: "" + arguments: {} + type: Chinook_Invoice + uniqueness_constraints: + InvoiceId: + unique_columns: + - InvoiceId + foreign_keys: {} + - name: Chinook_InvoiceLine + description: "" + arguments: {} + type: Chinook_InvoiceLine + uniqueness_constraints: + InvoiceLineId: + unique_columns: + - InvoiceLineId + foreign_keys: {} + - name: Chinook_MediaType + description: "" + arguments: {} + type: Chinook_MediaType + uniqueness_constraints: + MediaTypeId: + unique_columns: + - MediaTypeId + foreign_keys: {} + - name: Chinook_Playlist + description: "" + arguments: {} + type: Chinook_Playlist + uniqueness_constraints: + PlaylistId: + unique_columns: + - PlaylistId + foreign_keys: {} + - name: Chinook_PlaylistTrack + description: "" + arguments: {} + type: Chinook_PlaylistTrack + uniqueness_constraints: + "PlaylistId, TrackId": + unique_columns: + - PlaylistId + - TrackId + foreign_keys: {} + - name: Chinook_Track + description: "" + arguments: {} + type: Chinook_Track + uniqueness_constraints: + TrackId: + unique_columns: + - TrackId + foreign_keys: {} +functions: [] +procedures: [] diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Expected Error@02_column_accessor_04_error_on_relationships_on_array_nested_field.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Expected Error@02_column_accessor_04_error_on_relationships_on_array_nested_field.request.json.snap new file mode 100644 index 0000000..3d4008a --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Expected Error@02_column_accessor_04_error_on_relationships_on_array_nested_field.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: err +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_04_error_on_relationships_on_array_nested_field.request.json +--- +Not supported: Relationships with fields nested in arrays diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@01_bind_complex_parameters.request.json.snap similarity index 79% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@01_bind_complex_parameters.request.json.snap index 7e2d7dc..9ce3704 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@01_bind_complex_parameters.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/01_bind_complex_parameters.request.json +--- SELECT toJSONString( groupArray( @@ -32,4 +37,4 @@ FROM ) ) ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@01_complex_parameters_01_bind.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@01_complex_parameters_01_bind.request.json.snap new file mode 100644 index 0000000..b5ec6a4 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@01_complex_parameters_01_bind.request.json.snap @@ -0,0 +1,40 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_01_bind.request.json +--- +SELECT + toJSONString( + groupArray( + cast( + "_rowset"."_rowset", + 'Tuple(rows Array(Tuple("field1" String)))' + ) + ) + ) AS "rowsets" +FROM + ( + SELECT + tuple(groupArray(tuple("_row"."_field_field1"))) AS "_rowset" + FROM + ( + SELECT + "_origin"."ColumnA" AS "_field_field1" + FROM + "Schema1"."Table1" AS "_origin" + WHERE + ( + "_origin"."ColumnB" = [('foo', 'bar')] + AND "_origin"."ColumnC" = [('foo', 'bar')] + AND "_origin"."ColumnD" = ((1, 'foo')) + AND "_origin"."ColumnE" = ([(1, 'foo')]) + AND "_origin"."ColumnF" = ((1, 'foo', [(2, 'bar')])) + AND "_origin"."ColumnG" = ( + NULL, + { 'foo': 'bar' }, + [('foo', ('foo', 'bar'))], + ('foo', 'bar') + ) + ) + ) AS "_row" + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@01_complex_parameters_02_variables.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@01_complex_parameters_02_variables.request.json.snap new file mode 100644 index 0000000..f007b76 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@01_complex_parameters_02_variables.request.json.snap @@ -0,0 +1,50 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_02_variables.request.json +--- +WITH "_vars" AS ( + SELECT + * + FROM + format( + JSONColumns, + '{"_varset_id":[1,2],"_var_var1":[[{"field1":"foo","field2":"bar"}],[{"field1":"foo","field2":"bar"}]],"_var_var2":[[{"field1":"foo","field2":"bar"}],[{"field1":"foo","field2":"bar"}]],"_var_var3":[{"child":{"id":1,"name":"foo"}},{"child":{"id":1,"name":"foo"}}],"_var_var4":[{"child":[{"id":1,"name":"foo"}]},{"child":[{"id":1,"name":"foo"}]}],"_var_var5":[{"child":{"id":1,"name":"foo","toys":[{"id":2,"name":"bar"}]}},{"child":{"id":1,"name":"foo","toys":[{"id":2,"name":"bar"}]}}],"_var_var6":[{"a":null,"b":{"foo":"bar"},"c":[{"a":"foo","b":["foo","bar"]}],"d":{"a":"foo","b":"bar"}},{"a":null,"b":{"foo":"bar"},"c":[{"a":"foo","b":["foo","bar"]}],"d":{"a":"foo","b":"bar"}}]}' + ) +) +SELECT + toJSONString( + groupArray( + cast( + "_rowset"."_rowset", + 'Tuple(rows Array(Tuple("field1" String)))' + ) + ) + ) AS "rowsets" +FROM + "_vars" AS "_vars" + LEFT JOIN ( + SELECT + tuple(groupArray(tuple("_row"."_field_field1"))) AS "_rowset", + "_row"."_varset_id" AS "_varset_id" + FROM + ( + SELECT + "_origin"."ColumnA" AS "_field_field1", + "_vars"."_varset_id" AS "_varset_id" + FROM + "_vars" AS "_vars" + CROSS JOIN "Schema1"."Table1" AS "_origin" + WHERE + ( + "_origin"."ColumnB" = "_vars"."_var_var1" + AND "_origin"."ColumnC" = "_vars"."_var_var2" + AND "_origin"."ColumnD" = "_vars"."_var_var3" + AND "_origin"."ColumnE" = "_vars"."_var_var4" + AND "_origin"."ColumnF" = "_vars"."_var_var5" + AND "_origin"."ColumnG" = "_vars"."_var_var6" + ) + ) AS "_row" + GROUP BY + "_row"."_varset_id" + ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_01_generate_column_accessor.request.json.snap similarity index 66% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_01_generate_column_accessor.request.json.snap index dae2c71..002ccb0 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/01_generate_column_accessor.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_01_generate_column_accessor.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_01_generate_column_accessor.request.json +--- SELECT toJSONString( groupArray( @@ -21,4 +26,4 @@ FROM FROM "Schema1"."Table1" AS "_origin" ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_02_skip_if_not_required.request.json.snap similarity index 64% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_02_skip_if_not_required.request.json.snap index 6e6bb2f..5fd6eb0 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/02_skip_if_not_required.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_02_skip_if_not_required.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_02_skip_if_not_required.request.json +--- SELECT toJSONString( groupArray( @@ -18,4 +23,4 @@ FROM FROM "Schema1"."Table1" AS "_origin" ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_03_support_relationships_on_nested_field.request.json.snap similarity index 83% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_03_support_relationships_on_nested_field.request.json.snap index c925ede..1c485d8 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/03_support_relationships_on_nested_field.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_03_support_relationships_on_nested_field.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_03_support_relationships_on_nested_field.request.json +--- SELECT toJSONString( groupArray( @@ -44,4 +49,4 @@ FROM "_row"."_relkey_Id" ) AS "_rel_0_child" ON "_origin"."ColumnD"."child"."id" = "_rel_0_child"."_relkey_Id" ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_05_complex_example.request.json.snap similarity index 86% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_05_complex_example.request.json.snap index 5ce92c5..e291d54 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/05_complex_example.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_05_complex_example.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_05_complex_example.request.json +--- SELECT toJSONString( groupArray( @@ -48,4 +53,4 @@ FROM "_row"."_relkey_Id" ) AS "_rel_0_child" ON "_origin"."ColumnF"."child"."id" = "_rel_0_child"."_relkey_Id" ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_06_no_useless_nested_accessors.request.json.snap similarity index 74% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_06_no_useless_nested_accessors.request.json.snap index 4e3d084..084099c 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/field_selector/06_no_useless_nested_accessors.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_column_accessor_06_no_useless_nested_accessors.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/02_column_accessor_06_no_useless_nested_accessors.request.json +--- SELECT toJSONString( groupArray( @@ -27,4 +32,4 @@ FROM FROM "Schema1"."Table1" AS "_origin" ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_variables_with_complex_parameters.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_variables_with_complex_parameters.request.json.snap new file mode 100644 index 0000000..0107a45 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Inlined SQL@02_variables_with_complex_parameters.request.json.snap @@ -0,0 +1,50 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/02_variables_with_complex_parameters.request.json +--- +WITH "_vars" AS ( + SELECT + * + FROM + format( + JSONColumns, + '{"_varset_id":[1,2],"_var_var1":[[{"field1":"foo","field2":"bar"}],[{"field1":"foo","field2":"bar"}]],"_var_var2":[[{"field1":"foo","field2":"bar"}],[{"field1":"foo","field2":"bar"}]],"_var_var3":[{"child":{"id":1,"name":"foo"}},{"child":{"id":1,"name":"foo"}}],"_var_var4":[{"child":[{"id":1,"name":"foo"}]},{"child":[{"id":1,"name":"foo"}]}],"_var_var5":[{"child":{"id":1,"name":"foo","toys":[{"id":2,"name":"bar"}]}},{"child":{"id":1,"name":"foo","toys":[{"id":2,"name":"bar"}]}}],"_var_var6":[{"a":null,"b":{"foo":"bar"},"c":[{"a":"foo","b":["foo","bar"]}],"d":{"a":"foo","b":"bar"}},{"a":null,"b":{"foo":"bar"},"c":[{"a":"foo","b":["foo","bar"]}],"d":{"a":"foo","b":"bar"}}]}' + ) +) +SELECT + toJSONString( + groupArray( + cast( + "_rowset"."_rowset", + 'Tuple(rows Array(Tuple("field1" String)))' + ) + ) + ) AS "rowsets" +FROM + "_vars" AS "_vars" + LEFT JOIN ( + SELECT + tuple(groupArray(tuple("_row"."_field_field1"))) AS "_rowset", + "_row"."_varset_id" AS "_varset_id" + FROM + ( + SELECT + "_origin"."ColumnA" AS "_field_field1", + "_vars"."_varset_id" AS "_varset_id" + FROM + "_vars" AS "_vars" + CROSS JOIN "Schema1"."Table1" AS "_origin" + WHERE + ( + "_origin"."ColumnB" = "_vars"."_var_var1" + AND "_origin"."ColumnC" = "_vars"."_var_var2" + AND "_origin"."ColumnD" = "_vars"."_var_var3" + AND "_origin"."ColumnE" = "_vars"."_var_var4" + AND "_origin"."ColumnF" = "_vars"."_var_var5" + AND "_origin"."ColumnG" = "_vars"."_var_var6" + ) + ) AS "_row" + GROUP BY + "_row"."_varset_id" + ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@01_bind_complex_parameters.request.json.snap similarity index 83% rename from crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@01_bind_complex_parameters.request.json.snap index b799206..29421ef 100644 --- a/crates/ndc-clickhouse/tests/query_builder/complex_columns/bound_parameters/01_bind_complex_parameters.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@01_bind_complex_parameters.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/01_bind_complex_parameters.request.json +--- SELECT toJSONString( groupArray( @@ -38,4 +43,4 @@ FROM ) } ) ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@01_complex_parameters_01_bind.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@01_complex_parameters_01_bind.request.json.snap new file mode 100644 index 0000000..6d8a858 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@01_complex_parameters_01_bind.request.json.snap @@ -0,0 +1,46 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_01_bind.request.json +--- +SELECT + toJSONString( + groupArray( + cast( + "_rowset"."_rowset", + 'Tuple(rows Array(Tuple("field1" String)))' + ) + ) + ) AS "rowsets" +FROM + ( + SELECT + tuple(groupArray(tuple("_row"."_field_field1"))) AS "_rowset" + FROM + ( + SELECT + "_origin"."ColumnA" AS "_field_field1" + FROM + "Schema1"."Table1" AS "_origin" + WHERE + ( + "_origin"."ColumnB" = { p0 :Array(Tuple(field1 String, field2 String)) } + AND "_origin"."ColumnC" = { p1 :Nested(field1 String, field2 String) } + AND "_origin"."ColumnD" = { p2 :Tuple(child Tuple(id UInt32, name String)) } + AND "_origin"."ColumnE" = { p3 :Tuple(child Array(Tuple(id UInt32, name String))) } + AND "_origin"."ColumnF" = { p4 :Tuple( + child Tuple( + id UInt32, + name String, + toys Nested(id UInt32, name String) + ) + ) } + AND "_origin"."ColumnG" = { p5 :Tuple( + a Nullable(String), + b Map(String, String), + c Array(Tuple(a String, b Tuple(String, String))), + d Tuple(a String, b String) + ) } + ) + ) AS "_row" + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@01_complex_parameters_02_variables.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@01_complex_parameters_02_variables.request.json.snap new file mode 100644 index 0000000..36ffdd0 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@01_complex_parameters_02_variables.request.json.snap @@ -0,0 +1,47 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_02_variables.request.json +--- +WITH "_vars" AS ( + SELECT + * + FROM + format(JSONColumns, { p0 :String }) +) +SELECT + toJSONString( + groupArray( + cast( + "_rowset"."_rowset", + 'Tuple(rows Array(Tuple("field1" String)))' + ) + ) + ) AS "rowsets" +FROM + "_vars" AS "_vars" + LEFT JOIN ( + SELECT + tuple(groupArray(tuple("_row"."_field_field1"))) AS "_rowset", + "_row"."_varset_id" AS "_varset_id" + FROM + ( + SELECT + "_origin"."ColumnA" AS "_field_field1", + "_vars"."_varset_id" AS "_varset_id" + FROM + "_vars" AS "_vars" + CROSS JOIN "Schema1"."Table1" AS "_origin" + WHERE + ( + "_origin"."ColumnB" = "_vars"."_var_var1" + AND "_origin"."ColumnC" = "_vars"."_var_var2" + AND "_origin"."ColumnD" = "_vars"."_var_var3" + AND "_origin"."ColumnE" = "_vars"."_var_var4" + AND "_origin"."ColumnF" = "_vars"."_var_var5" + AND "_origin"."ColumnG" = "_vars"."_var_var6" + ) + ) AS "_row" + GROUP BY + "_row"."_varset_id" + ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@02_variables_with_complex_parameters.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@02_variables_with_complex_parameters.request.json.snap new file mode 100644 index 0000000..a96ad6a --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameterized SQL@02_variables_with_complex_parameters.request.json.snap @@ -0,0 +1,47 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/02_variables_with_complex_parameters.request.json +--- +WITH "_vars" AS ( + SELECT + * + FROM + format(JSONColumns, { p0 :String }) +) +SELECT + toJSONString( + groupArray( + cast( + "_rowset"."_rowset", + 'Tuple(rows Array(Tuple("field1" String)))' + ) + ) + ) AS "rowsets" +FROM + "_vars" AS "_vars" + LEFT JOIN ( + SELECT + tuple(groupArray(tuple("_row"."_field_field1"))) AS "_rowset", + "_row"."_varset_id" AS "_varset_id" + FROM + ( + SELECT + "_origin"."ColumnA" AS "_field_field1", + "_vars"."_varset_id" AS "_varset_id" + FROM + "_vars" AS "_vars" + CROSS JOIN "Schema1"."Table1" AS "_origin" + WHERE + ( + "_origin"."ColumnB" = "_vars"."_var_var1" + AND "_origin"."ColumnC" = "_vars"."_var_var2" + AND "_origin"."ColumnD" = "_vars"."_var_var3" + AND "_origin"."ColumnE" = "_vars"."_var_var4" + AND "_origin"."ColumnF" = "_vars"."_var_var5" + AND "_origin"."ColumnG" = "_vars"."_var_var6" + ) + ) AS "_row" + GROUP BY + "_row"."_varset_id" + ) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@01_bind_complex_parameters.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@01_bind_complex_parameters.request.json.snap new file mode 100644 index 0000000..dd248cf --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@01_bind_complex_parameters.request.json.snap @@ -0,0 +1,11 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/01_bind_complex_parameters.request.json +--- +param_p0=[('foo','bar')] +param_p1=[('foo','bar')] +param_p2=((1,'foo')) +param_p3=([(1,'foo')]) +param_p4=((1,'foo',[(2,'bar')])) +param_p5=(\N,{'foo':'bar'},[('foo',('foo','bar'))],('foo','bar')) diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@01_complex_parameters_01_bind.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@01_complex_parameters_01_bind.request.json.snap new file mode 100644 index 0000000..5530e80 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@01_complex_parameters_01_bind.request.json.snap @@ -0,0 +1,11 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_01_bind.request.json +--- +param_p0=[('foo','bar')] +param_p1=[('foo','bar')] +param_p2=((1,'foo')) +param_p3=([(1,'foo')]) +param_p4=((1,'foo',[(2,'bar')])) +param_p5=(\N,{'foo':'bar'},[('foo',('foo','bar'))],('foo','bar')) diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@01_complex_parameters_02_variables.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@01_complex_parameters_02_variables.request.json.snap new file mode 100644 index 0000000..f1946b6 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@01_complex_parameters_02_variables.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/01_complex_parameters_02_variables.request.json +--- +param_p0={"_varset_id":[1,2],"_var_var1":[[{"field1":"foo","field2":"bar"}],[{"field1":"foo","field2":"bar"}]],"_var_var2":[[{"field1":"foo","field2":"bar"}],[{"field1":"foo","field2":"bar"}]],"_var_var3":[{"child":{"id":1,"name":"foo"}},{"child":{"id":1,"name":"foo"}}],"_var_var4":[{"child":[{"id":1,"name":"foo"}]},{"child":[{"id":1,"name":"foo"}]}],"_var_var5":[{"child":{"id":1,"name":"foo","toys":[{"id":2,"name":"bar"}]}},{"child":{"id":1,"name":"foo","toys":[{"id":2,"name":"bar"}]}}],"_var_var6":[{"a":null,"b":{"foo":"bar"},"c":[{"a":"foo","b":["foo","bar"]}],"d":{"a":"foo","b":"bar"}},{"a":null,"b":{"foo":"bar"},"c":[{"a":"foo","b":["foo","bar"]}],"d":{"a":"foo","b":"bar"}}]} diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@02_variables_with_complex_parameters.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@02_variables_with_complex_parameters.request.json.snap new file mode 100644 index 0000000..38378d1 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Parameters@02_variables_with_complex_parameters.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/complex_columns/02_variables_with_complex_parameters.request.json +--- +param_p0={"_varset_id":[1,2],"_var_var1":[[{"field1":"foo","field2":"bar"}],[{"field1":"foo","field2":"bar"}]],"_var_var2":[[{"field1":"foo","field2":"bar"}],[{"field1":"foo","field2":"bar"}]],"_var_var3":[{"child":{"id":1,"name":"foo"}},{"child":{"id":1,"name":"foo"}}],"_var_var4":[{"child":[{"id":1,"name":"foo"}]},{"child":[{"id":1,"name":"foo"}]}],"_var_var5":[{"child":{"id":1,"name":"foo","toys":[{"id":2,"name":"bar"}]}},{"child":{"id":1,"name":"foo","toys":[{"id":2,"name":"bar"}]}}],"_var_var6":[{"a":null,"b":{"foo":"bar"},"c":[{"a":"foo","b":["foo","bar"]}],"d":{"a":"foo","b":"bar"}},{"a":null,"b":{"foo":"bar"},"c":[{"a":"foo","b":["foo","bar"]}],"d":{"a":"foo","b":"bar"}}]} diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Schema Response.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Schema Response.snap new file mode 100644 index 0000000..13e0e18 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__complex_columns Schema Response.snap @@ -0,0 +1,336 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: schema +--- +scalar_types: + "Map(String, String)": + aggregate_functions: {} + comparison_operators: {} + String: + representation: + type: string + aggregate_functions: {} + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: String + _gte: + type: custom + argument_type: + type: named + name: String + _ilike: + type: custom + argument_type: + type: named + name: String + _in: + type: in + _like: + type: custom + argument_type: + type: named + name: String + _lt: + type: custom + argument_type: + type: named + name: String + _lte: + type: custom + argument_type: + type: named + name: String + _match: + type: custom + argument_type: + type: named + name: String + _neq: + type: custom + argument_type: + type: named + name: String + _nilike: + type: custom + argument_type: + type: named + name: String + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: String + _nlike: + type: custom + argument_type: + type: named + name: String + "Tuple(String, String)": + aggregate_functions: {} + comparison_operators: {} + UInt32: + representation: + type: int64 + aggregate_functions: + avg: + result_type: + type: named + name: Float64 + max: + result_type: + type: named + name: UInt32 + min: + result_type: + type: named + name: UInt32 + stddev_pop: + result_type: + type: named + name: Float64 + stddev_samp: + result_type: + type: named + name: Float64 + sum: + result_type: + type: named + name: UInt64 + var_pop: + result_type: + type: named + name: Float64 + var_samp: + result_type: + type: named + name: Float64 + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: UInt32 + _gte: + type: custom + argument_type: + type: named + name: UInt32 + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: UInt32 + _lte: + type: custom + argument_type: + type: named + name: UInt32 + _neq: + type: custom + argument_type: + type: named + name: UInt32 + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: UInt32 +object_types: + TableOne: + fields: + ColumnA: + type: + type: named + name: String + ColumnB: + type: + type: array + element_type: + type: named + name: TableOne.ColumnB + ColumnC: + type: + type: array + element_type: + type: named + name: TableOne.ColumnC + ColumnD: + type: + type: named + name: TableOne.ColumnD + ColumnE: + type: + type: named + name: TableOne.ColumnE + ColumnF: + type: + type: named + name: TableOne.ColumnF + ColumnG: + type: + type: named + name: TableOne.ColumnG + TableOne.ColumnB: + fields: + field1: + type: + type: named + name: String + field2: + type: + type: named + name: String + TableOne.ColumnC: + fields: + field1: + type: + type: named + name: String + field2: + type: + type: named + name: String + TableOne.ColumnD: + fields: + child: + type: + type: named + name: TableOne.ColumnD.child + TableOne.ColumnD.child: + fields: + id: + type: + type: named + name: UInt32 + name: + type: + type: named + name: String + TableOne.ColumnE: + fields: + child: + type: + type: array + element_type: + type: named + name: TableOne.ColumnE.child + TableOne.ColumnE.child: + fields: + id: + type: + type: named + name: UInt32 + name: + type: + type: named + name: String + TableOne.ColumnF: + fields: + child: + type: + type: named + name: TableOne.ColumnF.child + TableOne.ColumnF.child: + fields: + id: + type: + type: named + name: UInt32 + name: + type: + type: named + name: String + toys: + type: + type: array + element_type: + type: named + name: TableOne.ColumnF.child.toys + TableOne.ColumnF.child.toys: + fields: + id: + type: + type: named + name: UInt32 + name: + type: + type: named + name: String + TableOne.ColumnG: + fields: + a: + type: + type: nullable + underlying_type: + type: named + name: String + b: + type: + type: named + name: "Map(String, String)" + c: + type: + type: array + element_type: + type: named + name: TableOne.ColumnG.c + d: + type: + type: named + name: TableOne.ColumnG.d + TableOne.ColumnG.c: + fields: + a: + type: + type: named + name: String + b: + type: + type: named + name: "Tuple(String, String)" + TableOne.ColumnG.d: + fields: + a: + type: + type: named + name: String + b: + type: + type: named + name: String + TableTwo: + fields: + Id: + type: + type: named + name: UInt32 + Name: + type: + type: named + name: String +collections: + - name: TableOne + arguments: {} + type: TableOne + uniqueness_constraints: {} + foreign_keys: {} + - name: TableTwo + arguments: {} + type: TableTwo + uniqueness_constraints: {} + foreign_keys: {} +functions: [] +procedures: [] diff --git a/crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Inlined SQL@01_native_query.request.json.snap similarity index 75% rename from crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Inlined SQL@01_native_query.request.json.snap index 2568396..4b9ba55 100644 --- a/crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Inlined SQL@01_native_query.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_query.request.json +--- SELECT toJSONString( groupArray( @@ -27,4 +32,4 @@ FROM AND LO_QUANTITY < 25 ) AS "_origin" ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.parameterized_statement.sql b/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Inlined SQL@02_native_query_with_predicate.request.json.snap similarity index 56% rename from crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.parameterized_statement.sql rename to crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Inlined SQL@02_native_query_with_predicate.request.json.snap index 2568396..30334ea 100644 --- a/crates/ndc-clickhouse/tests/query_builder/star_schema/01_native_queries/01_native_query.parameterized_statement.sql +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Inlined SQL@02_native_query_with_predicate.request.json.snap @@ -1,3 +1,8 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: inlined_sql +input_file: crates/ndc-clickhouse/tests/query_builder/star_schema/02_native_query_with_predicate.request.json +--- SELECT toJSONString( groupArray( @@ -22,9 +27,11 @@ FROM FROM star.lineorder_flat WHERE - toYear(LO_ORDERDATE) = 1993 - AND LO_DISCOUNT BETWEEN 1 AND 3 - AND LO_QUANTITY < 25 + toYYYYMM(LO_ORDERDATE) = 199401 + AND LO_DISCOUNT BETWEEN 4 AND 6 + AND LO_QUANTITY BETWEEN 26 AND 35 ) AS "_origin" + WHERE + "_origin"."revenue" >= 1 ) AS "_row" - ) AS "_rowset" FORMAT TabSeparatedRaw; \ No newline at end of file + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Parameterized SQL@02_native_query_with_predicate.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Parameterized SQL@02_native_query_with_predicate.request.json.snap new file mode 100644 index 0000000..4d3cbc3 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Parameterized SQL@02_native_query_with_predicate.request.json.snap @@ -0,0 +1,37 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: parameterized_sql +input_file: crates/ndc-clickhouse/tests/query_builder/star_schema/02_native_query_with_predicate.request.json +--- +SELECT + toJSONString( + groupArray( + cast( + "_rowset"."_rowset", + 'Tuple(rows Array(Tuple("revenue" UInt64)))' + ) + ) + ) AS "rowsets" +FROM + ( + SELECT + tuple(groupArray(tuple("_row"."_field_revenue"))) AS "_rowset" + FROM + ( + SELECT + "_origin"."revenue" AS "_field_revenue" + FROM + ( + SELECT + sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue + FROM + star.lineorder_flat + WHERE + toYYYYMM(LO_ORDERDATE) = 199401 + AND LO_DISCOUNT BETWEEN 4 AND 6 + AND LO_QUANTITY BETWEEN 26 AND 35 + ) AS "_origin" + WHERE + "_origin"."revenue" >= { p0 :UInt64 } + ) AS "_row" + ) AS "_rowset" FORMAT TabSeparatedRaw; diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Parameters@02_native_query_with_predicate.request.json.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Parameters@02_native_query_with_predicate.request.json.snap new file mode 100644 index 0000000..f4ee1ee --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Parameters@02_native_query_with_predicate.request.json.snap @@ -0,0 +1,6 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: printed_parameters +input_file: crates/ndc-clickhouse/tests/query_builder/star_schema/02_native_query_with_predicate.request.json +--- +param_p0=1 diff --git a/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Schema Response.snap b/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Schema Response.snap new file mode 100644 index 0000000..ee05939 --- /dev/null +++ b/crates/ndc-clickhouse/tests/snapshots/query_builder__star_schema Schema Response.snap @@ -0,0 +1,1108 @@ +--- +source: crates/ndc-clickhouse/tests/query_builder.rs +expression: schema +--- +scalar_types: + Date: + representation: + type: string + aggregate_functions: + max: + result_type: + type: named + name: Date + min: + result_type: + type: named + name: Date + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: Date + _gte: + type: custom + argument_type: + type: named + name: Date + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: Date + _lte: + type: custom + argument_type: + type: named + name: Date + _neq: + type: custom + argument_type: + type: named + name: Date + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: Date + Int64: + representation: + type: int64 + aggregate_functions: + avg: + result_type: + type: named + name: Float64 + max: + result_type: + type: named + name: Int64 + min: + result_type: + type: named + name: Int64 + stddev_pop: + result_type: + type: named + name: Float64 + stddev_samp: + result_type: + type: named + name: Float64 + sum: + result_type: + type: named + name: Int64 + var_pop: + result_type: + type: named + name: Float64 + var_samp: + result_type: + type: named + name: Float64 + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: Int64 + _gte: + type: custom + argument_type: + type: named + name: Int64 + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: Int64 + _lte: + type: custom + argument_type: + type: named + name: Int64 + _neq: + type: custom + argument_type: + type: named + name: Int64 + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: Int64 + String: + representation: + type: string + aggregate_functions: {} + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: String + _gte: + type: custom + argument_type: + type: named + name: String + _ilike: + type: custom + argument_type: + type: named + name: String + _in: + type: in + _like: + type: custom + argument_type: + type: named + name: String + _lt: + type: custom + argument_type: + type: named + name: String + _lte: + type: custom + argument_type: + type: named + name: String + _match: + type: custom + argument_type: + type: named + name: String + _neq: + type: custom + argument_type: + type: named + name: String + _nilike: + type: custom + argument_type: + type: named + name: String + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: String + _nlike: + type: custom + argument_type: + type: named + name: String + UInt16: + representation: + type: int32 + aggregate_functions: + avg: + result_type: + type: named + name: Float64 + max: + result_type: + type: named + name: UInt16 + min: + result_type: + type: named + name: UInt16 + stddev_pop: + result_type: + type: named + name: Float64 + stddev_samp: + result_type: + type: named + name: Float64 + sum: + result_type: + type: named + name: UInt64 + var_pop: + result_type: + type: named + name: Float64 + var_samp: + result_type: + type: named + name: Float64 + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: UInt16 + _gte: + type: custom + argument_type: + type: named + name: UInt16 + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: UInt16 + _lte: + type: custom + argument_type: + type: named + name: UInt16 + _neq: + type: custom + argument_type: + type: named + name: UInt16 + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: UInt16 + UInt32: + representation: + type: int64 + aggregate_functions: + avg: + result_type: + type: named + name: Float64 + max: + result_type: + type: named + name: UInt32 + min: + result_type: + type: named + name: UInt32 + stddev_pop: + result_type: + type: named + name: Float64 + stddev_samp: + result_type: + type: named + name: Float64 + sum: + result_type: + type: named + name: UInt64 + var_pop: + result_type: + type: named + name: Float64 + var_samp: + result_type: + type: named + name: Float64 + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: UInt32 + _gte: + type: custom + argument_type: + type: named + name: UInt32 + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: UInt32 + _lte: + type: custom + argument_type: + type: named + name: UInt32 + _neq: + type: custom + argument_type: + type: named + name: UInt32 + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: UInt32 + UInt64: + representation: + type: biginteger + aggregate_functions: + avg: + result_type: + type: named + name: Float64 + max: + result_type: + type: named + name: UInt64 + min: + result_type: + type: named + name: UInt64 + stddev_pop: + result_type: + type: named + name: Float64 + stddev_samp: + result_type: + type: named + name: Float64 + sum: + result_type: + type: named + name: UInt64 + var_pop: + result_type: + type: named + name: Float64 + var_samp: + result_type: + type: named + name: Float64 + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: UInt64 + _gte: + type: custom + argument_type: + type: named + name: UInt64 + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: UInt64 + _lte: + type: custom + argument_type: + type: named + name: UInt64 + _neq: + type: custom + argument_type: + type: named + name: UInt64 + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: UInt64 + UInt8: + representation: + type: int16 + aggregate_functions: + avg: + result_type: + type: named + name: Float64 + max: + result_type: + type: named + name: UInt8 + min: + result_type: + type: named + name: UInt8 + stddev_pop: + result_type: + type: named + name: Float64 + stddev_samp: + result_type: + type: named + name: Float64 + sum: + result_type: + type: named + name: UInt64 + var_pop: + result_type: + type: named + name: Float64 + var_samp: + result_type: + type: named + name: Float64 + comparison_operators: + _eq: + type: equal + _gt: + type: custom + argument_type: + type: named + name: UInt8 + _gte: + type: custom + argument_type: + type: named + name: UInt8 + _in: + type: in + _lt: + type: custom + argument_type: + type: named + name: UInt8 + _lte: + type: custom + argument_type: + type: named + name: UInt8 + _neq: + type: custom + argument_type: + type: named + name: UInt8 + _nin: + type: custom + argument_type: + type: array + element_type: + type: named + name: UInt8 +object_types: + q11: + fields: + revenue: + type: + type: named + name: UInt64 + q13: + fields: + revenue: + type: + type: named + name: UInt64 + q21: + fields: + P_BRAND: + type: + type: named + name: String + sum(LO_REVENUE): + type: + type: named + name: UInt64 + year: + type: + type: named + name: UInt16 + q22: + fields: + P_BRAND: + type: + type: named + name: String + sum(LO_REVENUE): + type: + type: named + name: UInt64 + year: + type: + type: named + name: UInt16 + q23: + fields: + P_BRAND: + type: + type: named + name: String + sum(LO_REVENUE): + type: + type: named + name: UInt64 + year: + type: + type: named + name: UInt16 + q31: + fields: + C_NATION: + type: + type: named + name: String + S_NATION: + type: + type: named + name: String + revenue: + type: + type: named + name: UInt64 + year: + type: + type: named + name: UInt16 + q32: + fields: + C_NATION: + type: + type: named + name: String + S_NATION: + type: + type: named + name: String + revenue: + type: + type: named + name: UInt64 + year: + type: + type: named + name: UInt16 + q33: + fields: + C_NATION: + type: + type: named + name: String + S_NATION: + type: + type: named + name: String + revenue: + type: + type: named + name: UInt64 + year: + type: + type: named + name: UInt16 + q34: + fields: + C_NATION: + type: + type: named + name: String + S_NATION: + type: + type: named + name: String + revenue: + type: + type: named + name: UInt64 + year: + type: + type: named + name: UInt16 + q41: + fields: + C_NATION: + type: + type: named + name: String + profit: + type: + type: named + name: Int64 + year: + type: + type: named + name: UInt16 + q42: + fields: + P_CATEGORY: + type: + type: named + name: String + S_NATION: + type: + type: named + name: String + profit: + type: + type: named + name: Int64 + year: + type: + type: named + name: UInt16 + q43: + fields: + P_BRAND: + type: + type: named + name: String + S_CITY: + type: + type: named + name: String + profit: + type: + type: named + name: Int64 + year: + type: + type: named + name: UInt16 + star_customer: + description: "" + fields: + C_ADDRESS: + type: + type: named + name: String + C_CITY: + type: + type: named + name: String + C_CUSTKEY: + type: + type: named + name: UInt32 + C_MKTSEGMENT: + type: + type: named + name: String + C_NAME: + type: + type: named + name: String + C_NATION: + type: + type: named + name: String + C_PHONE: + type: + type: named + name: String + C_REGION: + type: + type: named + name: String + star_lineorder: + description: "" + fields: + LO_COMMITDATE: + type: + type: named + name: Date + LO_CUSTKEY: + type: + type: named + name: UInt32 + LO_DISCOUNT: + type: + type: named + name: UInt8 + LO_EXTENDEDPRICE: + type: + type: named + name: UInt32 + LO_LINENUMBER: + type: + type: named + name: UInt8 + LO_ORDERDATE: + type: + type: named + name: Date + LO_ORDERKEY: + type: + type: named + name: UInt32 + LO_ORDERPRIORITY: + type: + type: named + name: String + LO_ORDTOTALPRICE: + type: + type: named + name: UInt32 + LO_PARTKEY: + type: + type: named + name: UInt32 + LO_QUANTITY: + type: + type: named + name: UInt8 + LO_REVENUE: + type: + type: named + name: UInt32 + LO_SHIPMODE: + type: + type: named + name: String + LO_SHIPPRIORITY: + type: + type: named + name: UInt8 + LO_SUPPKEY: + type: + type: named + name: UInt32 + LO_SUPPLYCOST: + type: + type: named + name: UInt32 + LO_TAX: + type: + type: named + name: UInt8 + star_lineorder_flat: + description: "" + fields: + C_ADDRESS: + type: + type: named + name: String + C_CITY: + type: + type: named + name: String + C_MKTSEGMENT: + type: + type: named + name: String + C_NAME: + type: + type: named + name: String + C_NATION: + type: + type: named + name: String + C_PHONE: + type: + type: named + name: String + C_REGION: + type: + type: named + name: String + LO_COMMITDATE: + type: + type: named + name: Date + LO_CUSTKEY: + type: + type: named + name: UInt32 + LO_DISCOUNT: + type: + type: named + name: UInt8 + LO_EXTENDEDPRICE: + type: + type: named + name: UInt32 + LO_LINENUMBER: + type: + type: named + name: UInt8 + LO_ORDERDATE: + type: + type: named + name: Date + LO_ORDERKEY: + type: + type: named + name: UInt32 + LO_ORDERPRIORITY: + type: + type: named + name: String + LO_ORDTOTALPRICE: + type: + type: named + name: UInt32 + LO_PARTKEY: + type: + type: named + name: UInt32 + LO_QUANTITY: + type: + type: named + name: UInt8 + LO_REVENUE: + type: + type: named + name: UInt32 + LO_SHIPMODE: + type: + type: named + name: String + LO_SHIPPRIORITY: + type: + type: named + name: UInt8 + LO_SUPPKEY: + type: + type: named + name: UInt32 + LO_SUPPLYCOST: + type: + type: named + name: UInt32 + LO_TAX: + type: + type: named + name: UInt8 + P_BRAND: + type: + type: named + name: String + P_CATEGORY: + type: + type: named + name: String + P_COLOR: + type: + type: named + name: String + P_CONTAINER: + type: + type: named + name: String + P_MFGR: + type: + type: named + name: String + P_NAME: + type: + type: named + name: String + P_SIZE: + type: + type: named + name: UInt8 + P_TYPE: + type: + type: named + name: String + S_ADDRESS: + type: + type: named + name: String + S_CITY: + type: + type: named + name: String + S_NAME: + type: + type: named + name: String + S_NATION: + type: + type: named + name: String + S_PHONE: + type: + type: named + name: String + S_REGION: + type: + type: named + name: String + star_part: + description: "" + fields: + P_BRAND: + type: + type: named + name: String + P_CATEGORY: + type: + type: named + name: String + P_COLOR: + type: + type: named + name: String + P_CONTAINER: + type: + type: named + name: String + P_MFGR: + type: + type: named + name: String + P_NAME: + type: + type: named + name: String + P_PARTKEY: + type: + type: named + name: UInt32 + P_SIZE: + type: + type: named + name: UInt8 + P_TYPE: + type: + type: named + name: String + star_supplier: + description: "" + fields: + S_ADDRESS: + type: + type: named + name: String + S_CITY: + type: + type: named + name: String + S_NAME: + type: + type: named + name: String + S_NATION: + type: + type: named + name: String + S_PHONE: + type: + type: named + name: String + S_REGION: + type: + type: named + name: String + S_SUPPKEY: + type: + type: named + name: UInt32 +collections: + - name: star_customer + description: "" + arguments: {} + type: star_customer + uniqueness_constraints: + C_CUSTKEY: + unique_columns: + - C_CUSTKEY + foreign_keys: {} + - name: star_lineorder + description: "" + arguments: {} + type: star_lineorder + uniqueness_constraints: + "LO_ORDERDATE, LO_ORDERKEY": + unique_columns: + - LO_ORDERKEY + - LO_ORDERDATE + foreign_keys: {} + - name: star_lineorder_flat + description: "" + arguments: {} + type: star_lineorder_flat + uniqueness_constraints: + "LO_ORDERDATE, LO_ORDERKEY": + unique_columns: + - LO_ORDERKEY + - LO_ORDERDATE + foreign_keys: {} + - name: star_part + description: "" + arguments: {} + type: star_part + uniqueness_constraints: + P_PARTKEY: + unique_columns: + - P_PARTKEY + foreign_keys: {} + - name: star_supplier + description: "" + arguments: {} + type: star_supplier + uniqueness_constraints: + S_SUPPKEY: + unique_columns: + - S_SUPPKEY + foreign_keys: {} + - name: q11 + arguments: {} + type: q11 + uniqueness_constraints: {} + foreign_keys: {} + - name: q12 + arguments: {} + type: q11 + uniqueness_constraints: {} + foreign_keys: {} + - name: q13 + arguments: {} + type: q13 + uniqueness_constraints: {} + foreign_keys: {} + - name: q21 + arguments: {} + type: q21 + uniqueness_constraints: {} + foreign_keys: {} + - name: q22 + arguments: {} + type: q22 + uniqueness_constraints: {} + foreign_keys: {} + - name: q23 + arguments: {} + type: q23 + uniqueness_constraints: {} + foreign_keys: {} + - name: q31 + arguments: {} + type: q31 + uniqueness_constraints: {} + foreign_keys: {} + - name: q32 + arguments: {} + type: q32 + uniqueness_constraints: {} + foreign_keys: {} + - name: q33 + arguments: {} + type: q33 + uniqueness_constraints: {} + foreign_keys: {} + - name: q34 + arguments: {} + type: q34 + uniqueness_constraints: {} + foreign_keys: {} + - name: q41 + arguments: {} + type: q41 + uniqueness_constraints: {} + foreign_keys: {} + - name: q42 + arguments: {} + type: q42 + uniqueness_constraints: {} + foreign_keys: {} + - name: q43 + arguments: {} + type: q43 + uniqueness_constraints: {} + foreign_keys: {} +functions: [] +procedures: []