From efd5f644da26894dbcf15632ae7ab64440ae2aa8 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Mon, 8 Apr 2024 12:22:32 +0300 Subject: [PATCH 01/16] cast int64 to string --- crates/configuration/src/version3/mod.rs | 2 +- .../translation/src/translation/helpers.rs | 99 +- .../src/translation/query/fields.rs | 159 +- ...ests__select_composite_column_complex.snap | 57 +- ...tests__select_composite_column_simple.snap | 27 +- ...ts__select_composite_variable_complex.snap | 61 +- ...sts__select_composite_variable_simple.snap | 31 +- ...asic__select_composite_column_complex.snap | 8 +- ...ic__select_composite_variable_complex.snap | 16 +- ...uery_tests__types__select_value_types.snap | 4 +- ...asic__select_composite_column_complex.snap | 8 +- ...ic__select_composite_variable_complex.snap | 16 +- ...uery_tests__types__select_value_types.snap | 4 +- ...schema_tests__schema_test__get_schema.snap | 4 +- .../src/cockroach/query_tests.rs | 6 +- ...y_tests__basic__select_int_and_string.snap | 2 +- ...es__select_where_album_id_equals_self.snap | 2 +- ...s__select_where_album_id_greater_than.snap | 14 +- ...ere_album_id_greater_than_or_equal_to.snap | 16 +- ..._where_album_id_less_than_or_equal_to.snap | 2 +- ...__predicates__select_where_name_ilike.snap | 14 +- ...sts__predicates__select_where_name_in.snap | 2 +- ..._predicates__select_where_name_iregex.snap | 2 +- ...s__predicates__select_where_name_like.snap | 14 +- ...predicates__select_where_name_niregex.snap | 10 +- ..._predicates__select_where_name_not_in.snap | 10 +- ...redicates__select_where_name_not_like.snap | 10 +- ..._predicates__select_where_name_nregex.snap | 20 +- ...redicates__select_where_name_nsimilar.snap | 10 +- ...__predicates__select_where_name_regex.snap | 2 +- ...predicates__select_where_name_similar.snap | 10 +- ...predicates__select_where_variable_int.snap | 4 +- ...s__very_nested_recursive_relationship.snap | 10 +- ...uery_tests__types__select_value_types.snap | 4 +- ...schema_tests__schema_test__get_schema.snap | 2 +- .../src/postgres/query_tests.rs | 10 + ...v3_initial_configuration_is_unchanged.snap | 60 +- ...on_tests__basic__v1_insert_custom_dog.snap | 8 +- ...asic__select_composite_column_complex.snap | 8 +- ...ic__select_composite_variable_complex.snap | 16 +- ..._select_discoverable_composite_column.snap | 15 + ...uery_tests__types__select_value_types.snap | 4 +- ...schema_tests__schema_test__get_schema.snap | 4 +- ...asic__select_composite_column_complex.snap | 8 +- ...ic__select_composite_variable_complex.snap | 16 +- ...uery_tests__types__select_value_types.snap | 4 +- .../select_discoverable_composite_column.json | 14 + .../configuration.json | 2 +- .../configuration.json | 56 +- .../configuration.json | 2 +- static/composite-types-simple.sql | 4 +- .../configuration.json | 3978 +++++++++++++++++ .../summarize_organizations.sql | 22 + .../configuration.json | 2 +- .../configuration.json | 56 +- .../configuration.json | 56 +- 56 files changed, 4648 insertions(+), 359 deletions(-) create mode 100644 crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_discoverable_composite_column.snap create mode 100644 crates/tests/tests-common/goldenfiles/select_discoverable_composite_column.json create mode 100644 static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/configuration.json create mode 100644 static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/native_queries/summarize_organizations.sql diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index c2f04c167..2a179ecaf 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -246,7 +246,7 @@ fn base_type_representations() -> database::TypeRepresentations { // This is not what we do now and is a breaking change. // This will need to be changed in the future. In the meantime, we report // The type representation to be json. - database::TypeRepresentation::Json, + database::TypeRepresentation::Int64, ), ( database::ScalarType("numeric".to_string()), diff --git a/crates/query-engine/translation/src/translation/helpers.rs b/crates/query-engine/translation/src/translation/helpers.rs index bcd2cc5c7..e46f05cf2 100644 --- a/crates/query-engine/translation/src/translation/helpers.rs +++ b/crates/query-engine/translation/src/translation/helpers.rs @@ -25,6 +25,7 @@ pub struct State { } #[derive(Debug)] +/// Used for generating a unique name for intermediate tables. pub struct TableAliasIndex(pub u64); #[derive(Debug)] @@ -89,13 +90,17 @@ pub enum CollectionInfo<'env> { } #[derive(Debug)] -/// Metadata information about a specific collection. -pub enum CompositeTypeInfo<'env> { +/// Metadata information about a specific collection or composite type. +pub enum CollectionOrCompositeTypeInfo<'env> { CollectionInfo(CollectionInfo<'env>), - CompositeTypeInfo { - name: String, - info: metadata::CompositeType, - }, + CompositeTypeInfo(CompositeTypeInfo), +} + +#[derive(Debug)] +/// Information about composite types. +pub struct CompositeTypeInfo { + pub name: String, + pub info: metadata::CompositeType, } impl<'request> Env<'request> { @@ -114,22 +119,23 @@ impl<'request> Env<'request> { } } - /// Lookup a collection's information in the metadata. - - pub fn lookup_composite_type( + /// Lookup collection or composite type. + pub fn lookup_collection_or_composite_type( &self, type_name: &'request str, - ) -> Result, Error> { + ) -> Result, Error> { let it_is_a_collection = self.lookup_collection(type_name); match it_is_a_collection { - Ok(collection_info) => Ok(CompositeTypeInfo::CollectionInfo(collection_info)), + Ok(collection_info) => Ok(CollectionOrCompositeTypeInfo::CollectionInfo( + collection_info, + )), Err(Error::CollectionNotFound(_)) => { let its_a_type = self.metadata.composite_types.0.get(type_name).map(|t| { - CompositeTypeInfo::CompositeTypeInfo { + CollectionOrCompositeTypeInfo::CompositeTypeInfo(CompositeTypeInfo { name: t.name.clone(), info: t.clone(), - } + }) }); its_a_type.ok_or(Error::CollectionNotFound(type_name.to_string())) @@ -138,6 +144,21 @@ impl<'request> Env<'request> { } } + pub fn lookup_composite_type(&self, type_name: &str) -> Result { + let its_a_type = + self.metadata + .composite_types + .0 + .get(type_name) + .map(|t| CompositeTypeInfo { + name: t.name.clone(), + info: t.clone(), + }); + + its_a_type.ok_or(Error::CollectionNotFound(type_name.to_string())) + } + + /// Lookup a collection's information in the metadata. pub fn lookup_collection( &self, collection_name: &'request str, @@ -202,6 +223,23 @@ impl<'request> Env<'request> { }) } + /// Lookup type representation of a type. + pub fn lookup_type_representation( + &self, + typ: &metadata::Type, + ) -> Option { + match typ { + metadata::Type::ScalarType(scalar_type) => self + .metadata + .type_representations + .0 + .get(scalar_type) + .cloned(), + metadata::Type::ArrayType(_) => None, + metadata::Type::CompositeType(_) => None, + } + } + /// Try to get the variables table reference. This will fail if no variables were passed /// as part of the query request. pub fn get_variables_table(&self) -> Result { @@ -242,28 +280,37 @@ impl CollectionInfo<'_> { } } -impl CompositeTypeInfo<'_> { +impl CollectionOrCompositeTypeInfo<'_> { /// Lookup a column in a collection. pub fn lookup_column(&self, column_name: &str) -> Result { match self { - CompositeTypeInfo::CollectionInfo(collection_info) => { + CollectionOrCompositeTypeInfo::CollectionInfo(collection_info) => { collection_info.lookup_column(column_name) } - CompositeTypeInfo::CompositeTypeInfo { name, info } => info - .fields - .get(column_name) - .map(|field_info| ColumnInfo { - name: sql::ast::ColumnName(field_info.name.clone()), - r#type: field_info.r#type.clone(), - }) - .ok_or(Error::ColumnNotFoundInCollection( - column_name.to_string(), - name.clone(), - )), + CollectionOrCompositeTypeInfo::CompositeTypeInfo(composite_type) => { + composite_type.lookup_column(column_name) + } } } } +impl CompositeTypeInfo { + /// Lookup a column in a composite type. + pub fn lookup_column(&self, column_name: &str) -> Result { + self.info + .fields + .get(column_name) + .map(|field_info| ColumnInfo { + name: sql::ast::ColumnName(field_info.name.clone()), + r#type: field_info.r#type.clone(), + }) + .ok_or(Error::ColumnNotFoundInCollection( + column_name.to_string(), + self.name.clone(), + )) + } +} + impl Default for State { fn default() -> State { State { diff --git a/crates/query-engine/translation/src/translation/query/fields.rs b/crates/query-engine/translation/src/translation/query/fields.rs index c2ba1c9f5..3a1afb83f 100644 --- a/crates/query-engine/translation/src/translation/query/fields.rs +++ b/crates/query-engine/translation/src/translation/query/fields.rs @@ -1,13 +1,16 @@ //! Handle 'rows' and 'aggregates' translation. +use indexmap::indexmap; use indexmap::IndexMap; use ndc_sdk::models; use super::relationships; use crate::translation::error::Error; -use crate::translation::helpers::{ColumnInfo, Env, State, TableNameAndReference}; -use query_engine_metadata::metadata::Type; +use crate::translation::helpers::{ + CollectionOrCompositeTypeInfo, ColumnInfo, Env, State, TableNameAndReference, +}; +use query_engine_metadata::metadata::{Type, TypeRepresentation}; use query_engine_sql::sql; /// This type collects the salient parts of joined-on subqueries that compute the result of a @@ -41,7 +44,7 @@ pub(crate) fn translate_fields( join_relationship_fields: &mut Vec, ) -> Result { // find the table according to the metadata. - let type_info = env.lookup_composite_type(¤t_table.name)?; + let type_info = env.lookup_collection_or_composite_type(¤t_table.name)?; // Each nested field is computed in one joined-on sub query. let mut nested_field_joins: Vec = vec![]; @@ -52,14 +55,16 @@ pub(crate) fn translate_fields( models::Field::Column { column, fields: None, - } => { - let column_info = type_info.lookup_column(&column)?; - Ok(sql::helpers::make_column( - current_table.reference.clone(), - column_info.name.clone(), - sql::helpers::make_column_alias(alias), - )) - } + } => unpack_and_wrap_fields( + env, + state, + current_table, + join_relationship_fields, + &column, + sql::helpers::make_column_alias(alias), + &type_info, + &mut nested_field_joins, + ), models::Field::Column { column, fields: Some(nested_field), @@ -318,3 +323,135 @@ fn translate_nested_field( }, )) } + +#[allow(clippy::too_many_arguments)] +/// In order to return the expected type representation for each column, +/// we need to wrap columns in type representation cast, and unpack composite types +/// so we can wrap them. +fn unpack_and_wrap_fields( + env: &Env, + state: &mut State, + current_table: &TableNameAndReference, + join_relationship_fields: &mut Vec, + column: &str, + alias: sql::ast::ColumnAlias, + type_info: &CollectionOrCompositeTypeInfo<'_>, + nested_field_joins: &mut Vec, +) -> Result<(sql::ast::ColumnAlias, sql::ast::Expression), Error> { + let column_info = type_info.lookup_column(column)?; + + // Different kinds of types have different strategy for converting to their + // type representation. + match column_info.r#type { + // Scalar types can just be wrapped in a cast. + Type::ScalarType(_) => { + let column_type_representation = env.lookup_type_representation(&column_info.r#type); + let (alias, expression) = sql::helpers::make_column( + current_table.reference.clone(), + column_info.name.clone(), + alias, + ); + Ok(( + alias, + wrap_in_type_representation(expression, column_type_representation), + )) + } + // Composite types are a more involved case because we cannot just "cast" + // a composite type, we need to unpack it and cast the individual fields. + // In this case, we unpack a single composite column selection to an explicit + // selection of all fields. + Type::CompositeType(ref composite_type) => { + // build a nested field selection of all fields. + let nested_field = models::NestedField::Object({ + let composite_type = env.lookup_composite_type(composite_type)?; + let mut fields = indexmap!(); + for (name, field_info) in composite_type.info.fields.iter() { + fields.insert( + name.to_string(), + models::Field::Column { + column: field_info.name.clone(), + fields: None, + }, + ); + } + models::NestedObject { fields } + }); + + // translate this as if it is a nested field selection. + let (nested_field_join, nested_column_reference) = translate_nested_field( + env, + state, + current_table, + &column_info, + nested_field, + join_relationship_fields, + )?; + + nested_field_joins.push(nested_field_join); + + Ok(( + alias, + sql::ast::Expression::ColumnReference(nested_column_reference), + )) + } + // TODO: Arrays for composite types and nested arrays are not handled yet. + Type::ArrayType(type_boxed) => { + let inner_column_type_representation = env.lookup_type_representation(&*type_boxed); + let (alias, expression) = sql::helpers::make_column( + current_table.reference.clone(), + column_info.name.clone(), + alias, + ); + Ok(( + alias, + wrap_array_in_type_representation(expression, inner_column_type_representation), + )) + } + } +} + +/// Certain type representations require that we provide a different json representation +/// than what postgres will return. +/// For array columns of those type representation, we wrap the result in a cast. +fn wrap_array_in_type_representation( + expression: sql::ast::Expression, + inner_column_type_representation: Option, +) -> sql::ast::Expression { + match inner_column_type_representation { + None => expression, + Some(type_rep) => match type_rep { + TypeRepresentation::Int64 => sql::ast::Expression::Cast { + expression: Box::new(expression), + r#type: sql::ast::ScalarType("text[]".to_string()), + }, + TypeRepresentation::BigDecimal => sql::ast::Expression::Cast { + expression: Box::new(expression), + r#type: sql::ast::ScalarType("text[]".to_string()), + }, + _ => expression, + }, + } +} + +/// Certain type representations require that we provide a different json representation +/// than what postgres will return. +/// For columns of those type representation, we wrap the result in a cast. +fn wrap_in_type_representation( + expression: sql::ast::Expression, + column_type_representation: Option, +) -> sql::ast::Expression { + match column_type_representation { + None => expression, + Some(type_rep) => match type_rep { + TypeRepresentation::Int64 => sql::ast::Expression::Cast { + expression: Box::new(expression), + r#type: sql::ast::ScalarType("text".to_string()), + }, + TypeRepresentation::BigDecimal => sql::ast::Expression::Cast { + expression: Box::new(expression), + r#type: sql::ast::ScalarType("text".to_string()), + }, + _ => expression, + }, + } +} diff --git a/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_complex.snap b/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_complex.snap index e7cb6f6d6..c8889476d 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_complex.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_complex.snap @@ -13,7 +13,7 @@ WITH "%1_NATIVE_QUERY_make_person" AS ( ) :: person as result ) SELECT - coalesce(json_agg(row_to_json("%2_universe")), '[]') AS "universe" + coalesce(json_agg(row_to_json("%11_universe")), '[]') AS "universe" FROM ( SELECT @@ -21,16 +21,61 @@ FROM FROM ( SELECT - coalesce(json_agg(row_to_json("%3_rows")), '[]') AS "rows" + coalesce(json_agg(row_to_json("%12_rows")), '[]') AS "rows" FROM ( SELECT - "%0_make_person"."result" AS "result" + "%10_nested_fields_collect"."collected" AS "result" FROM "%1_NATIVE_QUERY_make_person" AS "%0_make_person" - ) AS "%3_rows" - ) AS "%3_rows" - ) AS "%2_universe"; + LEFT OUTER JOIN LATERAL ( + SELECT + row_to_json("%2_nested_fields") AS "collected" + FROM + ( + SELECT + "%6_nested_fields_collect"."collected" AS "address", + "%9_nested_fields_collect"."collected" AS "name" + FROM + ( + SELECT + ("%0_make_person"."result").* + ) AS "%3_nested_field_binding" + LEFT OUTER JOIN LATERAL ( + SELECT + row_to_json("%4_nested_fields") AS "collected" + FROM + ( + SELECT + "%5_nested_field_binding"."address_line_1" AS "address_line_1", + "%5_nested_field_binding"."address_line_2" AS "address_line_2" + FROM + ( + SELECT + ("%3_nested_field_binding"."address").* + ) AS "%5_nested_field_binding" + ) AS "%4_nested_fields" + ) AS "%6_nested_fields_collect" ON ('true') + LEFT OUTER JOIN LATERAL ( + SELECT + row_to_json("%7_nested_fields") AS "collected" + FROM + ( + SELECT + "%8_nested_field_binding"."first_name" AS "first_name", + "%8_nested_field_binding"."last_name" AS "last_name" + FROM + ( + SELECT + ("%3_nested_field_binding"."name").* + ) AS "%8_nested_field_binding" + ) AS "%7_nested_fields" + ) AS "%9_nested_fields_collect" ON ('true') + ) AS "%2_nested_fields" + ) AS "%10_nested_fields_collect" ON ('true') + ) AS "%12_rows" + ) AS "%12_rows" + ) AS "%11_universe"; COMMIT; diff --git a/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_simple.snap b/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_simple.snap index d5d60fd28..50c54fa34 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_simple.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_simple.snap @@ -10,7 +10,7 @@ WITH "%1_NATIVE_QUERY_address_identity_function" AS ( jsonb_populate_record(cast(null as person_address), $1) as result ) SELECT - coalesce(json_agg(row_to_json("%2_universe")), '[]') AS "universe" + coalesce(json_agg(row_to_json("%5_universe")), '[]') AS "universe" FROM ( SELECT @@ -18,16 +18,31 @@ FROM FROM ( SELECT - coalesce(json_agg(row_to_json("%3_rows")), '[]') AS "rows" + coalesce(json_agg(row_to_json("%6_rows")), '[]') AS "rows" FROM ( SELECT - "%0_address_identity_function"."result" AS "result" + "%4_nested_fields_collect"."collected" AS "result" FROM "%1_NATIVE_QUERY_address_identity_function" AS "%0_address_identity_function" - ) AS "%3_rows" - ) AS "%3_rows" - ) AS "%2_universe"; + LEFT OUTER JOIN LATERAL ( + SELECT + row_to_json("%2_nested_fields") AS "collected" + FROM + ( + SELECT + "%3_nested_field_binding"."address_line_1" AS "address_line_1", + "%3_nested_field_binding"."address_line_2" AS "address_line_2" + FROM + ( + SELECT + ("%0_address_identity_function"."result").* + ) AS "%3_nested_field_binding" + ) AS "%2_nested_fields" + ) AS "%4_nested_fields_collect" ON ('true') + ) AS "%6_rows" + ) AS "%6_rows" + ) AS "%5_universe"; COMMIT; diff --git a/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_complex.snap b/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_complex.snap index 19f31c5cf..9c2de26dc 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_complex.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_complex.snap @@ -6,11 +6,11 @@ BEGIN ISOLATION LEVEL READ COMMITTED READ ONLY; SELECT - coalesce(json_agg("%6_universe_agg"."universe"), '[]') AS "universe" + coalesce(json_agg("%15_universe_agg"."universe"), '[]') AS "universe" FROM ( SELECT - row_to_json("%3_universe") AS "universe" + row_to_json("%12_universe") AS "universe" FROM jsonb_to_recordset($1) AS "%0_%variables_table"("%variable_order" int, "%variables" jsonb) CROSS JOIN LATERAL ( @@ -32,19 +32,64 @@ FROM FROM ( SELECT - coalesce(json_agg(row_to_json("%4_rows")), '[]') AS "rows" + coalesce(json_agg(row_to_json("%13_rows")), '[]') AS "rows" FROM ( SELECT - "%1_make_person"."result" AS "result" + "%11_nested_fields_collect"."collected" AS "result" FROM "%2_NATIVE_QUERY_make_person" AS "%1_make_person" - ) AS "%4_rows" - ) AS "%4_rows" - ) AS "%3_universe" + LEFT OUTER JOIN LATERAL ( + SELECT + row_to_json("%3_nested_fields") AS "collected" + FROM + ( + SELECT + "%7_nested_fields_collect"."collected" AS "address", + "%10_nested_fields_collect"."collected" AS "name" + FROM + ( + SELECT + ("%1_make_person"."result").* + ) AS "%4_nested_field_binding" + LEFT OUTER JOIN LATERAL ( + SELECT + row_to_json("%5_nested_fields") AS "collected" + FROM + ( + SELECT + "%6_nested_field_binding"."address_line_1" AS "address_line_1", + "%6_nested_field_binding"."address_line_2" AS "address_line_2" + FROM + ( + SELECT + ("%4_nested_field_binding"."address").* + ) AS "%6_nested_field_binding" + ) AS "%5_nested_fields" + ) AS "%7_nested_fields_collect" ON ('true') + LEFT OUTER JOIN LATERAL ( + SELECT + row_to_json("%8_nested_fields") AS "collected" + FROM + ( + SELECT + "%9_nested_field_binding"."first_name" AS "first_name", + "%9_nested_field_binding"."last_name" AS "last_name" + FROM + ( + SELECT + ("%4_nested_field_binding"."name").* + ) AS "%9_nested_field_binding" + ) AS "%8_nested_fields" + ) AS "%10_nested_fields_collect" ON ('true') + ) AS "%3_nested_fields" + ) AS "%11_nested_fields_collect" ON ('true') + ) AS "%13_rows" + ) AS "%13_rows" + ) AS "%12_universe" ORDER BY "%0_%variables_table"."%variable_order" ASC - ) AS "%6_universe_agg"; + ) AS "%15_universe_agg"; COMMIT; diff --git a/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_simple.snap b/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_simple.snap index dcbc7ced6..40e8ef1bd 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_simple.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_simple.snap @@ -6,11 +6,11 @@ BEGIN ISOLATION LEVEL READ COMMITTED READ ONLY; SELECT - coalesce(json_agg("%6_universe_agg"."universe"), '[]') AS "universe" + coalesce(json_agg("%9_universe_agg"."universe"), '[]') AS "universe" FROM ( SELECT - row_to_json("%3_universe") AS "universe" + row_to_json("%6_universe") AS "universe" FROM jsonb_to_recordset($1) AS "%0_%variables_table"("%variable_order" int, "%variables" jsonb) CROSS JOIN LATERAL ( @@ -26,19 +26,34 @@ FROM FROM ( SELECT - coalesce(json_agg(row_to_json("%4_rows")), '[]') AS "rows" + coalesce(json_agg(row_to_json("%7_rows")), '[]') AS "rows" FROM ( SELECT - "%1_address_identity_function"."result" AS "result" + "%5_nested_fields_collect"."collected" AS "result" FROM "%2_NATIVE_QUERY_address_identity_function" AS "%1_address_identity_function" - ) AS "%4_rows" - ) AS "%4_rows" - ) AS "%3_universe" + LEFT OUTER JOIN LATERAL ( + SELECT + row_to_json("%3_nested_fields") AS "collected" + FROM + ( + SELECT + "%4_nested_field_binding"."address_line_1" AS "address_line_1", + "%4_nested_field_binding"."address_line_2" AS "address_line_2" + FROM + ( + SELECT + ("%1_address_identity_function"."result").* + ) AS "%4_nested_field_binding" + ) AS "%3_nested_fields" + ) AS "%5_nested_fields_collect" ON ('true') + ) AS "%7_rows" + ) AS "%7_rows" + ) AS "%6_universe" ORDER BY "%0_%variables_table"."%variable_order" ASC - ) AS "%6_universe_agg"; + ) AS "%9_universe_agg"; COMMIT; diff --git a/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__basic__select_composite_column_complex.snap b/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__basic__select_composite_column_complex.snap index 432970ad3..de6e910cf 100644 --- a/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__basic__select_composite_column_complex.snap +++ b/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__basic__select_composite_column_complex.snap @@ -7,13 +7,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "John", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "John", + "last_name": "Doe" } } } diff --git a/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__basic__select_composite_variable_complex.snap b/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__basic__select_composite_variable_complex.snap index 970d79f81..7a3849631 100644 --- a/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__basic__select_composite_variable_complex.snap +++ b/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__basic__select_composite_variable_complex.snap @@ -7,13 +7,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "John", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "John", + "last_name": "Doe" } } } @@ -23,13 +23,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "Jane", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "Jane", + "last_name": "Doe" } } } diff --git a/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__types__select_value_types.snap b/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__types__select_value_types.snap index c6b6da209..2a77143f4 100644 --- a/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__types__select_value_types.snap +++ b/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__types__select_value_types.snap @@ -9,10 +9,10 @@ expression: result "bool": true, "int2": 245, "int4": 24555, - "int8": 245555555, + "int8": "245555555", "float4": 24.555, "float8": 2455.555, - "numeric": 24.555, + "numeric": "24.555", "char": "s", "varchar": "varchar string", "text": "textual text", diff --git a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__basic__select_composite_column_complex.snap b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__basic__select_composite_column_complex.snap index 1c20e6d0f..845e6e4b6 100644 --- a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__basic__select_composite_column_complex.snap +++ b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__basic__select_composite_column_complex.snap @@ -7,13 +7,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "John", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "John", + "last_name": "Doe" } } } diff --git a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__basic__select_composite_variable_complex.snap b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__basic__select_composite_variable_complex.snap index 97e9fd725..9ba142c8d 100644 --- a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__basic__select_composite_variable_complex.snap +++ b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__basic__select_composite_variable_complex.snap @@ -7,13 +7,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "John", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "John", + "last_name": "Doe" } } } @@ -23,13 +23,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "Jane", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "Jane", + "last_name": "Doe" } } } diff --git a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__types__select_value_types.snap b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__types__select_value_types.snap index afc32602a..b8ca8908c 100644 --- a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__types__select_value_types.snap +++ b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__types__select_value_types.snap @@ -9,10 +9,10 @@ expression: result "bool": true, "int2": 245, "int4": 24555, - "int8": 245555555, + "int8": "245555555", "float4": 24.555, "float8": 2455.555, - "numeric": 24.555, + "numeric": "24.555", "char": "s", "varchar": "varchar string", "text": "textual text", diff --git a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap index c38b79944..e6b2115ed 100644 --- a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap +++ b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap @@ -1272,7 +1272,7 @@ expression: result }, "int8": { "representation": { - "type": "json" + "type": "int64" }, "aggregate_functions": { "avg": { @@ -2926,7 +2926,7 @@ expression: result "only_occurring_here1": { "type": { "type": "named", - "name": "bit" + "name": "int8" } } } diff --git a/crates/tests/databases-tests/src/cockroach/query_tests.rs b/crates/tests/databases-tests/src/cockroach/query_tests.rs index da0f504e7..da9fbb8cb 100644 --- a/crates/tests/databases-tests/src/cockroach/query_tests.rs +++ b/crates/tests/databases-tests/src/cockroach/query_tests.rs @@ -59,26 +59,28 @@ mod basic { insta::assert_json_snapshot!(result); } + #[ignore = "Cockroach v23.2 does not introspect composite types."] #[tokio::test] async fn select_composite_column_simple() { let result = run_query(create_router().await, "select_composite_column_simple").await; insta::assert_json_snapshot!(result); } - #[ignore = "Cockroach v23.1.10 does not support nested user defined types which this test uses."] + #[ignore = "Cockroach v23.2 does not support nested user defined types which this test uses."] #[tokio::test] async fn select_composite_column_complex() { let result = run_query(create_router().await, "select_composite_column_complex").await; insta::assert_json_snapshot!(result); } + #[ignore = "Cockroach v23.2 does not introspect composite types."] #[tokio::test] async fn select_composite_variable_simple() { let result = run_query(create_router().await, "select_composite_variable_simple").await; insta::assert_json_snapshot!(result); } - #[ignore = "Cockroach v23.1.10 does not support nested user defined types which this test uses."] + #[ignore = "Cockroach v23.2 does not support nested user defined types which this test uses."] #[tokio::test] async fn select_composite_variable_complex() { let result = run_query(create_router().await, "select_composite_variable_complex").await; diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_int_and_string.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_int_and_string.snap index eaf1c5274..57096385e 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_int_and_string.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_int_and_string.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": 35, + "AlbumId": "35", "title": "Garage Inc. (Disc 1)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_equals_self.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_equals_self.snap index e55338e53..0f244fd3b 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_equals_self.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_equals_self.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": 340, + "AlbumId": "340", "Title": "Liszt - 12 Études D'Execution Transcendante" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than.snap index d4d44ea02..ffe0186f7 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than.snap @@ -6,31 +6,31 @@ expression: result { "rows": [ { - "AlbumId": 341, + "AlbumId": "341", "Title": "Great Recordings of the Century - Shubert: Schwanengesang, 4 Lieder" }, { - "AlbumId": 342, + "AlbumId": "342", "Title": "Locatelli: Concertos for Violin, Strings and Continuo, Vol. 3" }, { - "AlbumId": 343, + "AlbumId": "343", "Title": "Respighi:Pines of Rome" }, { - "AlbumId": 344, + "AlbumId": "344", "Title": "Schubert: The Late String Quartets & String Quintet (3 CD's)" }, { - "AlbumId": 345, + "AlbumId": "345", "Title": "Monteverdi: L'Orfeo" }, { - "AlbumId": 346, + "AlbumId": "346", "Title": "Mozart: Chamber Music" }, { - "AlbumId": 347, + "AlbumId": "347", "Title": "Koyaanisqatsi (Soundtrack from the Motion Picture)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than_or_equal_to.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than_or_equal_to.snap index 4be116577..b6d2bbca8 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than_or_equal_to.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than_or_equal_to.snap @@ -6,35 +6,35 @@ expression: result { "rows": [ { - "AlbumId": 340, + "AlbumId": "340", "Title": "Liszt - 12 Études D'Execution Transcendante" }, { - "AlbumId": 341, + "AlbumId": "341", "Title": "Great Recordings of the Century - Shubert: Schwanengesang, 4 Lieder" }, { - "AlbumId": 342, + "AlbumId": "342", "Title": "Locatelli: Concertos for Violin, Strings and Continuo, Vol. 3" }, { - "AlbumId": 343, + "AlbumId": "343", "Title": "Respighi:Pines of Rome" }, { - "AlbumId": 344, + "AlbumId": "344", "Title": "Schubert: The Late String Quartets & String Quintet (3 CD's)" }, { - "AlbumId": 345, + "AlbumId": "345", "Title": "Monteverdi: L'Orfeo" }, { - "AlbumId": 346, + "AlbumId": "346", "Title": "Mozart: Chamber Music" }, { - "AlbumId": 347, + "AlbumId": "347", "Title": "Koyaanisqatsi (Soundtrack from the Motion Picture)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_less_than_or_equal_to.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_less_than_or_equal_to.snap index 083048e33..5b8973cbf 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_less_than_or_equal_to.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_less_than_or_equal_to.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": 1, + "AlbumId": "1", "Title": "For Those About To Rock We Salute You" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_ilike.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_ilike.snap index 44d49e59c..5b8eb5040 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_ilike.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_ilike.snap @@ -6,31 +6,31 @@ expression: result { "rows": [ { - "AlbumId": 1, + "AlbumId": "1", "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": 4, + "AlbumId": "4", "Title": "Let There Be Rock" }, { - "AlbumId": 59, + "AlbumId": "59", "Title": "Deep Purple In Rock" }, { - "AlbumId": 108, + "AlbumId": "108", "Title": "Rock In Rio [CD1]" }, { - "AlbumId": 109, + "AlbumId": "109", "Title": "Rock In Rio [CD2]" }, { - "AlbumId": 213, + "AlbumId": "213", "Title": "Pure Cult: The Best Of The Cult (For Rockers, Ravers, Lovers & Sinners) [UK]" }, { - "AlbumId": 216, + "AlbumId": "216", "Title": "Hot Rocks, 1964-1971 (Disc 1)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_in.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_in.snap index 99d7e07de..6681842c8 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_in.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_in.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": 346, + "AlbumId": "346", "Title": "Mozart: Chamber Music" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_iregex.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_iregex.snap index 89f65b410..c5a300059 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_iregex.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_iregex.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": 6, + "AlbumId": "6", "Title": "Jagged Little Pill" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_like.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_like.snap index 44d49e59c..5b8eb5040 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_like.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_like.snap @@ -6,31 +6,31 @@ expression: result { "rows": [ { - "AlbumId": 1, + "AlbumId": "1", "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": 4, + "AlbumId": "4", "Title": "Let There Be Rock" }, { - "AlbumId": 59, + "AlbumId": "59", "Title": "Deep Purple In Rock" }, { - "AlbumId": 108, + "AlbumId": "108", "Title": "Rock In Rio [CD1]" }, { - "AlbumId": 109, + "AlbumId": "109", "Title": "Rock In Rio [CD2]" }, { - "AlbumId": 213, + "AlbumId": "213", "Title": "Pure Cult: The Best Of The Cult (For Rockers, Ravers, Lovers & Sinners) [UK]" }, { - "AlbumId": 216, + "AlbumId": "216", "Title": "Hot Rocks, 1964-1971 (Disc 1)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_niregex.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_niregex.snap index f6b90784a..626817df1 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_niregex.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_niregex.snap @@ -6,23 +6,23 @@ expression: result { "rows": [ { - "AlbumId": 1, + "AlbumId": "1", "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": 2, + "AlbumId": "2", "Title": "Balls to the Wall" }, { - "AlbumId": 3, + "AlbumId": "3", "Title": "Restless and Wild" }, { - "AlbumId": 4, + "AlbumId": "4", "Title": "Let There Be Rock" }, { - "AlbumId": 5, + "AlbumId": "5", "Title": "Big Ones" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_in.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_in.snap index f6b90784a..626817df1 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_in.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_in.snap @@ -6,23 +6,23 @@ expression: result { "rows": [ { - "AlbumId": 1, + "AlbumId": "1", "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": 2, + "AlbumId": "2", "Title": "Balls to the Wall" }, { - "AlbumId": 3, + "AlbumId": "3", "Title": "Restless and Wild" }, { - "AlbumId": 4, + "AlbumId": "4", "Title": "Let There Be Rock" }, { - "AlbumId": 5, + "AlbumId": "5", "Title": "Big Ones" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_like.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_like.snap index a941af127..307def278 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_like.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_like.snap @@ -6,23 +6,23 @@ expression: result { "rows": [ { - "AlbumId": 2, + "AlbumId": "2", "Title": "Balls to the Wall" }, { - "AlbumId": 3, + "AlbumId": "3", "Title": "Restless and Wild" }, { - "AlbumId": 5, + "AlbumId": "5", "Title": "Big Ones" }, { - "AlbumId": 6, + "AlbumId": "6", "Title": "Jagged Little Pill" }, { - "AlbumId": 7, + "AlbumId": "7", "Title": "Facelift" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nregex.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nregex.snap index a73632c50..9cf950ba6 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nregex.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nregex.snap @@ -6,43 +6,43 @@ expression: result { "rows": [ { - "AlbumId": 1, + "AlbumId": "1", "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": 2, + "AlbumId": "2", "Title": "Balls to the Wall" }, { - "AlbumId": 3, + "AlbumId": "3", "Title": "Restless and Wild" }, { - "AlbumId": 4, + "AlbumId": "4", "Title": "Let There Be Rock" }, { - "AlbumId": 5, + "AlbumId": "5", "Title": "Big Ones" }, { - "AlbumId": 7, + "AlbumId": "7", "Title": "Facelift" }, { - "AlbumId": 8, + "AlbumId": "8", "Title": "Warner 25 Anos" }, { - "AlbumId": 9, + "AlbumId": "9", "Title": "Plays Metallica By Four Cellos" }, { - "AlbumId": 10, + "AlbumId": "10", "Title": "Audioslave" }, { - "AlbumId": 11, + "AlbumId": "11", "Title": "Out Of Exile" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nsimilar.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nsimilar.snap index 882d56f64..de5baa93b 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nsimilar.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nsimilar.snap @@ -6,23 +6,23 @@ expression: result { "rows": [ { - "AlbumId": 1, + "AlbumId": "1", "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": 4, + "AlbumId": "4", "Title": "Let There Be Rock" }, { - "AlbumId": 6, + "AlbumId": "6", "Title": "Jagged Little Pill" }, { - "AlbumId": 7, + "AlbumId": "7", "Title": "Facelift" }, { - "AlbumId": 8, + "AlbumId": "8", "Title": "Warner 25 Anos" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_regex.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_regex.snap index 89f65b410..c5a300059 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_regex.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_regex.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": 6, + "AlbumId": "6", "Title": "Jagged Little Pill" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_similar.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_similar.snap index ff1f1e282..b5a2862d9 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_similar.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_similar.snap @@ -6,23 +6,23 @@ expression: result { "rows": [ { - "AlbumId": 2, + "AlbumId": "2", "Title": "Balls to the Wall" }, { - "AlbumId": 3, + "AlbumId": "3", "Title": "Restless and Wild" }, { - "AlbumId": 5, + "AlbumId": "5", "Title": "Big Ones" }, { - "AlbumId": 12, + "AlbumId": "12", "Title": "BackBeat Soundtrack" }, { - "AlbumId": 16, + "AlbumId": "16", "Title": "Black Sabbath" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_variable_int.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_variable_int.snap index 25f2ec11c..800606bec 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_variable_int.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_variable_int.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": 35, + "AlbumId": "35", "Title": "Garage Inc. (Disc 1)" } ] @@ -14,7 +14,7 @@ expression: result { "rows": [ { - "AlbumId": 222, + "AlbumId": "222", "Title": "Serie Sem Limite (Disc 1)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__relationships__very_nested_recursive_relationship.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__relationships__very_nested_recursive_relationship.snap index e62f02314..2dddf0f12 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__relationships__very_nested_recursive_relationship.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__relationships__very_nested_recursive_relationship.snap @@ -14,7 +14,7 @@ expression: result "Artist": { "rows": [ { - "0ArtistId": 1, + "0ArtistId": "1", "Albums": { "rows": [ { @@ -48,7 +48,7 @@ expression: result "Artist": { "rows": [ { - "0ArtistId": 1, + "0ArtistId": "1", "Albums": { "rows": [ { @@ -89,7 +89,7 @@ expression: result "Artist": { "rows": [ { - "0ArtistId": 2, + "0ArtistId": "2", "Albums": { "rows": [ { @@ -123,7 +123,7 @@ expression: result "Artist": { "rows": [ { - "0ArtistId": 2, + "0ArtistId": "2", "Albums": { "rows": [ { @@ -164,7 +164,7 @@ expression: result "Artist": { "rows": [ { - "0ArtistId": 3, + "0ArtistId": "3", "Albums": { "rows": [ { diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__types__select_value_types.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__types__select_value_types.snap index 6122d10bf..d447d9ce8 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__types__select_value_types.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__types__select_value_types.snap @@ -13,8 +13,8 @@ expression: result "float8": 2455.555, "int2": 245, "int4": 24555, - "int8": 245555555, - "numeric": 24.555, + "int8": "245555555", + "numeric": "24.555", "text": "textual text", "time": "02:35:59", "timestamp": "2013-11-03T02:35:59", diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__schema_tests__schema_test__get_schema.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__schema_tests__schema_test__get_schema.snap index 29a676d95..62ff50e29 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__schema_tests__schema_test__get_schema.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__schema_tests__schema_test__get_schema.snap @@ -809,7 +809,7 @@ expression: result }, "int8": { "representation": { - "type": "json" + "type": "int64" }, "aggregate_functions": { "avg": { diff --git a/crates/tests/databases-tests/src/postgres/query_tests.rs b/crates/tests/databases-tests/src/postgres/query_tests.rs index 3dbf97396..2b558c553 100644 --- a/crates/tests/databases-tests/src/postgres/query_tests.rs +++ b/crates/tests/databases-tests/src/postgres/query_tests.rs @@ -69,6 +69,16 @@ mod basic { insta::assert_json_snapshot!(result); } + #[tokio::test] + async fn select_discoverable_composite_column() { + let result = run_query( + create_router().await, + "select_discoverable_composite_column", + ) + .await; + insta::assert_json_snapshot!(result); + } + #[tokio::test] async fn select_composite_column_complex() { let result = run_query(create_router().await, "select_composite_column_complex").await; diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap index dbf464daf..99d071d70 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap @@ -1110,7 +1110,7 @@ expression: default_configuration "only_occurring_here1": { "name": "only_occurring_here1", "type": { - "scalarType": "bit" + "scalarType": "int8" }, "description": null } @@ -1128,17 +1128,6 @@ expression: default_configuration "returnType": "text" } }, - "bit": { - "bit_and": { - "returnType": "bit" - }, - "bit_or": { - "returnType": "bit" - }, - "bit_xor": { - "returnType": "bit" - } - }, "bool": { "bool_and": { "returnType": "bool" @@ -1548,50 +1537,6 @@ expression: default_configuration "isInfix": false } }, - "bit": { - "_eq": { - "operatorName": "=", - "operatorKind": "equal", - "argumentType": "bit", - "isInfix": true - }, - "_gt": { - "operatorName": ">", - "operatorKind": "custom", - "argumentType": "bit", - "isInfix": true - }, - "_gte": { - "operatorName": ">=", - "operatorKind": "custom", - "argumentType": "bit", - "isInfix": true - }, - "_in": { - "operatorName": "IN", - "operatorKind": "in", - "argumentType": "bit", - "isInfix": true - }, - "_lt": { - "operatorName": "<", - "operatorKind": "custom", - "argumentType": "bit", - "isInfix": true - }, - "_lte": { - "operatorName": "<=", - "operatorKind": "custom", - "argumentType": "bit", - "isInfix": true - }, - "_neq": { - "operatorName": "<>", - "operatorKind": "custom", - "argumentType": "bit", - "isInfix": true - } - }, "bool": { "_eq": { "operatorName": "=", @@ -2291,7 +2236,6 @@ expression: default_configuration }, "typeRepresentations": { "Phone": "string", - "bit": "string", "bool": "boolean", "card_suit": { "enum": [ @@ -2306,7 +2250,7 @@ expression: default_configuration "float8": "float64", "int2": "int16", "int4": "int32", - "int8": "json", + "int8": "int64", "numeric": "bigDecimal", "text": "string", "timestamp": "timestamp", diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__mutation_tests__basic__v1_insert_custom_dog.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__mutation_tests__basic__v1_insert_custom_dog.snap index b4debd693..26c3e6c9e 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__mutation_tests__basic__v1_insert_custom_dog.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__mutation_tests__basic__v1_insert_custom_dog.snap @@ -9,11 +9,11 @@ expression: result "result": { "returning": [ { - "id": 1, + "id": "1", "name": "Cremebo", "birthday": "2024-01-17", - "height_cm": 160, - "height_inch": 62.99212598425197, + "height_cm": "160", + "height_inch": "62.9921259842519685", "adopter_name": null } ], @@ -27,7 +27,7 @@ expression: result { "name": "Manbo", "birthday": "2024-01-01", - "height_inch": 135.8267716535433, + "height_inch": "135.8267716535433071", "adopter_name": "Joseph" } ] diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_composite_column_complex.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_composite_column_complex.snap index ea12dc8ef..d1efcbd0f 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_composite_column_complex.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_composite_column_complex.snap @@ -7,13 +7,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "John", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "John", + "last_name": "Doe" } } } diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_composite_variable_complex.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_composite_variable_complex.snap index 2e6441618..53ffe787b 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_composite_variable_complex.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_composite_variable_complex.snap @@ -7,13 +7,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "John", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "John", + "last_name": "Doe" } } } @@ -23,13 +23,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "Jane", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "Jane", + "last_name": "Doe" } } } diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_discoverable_composite_column.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_discoverable_composite_column.snap new file mode 100644 index 000000000..ddbd0d34c --- /dev/null +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_discoverable_composite_column.snap @@ -0,0 +1,15 @@ +--- +source: crates/tests/databases-tests/src/postgres/query_tests.rs +expression: result +--- +[ + { + "rows": [ + { + "result": { + "only_occurring_here1": "1152921504606846976" + } + } + ] + } +] diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__types__select_value_types.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__types__select_value_types.snap index 1190a6bb1..a63f50501 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__types__select_value_types.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__types__select_value_types.snap @@ -9,10 +9,10 @@ expression: result "bool": true, "int2": 245, "int4": 24555, - "int8": 245555555, + "int8": "245555555", "float4": 24.555, "float8": 2455.555, - "numeric": 24.555, + "numeric": "24.555", "char": "s", "varchar": "varchar string", "text": "textual text", diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__schema_tests__schema_test__get_schema.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__schema_tests__schema_test__get_schema.snap index ec172c8ec..1a677cf96 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__schema_tests__schema_test__get_schema.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__schema_tests__schema_test__get_schema.snap @@ -1356,7 +1356,7 @@ expression: result }, "int8": { "representation": { - "type": "json" + "type": "int64" }, "aggregate_functions": { "avg": { @@ -3112,7 +3112,7 @@ expression: result "only_occurring_here1": { "type": { "type": "named", - "name": "bit" + "name": "int8" } } } diff --git a/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__basic__select_composite_column_complex.snap b/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__basic__select_composite_column_complex.snap index 006a32f26..4cf6dc00e 100644 --- a/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__basic__select_composite_column_complex.snap +++ b/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__basic__select_composite_column_complex.snap @@ -7,13 +7,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "John", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "John", + "last_name": "Doe" } } } diff --git a/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__basic__select_composite_variable_complex.snap b/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__basic__select_composite_variable_complex.snap index 27f3c0e3f..a0e3fcc8f 100644 --- a/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__basic__select_composite_variable_complex.snap +++ b/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__basic__select_composite_variable_complex.snap @@ -7,13 +7,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "John", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "John", + "last_name": "Doe" } } } @@ -23,13 +23,13 @@ expression: result "rows": [ { "result": { - "name": { - "first_name": "Jane", - "last_name": "Doe" - }, "address": { "address_line_1": "Somstreet 159", "address_line_2": "Second door to the right" + }, + "name": { + "first_name": "Jane", + "last_name": "Doe" } } } diff --git a/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__types__select_value_types.snap b/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__types__select_value_types.snap index 57dea2d80..7bf7b3c7d 100644 --- a/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__types__select_value_types.snap +++ b/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__types__select_value_types.snap @@ -9,10 +9,10 @@ expression: result "bool": true, "int2": 245, "int4": 24555, - "int8": 245555555, + "int8": "245555555", "float4": 24.555, "float8": 2455.555, - "numeric": 24.555, + "numeric": "24.555", "char": "s", "varchar": "varchar string", "text": "textual text", diff --git a/crates/tests/tests-common/goldenfiles/select_discoverable_composite_column.json b/crates/tests/tests-common/goldenfiles/select_discoverable_composite_column.json new file mode 100644 index 000000000..9716bdeda --- /dev/null +++ b/crates/tests/tests-common/goldenfiles/select_discoverable_composite_column.json @@ -0,0 +1,14 @@ +{ + "collection": "discoverable_types_root_occurrence", + "query": { + "fields": { + "result": { + "type": "column", + "column": "col", + "arguments": {} + } + } + }, + "arguments": {}, + "collection_relationships": {} +} diff --git a/static/aurora/v3-chinook-ndc-metadata/configuration.json b/static/aurora/v3-chinook-ndc-metadata/configuration.json index 8ffebddd4..99f2c35a3 100644 --- a/static/aurora/v3-chinook-ndc-metadata/configuration.json +++ b/static/aurora/v3-chinook-ndc-metadata/configuration.json @@ -2781,7 +2781,7 @@ "float8": "float64", "int2": "int16", "int4": "int32", - "int8": "json", + "int8": "int64", "numeric": "bigDecimal", "text": "string", "time": "time", diff --git a/static/citus/v3-chinook-ndc-metadata/configuration.json b/static/citus/v3-chinook-ndc-metadata/configuration.json index f59d312bc..f78453929 100644 --- a/static/citus/v3-chinook-ndc-metadata/configuration.json +++ b/static/citus/v3-chinook-ndc-metadata/configuration.json @@ -838,7 +838,7 @@ "only_occurring_here1": { "name": "only_occurring_here1", "type": { - "scalarType": "bit" + "scalarType": "int8" }, "description": null } @@ -929,32 +929,6 @@ } }, "nativeQueries": { - "organization_identity_function": { - "sql": { - "inline": "SELECT {{organization}} as result_the_column" - }, - "columns": { - "result_the_field": { - "name": "result_the_column", - "type": { - "compositeType": "organization" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "organization": { - "name": "organization", - "type": { - "compositeType": "organization" - }, - "nullable": "nullable", - "description": null - } - }, - "description": "A native query used to test support for composite types" - }, "address_identity_function": { "sql": { "inline": "SELECT {{address}} as result" @@ -1363,6 +1337,32 @@ }, "description": "A native query used to test support for composite types" }, + "organization_identity_function": { + "sql": { + "inline": "SELECT {{organization}} as result_the_column" + }, + "columns": { + "result_the_field": { + "name": "result_the_column", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "organization": { + "name": "organization", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + }, "summarize_organizations": { "sql": { "inline": "SELECT 'The organization ' || org.name || ' has ' || no_committees::text || ' committees, ' || 'the largest of which has ' || max_members || ' members.' AS result FROM (SELECT orgs.* FROM unnest({{organizations}}) as orgs) AS org JOIN LATERAL ( SELECT count(committee.*) AS no_committees, max(members_agg.no_members) AS max_members FROM unnest(org.committees) AS committee JOIN LATERAL ( SELECT count(*) as no_members FROM unnest(committee.members) AS members) AS members_agg ON true) AS coms ON true" @@ -3335,7 +3335,7 @@ "float8": "float64", "int2": "int16", "int4": "int32", - "int8": "json", + "int8": "int64", "numeric": "bigDecimal", "text": "string", "time": "time", diff --git a/static/cockroach/v3-chinook-ndc-metadata/configuration.json b/static/cockroach/v3-chinook-ndc-metadata/configuration.json index 1d5ada77e..1a7c9807e 100644 --- a/static/cockroach/v3-chinook-ndc-metadata/configuration.json +++ b/static/cockroach/v3-chinook-ndc-metadata/configuration.json @@ -2808,7 +2808,7 @@ "float8": "float64", "int2": "int16", "int4": "int32", - "int8": "json", + "int8": "int64", "numeric": "bigDecimal", "text": "string", "time": "time", diff --git a/static/composite-types-simple.sql b/static/composite-types-simple.sql index 0343e8d16..8b8ff421c 100644 --- a/static/composite-types-simple.sql +++ b/static/composite-types-simple.sql @@ -18,7 +18,7 @@ CREATE TYPE person_address AS CREATE TYPE discoverable_types AS ( - only_occurring_here1 bit + only_occurring_here1 int8 ); CREATE TABLE discoverable_types_root_occurrence @@ -27,4 +27,4 @@ CREATE TABLE discoverable_types_root_occurrence ); -- We add this because ndc-test is going to check that this table it not empty. -INSERT INTO discoverable_types_root_occurrence(col) VALUES (ROW(1)::discoverable_types); +INSERT INTO discoverable_types_root_occurrence(col) VALUES (ROW(1152921504606846976)::discoverable_types); diff --git a/static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/configuration.json b/static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/configuration.json new file mode 100644 index 000000000..6d7a19493 --- /dev/null +++ b/static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/configuration.json @@ -0,0 +1,3978 @@ +{ + "version": "3", + "$schema": "../../schema.json", + "connectionSettings": { + "connectionUri": { + "variable": "CONNECTION_URI" + }, + "poolSettings": { + "maxConnections": 50, + "poolTimeout": 30, + "idleTimeout": 180, + "connectionLifetime": 600 + }, + "isolationLevel": "ReadCommitted" + }, + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": "The identifier of an album" + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": "The id of the artist that authored the album" + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": "The title of an album" + } + }, + "uniquenessConstraints": { + "PK_Album": ["AlbumId"] + }, + "foreignRelations": { + "FK_AlbumArtistId": { + "foreignSchema": "public", + "foreignTable": "Artist", + "columnMapping": { + "ArtistId": "ArtistId" + } + } + }, + "description": "The record of all albums" + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": "The identifier of an artist" + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": "The name of an artist" + } + }, + "uniquenessConstraints": { + "PK_Artist": ["ArtistId"] + }, + "foreignRelations": {}, + "description": "The record of all artists" + }, + "Customer": { + "schemaName": "public", + "tableName": "Customer", + "columns": { + "Address": { + "name": "Address", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "City": { + "name": "City", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "Company": { + "name": "Company", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "Country": { + "name": "Country", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "CustomerId": { + "name": "CustomerId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": "The identifier of customer" + }, + "Email": { + "name": "Email", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": null + }, + "Fax": { + "name": "Fax", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "FirstName": { + "name": "FirstName", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": "The first name of a customer" + }, + "LastName": { + "name": "LastName", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": "The last name of a customer" + }, + "Phone": { + "name": "Phone", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "PostalCode": { + "name": "PostalCode", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "State": { + "name": "State", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "SupportRepId": { + "name": "SupportRepId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": { + "PK_Customer": ["CustomerId"] + }, + "foreignRelations": { + "FK_CustomerSupportRepId": { + "foreignSchema": "public", + "foreignTable": "Employee", + "columnMapping": { + "SupportRepId": "EmployeeId" + } + } + }, + "description": "The record of all customers" + }, + "Employee": { + "schemaName": "public", + "tableName": "Employee", + "columns": { + "Address": { + "name": "Address", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "BirthDate": { + "name": "BirthDate", + "type": { + "scalarType": "timestamp" + }, + "nullable": "nullable", + "description": null + }, + "City": { + "name": "City", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "Country": { + "name": "Country", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "Email": { + "name": "Email", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "EmployeeId": { + "name": "EmployeeId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "Fax": { + "name": "Fax", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "FirstName": { + "name": "FirstName", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": null + }, + "HireDate": { + "name": "HireDate", + "type": { + "scalarType": "timestamp" + }, + "nullable": "nullable", + "description": null + }, + "LastName": { + "name": "LastName", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": null + }, + "Phone": { + "name": "Phone", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "PostalCode": { + "name": "PostalCode", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "ReportsTo": { + "name": "ReportsTo", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "State": { + "name": "State", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": { + "PK_Employee": ["EmployeeId"] + }, + "foreignRelations": { + "FK_EmployeeReportsTo": { + "foreignSchema": "public", + "foreignTable": "Employee", + "columnMapping": { + "ReportsTo": "EmployeeId" + } + } + }, + "description": null + }, + "Genre": { + "schemaName": "public", + "tableName": "Genre", + "columns": { + "GenreId": { + "name": "GenreId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": { + "PK_Genre": ["GenreId"] + }, + "foreignRelations": {}, + "description": null + }, + "Invoice": { + "schemaName": "public", + "tableName": "Invoice", + "columns": { + "BillingAddress": { + "name": "BillingAddress", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "BillingCity": { + "name": "BillingCity", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "BillingCountry": { + "name": "BillingCountry", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "BillingPostalCode": { + "name": "BillingPostalCode", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "BillingState": { + "name": "BillingState", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "CustomerId": { + "name": "CustomerId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "InvoiceDate": { + "name": "InvoiceDate", + "type": { + "scalarType": "timestamp" + }, + "nullable": "nonNullable", + "description": null + }, + "InvoiceId": { + "name": "InvoiceId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "Total": { + "name": "Total", + "type": { + "scalarType": "numeric" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": { + "PK_Invoice": ["InvoiceId"] + }, + "foreignRelations": { + "FK_InvoiceCustomerId": { + "foreignSchema": "public", + "foreignTable": "Customer", + "columnMapping": { + "CustomerId": "CustomerId" + } + } + }, + "description": null + }, + "InvoiceLine": { + "schemaName": "public", + "tableName": "InvoiceLine", + "columns": { + "InvoiceId": { + "name": "InvoiceId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "InvoiceLineId": { + "name": "InvoiceLineId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "Quantity": { + "name": "Quantity", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "TrackId": { + "name": "TrackId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "UnitPrice": { + "name": "UnitPrice", + "type": { + "scalarType": "numeric" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": { + "PK_InvoiceLine": ["InvoiceLineId"] + }, + "foreignRelations": { + "FK_InvoiceLineInvoiceId": { + "foreignSchema": "public", + "foreignTable": "Invoice", + "columnMapping": { + "InvoiceId": "InvoiceId" + } + }, + "FK_InvoiceLineTrackId": { + "foreignSchema": "public", + "foreignTable": "Track", + "columnMapping": { + "TrackId": "TrackId" + } + } + }, + "description": null + }, + "MediaType": { + "schemaName": "public", + "tableName": "MediaType", + "columns": { + "MediaTypeId": { + "name": "MediaTypeId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": { + "PK_MediaType": ["MediaTypeId"] + }, + "foreignRelations": {}, + "description": null + }, + "Playlist": { + "schemaName": "public", + "tableName": "Playlist", + "columns": { + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "PlaylistId": { + "name": "PlaylistId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": { + "PK_Playlist": ["PlaylistId"] + }, + "foreignRelations": {}, + "description": null + }, + "PlaylistTrack": { + "schemaName": "public", + "tableName": "PlaylistTrack", + "columns": { + "PlaylistId": { + "name": "PlaylistId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "TrackId": { + "name": "TrackId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": { + "PK_PlaylistTrack": ["PlaylistId", "TrackId"] + }, + "foreignRelations": { + "FK_PlaylistTrackPlaylistId": { + "foreignSchema": "public", + "foreignTable": "Playlist", + "columnMapping": { + "PlaylistId": "PlaylistId" + } + }, + "FK_PlaylistTrackTrackId": { + "foreignSchema": "public", + "foreignTable": "Track", + "columnMapping": { + "TrackId": "TrackId" + } + } + }, + "description": null + }, + "Track": { + "schemaName": "public", + "tableName": "Track", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "Bytes": { + "name": "Bytes", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "Composer": { + "name": "Composer", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "GenreId": { + "name": "GenreId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "MediaTypeId": { + "name": "MediaTypeId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "Milliseconds": { + "name": "Milliseconds", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": null + }, + "TrackId": { + "name": "TrackId", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "UnitPrice": { + "name": "UnitPrice", + "type": { + "scalarType": "numeric" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": { + "PK_Track": ["TrackId"] + }, + "foreignRelations": { + "FK_TrackAlbumId": { + "foreignSchema": "public", + "foreignTable": "Album", + "columnMapping": { + "AlbumId": "AlbumId" + } + }, + "FK_TrackGenreId": { + "foreignSchema": "public", + "foreignTable": "Genre", + "columnMapping": { + "GenreId": "GenreId" + } + }, + "FK_TrackMediaTypeId": { + "foreignSchema": "public", + "foreignTable": "MediaType", + "columnMapping": { + "MediaTypeId": "MediaTypeId" + } + } + }, + "description": null + }, + "custom_dog": { + "schemaName": "custom", + "tableName": "dog", + "columns": { + "adopter_name": { + "name": "adopter_name", + "type": { + "scalarType": "text" + }, + "nullable": "nullable", + "description": null + }, + "birthday": { + "name": "birthday", + "type": { + "scalarType": "date" + }, + "nullable": "nonNullable", + "hasDefault": "hasDefault", + "description": null + }, + "height_cm": { + "name": "height_cm", + "type": { + "scalarType": "numeric" + }, + "nullable": "nonNullable", + "description": null + }, + "height_in": { + "name": "height_in", + "type": { + "scalarType": "numeric" + }, + "nullable": "nullable", + "hasDefault": "hasDefault", + "isGenerated": "stored", + "description": null + }, + "id": { + "name": "id", + "type": { + "scalarType": "int8" + }, + "nullable": "nonNullable", + "isIdentity": "identityAlways", + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": { + "dog_pkey": ["id"] + }, + "foreignRelations": {}, + "description": null + }, + "deck_of_cards": { + "schemaName": "public", + "tableName": "deck_of_cards", + "columns": { + "pips": { + "name": "pips", + "type": { + "scalarType": "int2" + }, + "nullable": "nonNullable", + "description": null + }, + "suit": { + "name": "suit", + "type": { + "scalarType": "card_suit" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "discoverable_types_root_occurrence": { + "schemaName": "public", + "tableName": "discoverable_types_root_occurrence", + "columns": { + "col": { + "name": "col", + "type": { + "compositeType": "discoverable_types" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "even_numbers": { + "schemaName": "public", + "tableName": "even_numbers", + "columns": { + "the_number": { + "name": "the_number", + "type": { + "scalarType": "even_number" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "phone_numbers": { + "schemaName": "public", + "tableName": "phone_numbers", + "columns": { + "the_number": { + "name": "the_number", + "type": { + "scalarType": "Phone" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, + "spatial_ref_sys": { + "schemaName": "public", + "tableName": "spatial_ref_sys", + "columns": { + "auth_name": { + "name": "auth_name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "auth_srid": { + "name": "auth_srid", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "proj4text": { + "name": "proj4text", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + }, + "srid": { + "name": "srid", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "srtext": { + "name": "srtext", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": { + "spatial_ref_sys_pkey": ["srid"] + }, + "foreignRelations": {}, + "description": null + }, + "topology_layer": { + "schemaName": "topology", + "tableName": "layer", + "columns": { + "child_id": { + "name": "child_id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "feature_column": { + "name": "feature_column", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": null + }, + "feature_type": { + "name": "feature_type", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "layer_id": { + "name": "layer_id", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + }, + "level": { + "name": "level", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "hasDefault": "hasDefault", + "description": null + }, + "schema_name": { + "name": "schema_name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": null + }, + "table_name": { + "name": "table_name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": null + }, + "topology_id": { + "name": "topology_id", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": { + "layer_pkey": ["layer_id", "topology_id"], + "layer_schema_name_table_name_feature_column_key": [ + "feature_column", + "schema_name", + "table_name" + ] + }, + "foreignRelations": { + "layer_topology_id_fkey": { + "foreignSchema": "topology", + "foreignTable": "topology", + "columnMapping": { + "topology_id": "id" + } + } + }, + "description": null + }, + "topology_topology": { + "schemaName": "topology", + "tableName": "topology", + "columns": { + "hasz": { + "name": "hasz", + "type": { + "scalarType": "bool" + }, + "nullable": "nonNullable", + "hasDefault": "hasDefault", + "description": null + }, + "id": { + "name": "id", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "hasDefault": "hasDefault", + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nonNullable", + "description": null + }, + "precision": { + "name": "precision", + "type": { + "scalarType": "float8" + }, + "nullable": "nonNullable", + "description": null + }, + "srid": { + "name": "srid", + "type": { + "scalarType": "int4" + }, + "nullable": "nonNullable", + "description": null + } + }, + "uniquenessConstraints": { + "topology_name_key": ["name"], + "topology_pkey": ["id"] + }, + "foreignRelations": {}, + "description": null + } + }, + "compositeTypes": { + "committee": { + "name": "committee", + "fields": { + "members": { + "name": "members", + "type": { + "arrayType": { + "compositeType": "person_name" + } + }, + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } + }, + "description": null + }, + "discoverable_types": { + "name": "discoverable_types", + "fields": { + "only_occurring_here1": { + "name": "only_occurring_here1", + "type": { + "scalarType": "int8" + }, + "description": null + } + }, + "description": null + }, + "organization": { + "name": "organization", + "fields": { + "committees": { + "name": "committees", + "type": { + "arrayType": { + "compositeType": "committee" + } + }, + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } + }, + "description": null + }, + "person": { + "name": "person", + "fields": { + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "description": null + }, + "name": { + "name": "name", + "type": { + "compositeType": "person_name" + }, + "description": null + } + }, + "description": null + }, + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + }, + "description": "Address line No 1" + }, + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + }, + "description": "Address line No 2" + } + }, + "description": "The address of a person, obviously" + }, + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { + "scalarType": "text" + }, + "description": "The first name of a person" + }, + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" + }, + "description": "The last name of a person" + } + }, + "description": "The name of a person, obviously" + } + }, + "nativeQueries": { + "address_identity_function": { + "sql": { + "inline": "SELECT {{address}} as result" + }, + "columns": { + "result": { + "name": "result", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + }, + "album_by_title": { + "sql": { + "inline": "SELECT * FROM public.\"Album\" WHERE \"Title\" LIKE {{title}} AND \"AlbumId\" < {{id}}" + }, + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "id": { + "name": "id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "title": { + "name": "title", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "description": null + }, + "array_reverse": { + "sql": { + "inline": "SELECT array_agg(t.x) as reversed FROM (SELECT x FROM unnest({{array}}) WITH ORDINALITY AS t(x,ix) ORDER BY t.ix DESC) as t(x)" + }, + "columns": { + "reversed": { + "name": "reversed", + "type": { + "arrayType": { + "scalarType": "varchar" + } + }, + "nullable": "nullable", + "description": "The reversed array" + } + }, + "arguments": { + "array": { + "name": "array", + "type": { + "arrayType": { + "scalarType": "varchar" + } + }, + "nullable": "nonNullable", + "description": "The array to reverse. This is necessarily of a monomorphic type." + } + }, + "description": "A native query used to test support for arrays as inputs" + }, + "array_series": { + "sql": { + "inline": "SELECT 3 as three, array_agg(arr.series) AS series FROM (SELECT generate_series({{from}},{{to}}) AS series) AS arr" + }, + "columns": { + "series": { + "name": "series", + "type": { + "arrayType": { + "scalarType": "int4" + } + }, + "nullable": "nullable", + "description": null + }, + "three": { + "name": "three", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "from": { + "name": "from", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "to": { + "name": "to", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for arrays" + }, + "artist": { + "sql": { + "inline": "SELECT * FROM public.\"Artist\"" + }, + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": {}, + "description": null + }, + "artist_below_id": { + "sql": { + "inline": "SELECT * FROM public.\"Artist\" WHERE \"ArtistId\" < {{id}}" + }, + "columns": { + "id": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "name": { + "name": "Name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "id": { + "name": "id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + } + }, + "description": null + }, + "count_elements": { + "sql": { + "inline": "SELECT array_length({{array_argument}}, 1) as result" + }, + "columns": { + "result": { + "name": "result", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "array_argument": { + "name": "array_argument", + "type": { + "arrayType": { + "scalarType": "text" + } + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support array-valued variables" + }, + "delete_playlist_track": { + "sql": { + "inline": "DELETE FROM public.\"PlaylistTrack\" WHERE \"TrackId\" = {{track_id}} RETURNING *" + }, + "columns": { + "PlaylistId": { + "name": "PlaylistId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "TrackId": { + "name": "TrackId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "track_id": { + "name": "track_id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + } + }, + "description": null, + "isProcedure": true + }, + "insert_album": { + "sql": { + "inline": "INSERT INTO public.\"Album\" VALUES({{id}}, {{title}}, {{artist_id}}) RETURNING *" + }, + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "artist_id": { + "name": "artist_id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "id": { + "name": "id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "title": { + "name": "title", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "description": null, + "isProcedure": true + }, + "insert_artist": { + "sql": { + "inline": "INSERT INTO public.\"Artist\" VALUES ({{id}}, {{name}}) RETURNING *" + }, + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "id": { + "name": "id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "description": null, + "isProcedure": true + }, + "make_person": { + "sql": { + "inline": "SELECT ROW({{name}}, {{address}})::person as result" + }, + "columns": { + "result": { + "name": "result", + "type": { + "compositeType": "person" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null + }, + "name": { + "name": "name", + "type": { + "compositeType": "person_name" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + }, + "organization_identity_function": { + "sql": { + "inline": "SELECT {{organization}} as result_the_column" + }, + "columns": { + "result_the_field": { + "name": "result_the_column", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "organization": { + "name": "organization", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + }, + "summarize_organizations": { + "sql": { + "file": "./native_queries/summarize_organizations.sql" + }, + "columns": { + "result": { + "name": "result", + "type": { + "scalarType": "text" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "organizations": { + "name": "organizations", + "type": { + "arrayType": { + "compositeType": "organization" + } + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support array-valued variables" + }, + "value_types": { + "sql": { + "inline": "SELECT {{bool}} as bool, {{int4}} as int4, {{int2}} as int2, {{int8}} as int8, {{float4}} as float4, {{float8}} as \"float8\", {{numeric}} as numeric, {{char}} as char, {{varchar}} as \"varchar\", {{text}} as text, {{date}} as date, {{time}} as time, {{timetz}} as timetz, {{timestamp}} as timestamp, {{timestamptz}} as timestamptz, {{uuid}} as uuid" + }, + "columns": { + "bool": { + "name": "bool", + "type": { + "scalarType": "bool" + }, + "nullable": "nullable", + "description": null + }, + "char": { + "name": "char", + "type": { + "scalarType": "char" + }, + "nullable": "nullable", + "description": null + }, + "date": { + "name": "date", + "type": { + "scalarType": "date" + }, + "nullable": "nullable", + "description": null + }, + "float4": { + "name": "float4", + "type": { + "scalarType": "float4" + }, + "nullable": "nullable", + "description": null + }, + "float8": { + "name": "float8", + "type": { + "scalarType": "float8" + }, + "nullable": "nullable", + "description": null + }, + "int2": { + "name": "int2", + "type": { + "scalarType": "int2" + }, + "nullable": "nullable", + "description": null + }, + "int4": { + "name": "int4", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "int8": { + "name": "int8", + "type": { + "scalarType": "int8" + }, + "nullable": "nullable", + "description": null + }, + "numeric": { + "name": "numeric", + "type": { + "scalarType": "numeric" + }, + "nullable": "nullable", + "description": null + }, + "text": { + "name": "text", + "type": { + "scalarType": "text" + }, + "nullable": "nullable", + "description": null + }, + "time": { + "name": "time", + "type": { + "scalarType": "time" + }, + "nullable": "nullable", + "description": null + }, + "timestamp": { + "name": "timestamp", + "type": { + "scalarType": "timestamp" + }, + "nullable": "nullable", + "description": null + }, + "timestamptz": { + "name": "timestamptz", + "type": { + "scalarType": "timestamptz" + }, + "nullable": "nullable", + "description": null + }, + "timetz": { + "name": "timetz", + "type": { + "scalarType": "timetz" + }, + "nullable": "nullable", + "description": null + }, + "uuid": { + "name": "uuid", + "type": { + "scalarType": "uuid" + }, + "nullable": "nullable", + "description": null + }, + "varchar": { + "name": "varchar", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "bool": { + "name": "bool", + "type": { + "scalarType": "bool" + }, + "nullable": "nullable", + "description": null + }, + "char": { + "name": "char", + "type": { + "scalarType": "char" + }, + "nullable": "nullable", + "description": null + }, + "date": { + "name": "date", + "type": { + "scalarType": "date" + }, + "nullable": "nullable", + "description": null + }, + "float4": { + "name": "float4", + "type": { + "scalarType": "float4" + }, + "nullable": "nullable", + "description": null + }, + "float8": { + "name": "float8", + "type": { + "scalarType": "float8" + }, + "nullable": "nullable", + "description": null + }, + "int2": { + "name": "int2", + "type": { + "scalarType": "int2" + }, + "nullable": "nullable", + "description": null + }, + "int4": { + "name": "int4", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "int8": { + "name": "int8", + "type": { + "scalarType": "int8" + }, + "nullable": "nullable", + "description": null + }, + "numeric": { + "name": "numeric", + "type": { + "scalarType": "numeric" + }, + "nullable": "nullable", + "description": null + }, + "text": { + "name": "text", + "type": { + "scalarType": "text" + }, + "nullable": "nullable", + "description": null + }, + "time": { + "name": "time", + "type": { + "scalarType": "time" + }, + "nullable": "nullable", + "description": null + }, + "timestamp": { + "name": "timestamp", + "type": { + "scalarType": "timestamp" + }, + "nullable": "nullable", + "description": null + }, + "timestamptz": { + "name": "timestamptz", + "type": { + "scalarType": "timestamptz" + }, + "nullable": "nullable", + "description": null + }, + "timetz": { + "name": "timetz", + "type": { + "scalarType": "timetz" + }, + "nullable": "nullable", + "description": null + }, + "uuid": { + "name": "uuid", + "type": { + "scalarType": "uuid" + }, + "nullable": "nullable", + "description": null + }, + "varchar": { + "name": "varchar", + "type": { + "scalarType": "varchar" + }, + "nullable": "nullable", + "description": null + } + }, + "description": null + } + }, + "aggregateFunctions": { + "Phone": { + "max": { + "returnType": "text" + }, + "min": { + "returnType": "text" + } + }, + "bit": { + "bit_and": { + "returnType": "bit" + }, + "bit_or": { + "returnType": "bit" + }, + "bit_xor": { + "returnType": "bit" + } + }, + "bool": { + "bool_and": { + "returnType": "bool" + }, + "bool_or": { + "returnType": "bool" + }, + "every": { + "returnType": "bool" + } + }, + "bpchar": { + "max": { + "returnType": "bpchar" + }, + "min": { + "returnType": "bpchar" + } + }, + "card_suit": { + "max": { + "returnType": "card_suit" + }, + "min": { + "returnType": "card_suit" + } + }, + "char": { + "max": { + "returnType": "text" + }, + "min": { + "returnType": "text" + } + }, + "date": { + "max": { + "returnType": "date" + }, + "min": { + "returnType": "date" + } + }, + "even_number": { + "avg": { + "returnType": "numeric" + }, + "bit_and": { + "returnType": "int4" + }, + "bit_or": { + "returnType": "int4" + }, + "bit_xor": { + "returnType": "int4" + }, + "max": { + "returnType": "int4" + }, + "min": { + "returnType": "int4" + }, + "stddev": { + "returnType": "numeric" + }, + "stddev_pop": { + "returnType": "numeric" + }, + "stddev_samp": { + "returnType": "numeric" + }, + "sum": { + "returnType": "int8" + }, + "var_pop": { + "returnType": "numeric" + }, + "var_samp": { + "returnType": "numeric" + }, + "variance": { + "returnType": "numeric" + } + }, + "float4": { + "avg": { + "returnType": "float8" + }, + "max": { + "returnType": "float4" + }, + "min": { + "returnType": "float4" + }, + "stddev": { + "returnType": "float8" + }, + "stddev_pop": { + "returnType": "float8" + }, + "stddev_samp": { + "returnType": "float8" + }, + "sum": { + "returnType": "float4" + }, + "var_pop": { + "returnType": "float8" + }, + "var_samp": { + "returnType": "float8" + }, + "variance": { + "returnType": "float8" + } + }, + "float8": { + "avg": { + "returnType": "float8" + }, + "max": { + "returnType": "float8" + }, + "min": { + "returnType": "float8" + }, + "stddev": { + "returnType": "float8" + }, + "stddev_pop": { + "returnType": "float8" + }, + "stddev_samp": { + "returnType": "float8" + }, + "sum": { + "returnType": "float8" + }, + "var_pop": { + "returnType": "float8" + }, + "var_samp": { + "returnType": "float8" + }, + "variance": { + "returnType": "float8" + } + }, + "int2": { + "avg": { + "returnType": "numeric" + }, + "bit_and": { + "returnType": "int2" + }, + "bit_or": { + "returnType": "int2" + }, + "bit_xor": { + "returnType": "int2" + }, + "max": { + "returnType": "int2" + }, + "min": { + "returnType": "int2" + }, + "stddev": { + "returnType": "numeric" + }, + "stddev_pop": { + "returnType": "numeric" + }, + "stddev_samp": { + "returnType": "numeric" + }, + "sum": { + "returnType": "int8" + }, + "var_pop": { + "returnType": "numeric" + }, + "var_samp": { + "returnType": "numeric" + }, + "variance": { + "returnType": "numeric" + } + }, + "int4": { + "avg": { + "returnType": "numeric" + }, + "bit_and": { + "returnType": "int4" + }, + "bit_or": { + "returnType": "int4" + }, + "bit_xor": { + "returnType": "int4" + }, + "max": { + "returnType": "int4" + }, + "min": { + "returnType": "int4" + }, + "stddev": { + "returnType": "numeric" + }, + "stddev_pop": { + "returnType": "numeric" + }, + "stddev_samp": { + "returnType": "numeric" + }, + "sum": { + "returnType": "int8" + }, + "var_pop": { + "returnType": "numeric" + }, + "var_samp": { + "returnType": "numeric" + }, + "variance": { + "returnType": "numeric" + } + }, + "int8": { + "avg": { + "returnType": "numeric" + }, + "bit_and": { + "returnType": "int8" + }, + "bit_or": { + "returnType": "int8" + }, + "bit_xor": { + "returnType": "int8" + }, + "max": { + "returnType": "int8" + }, + "min": { + "returnType": "int8" + }, + "stddev": { + "returnType": "numeric" + }, + "stddev_pop": { + "returnType": "numeric" + }, + "stddev_samp": { + "returnType": "numeric" + }, + "sum": { + "returnType": "numeric" + }, + "var_pop": { + "returnType": "numeric" + }, + "var_samp": { + "returnType": "numeric" + }, + "variance": { + "returnType": "numeric" + } + }, + "interval": { + "avg": { + "returnType": "interval" + }, + "max": { + "returnType": "interval" + }, + "min": { + "returnType": "interval" + }, + "sum": { + "returnType": "interval" + } + }, + "numeric": { + "avg": { + "returnType": "numeric" + }, + "max": { + "returnType": "numeric" + }, + "min": { + "returnType": "numeric" + }, + "stddev": { + "returnType": "numeric" + }, + "stddev_pop": { + "returnType": "numeric" + }, + "stddev_samp": { + "returnType": "numeric" + }, + "sum": { + "returnType": "numeric" + }, + "var_pop": { + "returnType": "numeric" + }, + "var_samp": { + "returnType": "numeric" + }, + "variance": { + "returnType": "numeric" + } + }, + "text": { + "max": { + "returnType": "text" + }, + "min": { + "returnType": "text" + } + }, + "time": { + "avg": { + "returnType": "interval" + }, + "max": { + "returnType": "time" + }, + "min": { + "returnType": "time" + }, + "sum": { + "returnType": "interval" + } + }, + "timestamp": { + "max": { + "returnType": "timestamp" + }, + "min": { + "returnType": "timestamp" + } + }, + "timestamptz": { + "max": { + "returnType": "timestamptz" + }, + "min": { + "returnType": "timestamptz" + } + }, + "timetz": { + "max": { + "returnType": "timetz" + }, + "min": { + "returnType": "timetz" + } + }, + "varchar": { + "max": { + "returnType": "text" + }, + "min": { + "returnType": "text" + } + } + }, + "comparisonOperators": { + "Phone": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "Phone", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_ilike": { + "operatorName": "~~*", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "Phone", + "isInfix": true + }, + "_iregex": { + "operatorName": "~*", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_like": { + "operatorName": "~~", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_nilike": { + "operatorName": "!~~*", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_niregex": { + "operatorName": "!~*", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_nlike": { + "operatorName": "!~~", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_nregex": { + "operatorName": "!~", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "_regex": { + "operatorName": "~", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": true + }, + "st_coveredby": { + "operatorName": "st_coveredby", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": false + }, + "st_covers": { + "operatorName": "st_covers", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": false + }, + "st_intersects": { + "operatorName": "st_intersects", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": false + }, + "st_relatematch": { + "operatorName": "st_relatematch", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": false + }, + "starts_with": { + "operatorName": "starts_with", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": false + }, + "ts_match_tt": { + "operatorName": "ts_match_tt", + "operatorKind": "custom", + "argumentType": "Phone", + "isInfix": false + } + }, + "bit": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "bit", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "bit", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "bit", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "bit", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "bit", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "bit", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "bit", + "isInfix": true + } + }, + "bool": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "bool", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "bool", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "bool", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "bool", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "bool", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "bool", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "bool", + "isInfix": true + } + }, + "bpchar": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "bpchar", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": true + }, + "_ilike": { + "operatorName": "~~*", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "bpchar", + "isInfix": true + }, + "_iregex": { + "operatorName": "~*", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_like": { + "operatorName": "~~", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": true + }, + "_nilike": { + "operatorName": "!~~*", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_niregex": { + "operatorName": "!~*", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_nlike": { + "operatorName": "!~~", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_nregex": { + "operatorName": "!~", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_regex": { + "operatorName": "~", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "st_coveredby": { + "operatorName": "st_coveredby", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": false + }, + "st_covers": { + "operatorName": "st_covers", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": false + }, + "st_intersects": { + "operatorName": "st_intersects", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": false + }, + "st_relatematch": { + "operatorName": "st_relatematch", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": false + }, + "starts_with": { + "operatorName": "starts_with", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": false + }, + "ts_match_tt": { + "operatorName": "ts_match_tt", + "operatorKind": "custom", + "argumentType": "bpchar", + "isInfix": false + } + }, + "card_suit": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "card_suit", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "card_suit", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "card_suit", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "card_suit", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "card_suit", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "card_suit", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "card_suit", + "isInfix": true + } + }, + "char": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "char", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_ilike": { + "operatorName": "~~*", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "char", + "isInfix": true + }, + "_iregex": { + "operatorName": "~*", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_like": { + "operatorName": "~~", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_nilike": { + "operatorName": "!~~*", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_niregex": { + "operatorName": "!~*", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_nlike": { + "operatorName": "!~~", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_nregex": { + "operatorName": "!~", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "_regex": { + "operatorName": "~", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": true + }, + "st_coveredby": { + "operatorName": "st_coveredby", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": false + }, + "st_covers": { + "operatorName": "st_covers", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": false + }, + "st_intersects": { + "operatorName": "st_intersects", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": false + }, + "st_relatematch": { + "operatorName": "st_relatematch", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": false + }, + "starts_with": { + "operatorName": "starts_with", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": false + }, + "ts_match_tt": { + "operatorName": "ts_match_tt", + "operatorKind": "custom", + "argumentType": "char", + "isInfix": false + } + }, + "date": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "date", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "date", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "date", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "date", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "date", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "date", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "date", + "isInfix": true + } + }, + "even_number": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "even_number", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "even_number", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "even_number", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "even_number", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "even_number", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "even_number", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "even_number", + "isInfix": true + } + }, + "float4": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "float4", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "float4", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "float4", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "float4", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "float4", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "float4", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "float4", + "isInfix": true + } + }, + "float8": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "float8", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "float8", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "float8", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "float8", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "float8", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "float8", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "float8", + "isInfix": true + } + }, + "int2": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "int2", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "int2", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "int2", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "int2", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "int2", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "int2", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "int2", + "isInfix": true + } + }, + "int4": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "int4", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "int4", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "int4", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "int4", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "int4", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "int4", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "int4", + "isInfix": true + } + }, + "int8": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "int8", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "int8", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "int8", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "int8", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "int8", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "int8", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "int8", + "isInfix": true + } + }, + "interval": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "interval", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "interval", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "interval", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "interval", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "interval", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "interval", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "interval", + "isInfix": true + } + }, + "numeric": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "numeric", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "numeric", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "numeric", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "numeric", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "numeric", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "numeric", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "numeric", + "isInfix": true + } + }, + "text": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "text", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_ilike": { + "operatorName": "~~*", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "text", + "isInfix": true + }, + "_iregex": { + "operatorName": "~*", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_like": { + "operatorName": "~~", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_nilike": { + "operatorName": "!~~*", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_niregex": { + "operatorName": "!~*", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_nlike": { + "operatorName": "!~~", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_nregex": { + "operatorName": "!~", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "_regex": { + "operatorName": "~", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": true + }, + "st_coveredby": { + "operatorName": "st_coveredby", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": false + }, + "st_covers": { + "operatorName": "st_covers", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": false + }, + "st_intersects": { + "operatorName": "st_intersects", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": false + }, + "st_relatematch": { + "operatorName": "st_relatematch", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": false + }, + "starts_with": { + "operatorName": "starts_with", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": false + }, + "ts_match_tt": { + "operatorName": "ts_match_tt", + "operatorKind": "custom", + "argumentType": "text", + "isInfix": false + } + }, + "time": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "time", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "time", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "time", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "time", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "time", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "time", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "time", + "isInfix": true + } + }, + "timestamp": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "timestamp", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "timestamp", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "timestamp", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "timestamp", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "timestamp", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "timestamp", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "timestamp", + "isInfix": true + } + }, + "timestamptz": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "timestamptz", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "timestamptz", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "timestamptz", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "timestamptz", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "timestamptz", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "timestamptz", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "timestamptz", + "isInfix": true + } + }, + "timetz": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "timetz", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "timetz", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "timetz", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "timetz", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "timetz", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "timetz", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "timetz", + "isInfix": true + } + }, + "uuid": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "uuid", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "uuid", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "uuid", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "uuid", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "uuid", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "uuid", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "uuid", + "isInfix": true + } + }, + "varchar": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "varchar", + "isInfix": true + }, + "_gt": { + "operatorName": ">", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_gte": { + "operatorName": ">=", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_ilike": { + "operatorName": "~~*", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_in": { + "operatorName": "IN", + "operatorKind": "in", + "argumentType": "varchar", + "isInfix": true + }, + "_iregex": { + "operatorName": "~*", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_like": { + "operatorName": "~~", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_lt": { + "operatorName": "<", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_lte": { + "operatorName": "<=", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_neq": { + "operatorName": "<>", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_nilike": { + "operatorName": "!~~*", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_niregex": { + "operatorName": "!~*", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_nlike": { + "operatorName": "!~~", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_nregex": { + "operatorName": "!~", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "_regex": { + "operatorName": "~", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": true + }, + "st_coveredby": { + "operatorName": "st_coveredby", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": false + }, + "st_covers": { + "operatorName": "st_covers", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": false + }, + "st_intersects": { + "operatorName": "st_intersects", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": false + }, + "st_relatematch": { + "operatorName": "st_relatematch", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": false + }, + "starts_with": { + "operatorName": "starts_with", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": false + }, + "ts_match_tt": { + "operatorName": "ts_match_tt", + "operatorKind": "custom", + "argumentType": "varchar", + "isInfix": false + } + } + }, + "typeRepresentations": { + "Phone": "string", + "bit": "string", + "bool": "boolean", + "bpchar": "string", + "card_suit": { + "enum": ["hearts", "clubs", "diamonds", "spades"] + }, + "char": "string", + "date": "date", + "even_number": "int32", + "float4": "float32", + "float8": "float64", + "int2": "int16", + "int4": "int32", + "int8": "int64", + "numeric": "bigDecimal", + "text": "string", + "time": "time", + "timestamp": "timestamp", + "timestamptz": "timestamptz", + "timetz": "timetz", + "uuid": "uUID", + "varchar": "string" + } + }, + "introspectionOptions": { + "excludedSchemas": [ + "information_schema", + "pg_catalog", + "tiger", + "crdb_internal", + "columnar", + "columnar_internal" + ], + "unqualifiedSchemasForTables": ["public"], + "unqualifiedSchemasForTypesAndProcedures": [ + "public", + "pg_catalog", + "tiger" + ], + "comparisonOperatorMapping": [ + { + "operatorName": "=", + "exposedName": "_eq", + "operatorKind": "equal" + }, + { + "operatorName": "<=", + "exposedName": "_lte", + "operatorKind": "custom" + }, + { + "operatorName": ">", + "exposedName": "_gt", + "operatorKind": "custom" + }, + { + "operatorName": ">=", + "exposedName": "_gte", + "operatorKind": "custom" + }, + { + "operatorName": "<", + "exposedName": "_lt", + "operatorKind": "custom" + }, + { + "operatorName": "!=", + "exposedName": "_neq", + "operatorKind": "custom" + }, + { + "operatorName": "LIKE", + "exposedName": "_like", + "operatorKind": "custom" + }, + { + "operatorName": "NOT LIKE", + "exposedName": "_nlike", + "operatorKind": "custom" + }, + { + "operatorName": "ILIKE", + "exposedName": "_ilike", + "operatorKind": "custom" + }, + { + "operatorName": "NOT ILIKE", + "exposedName": "_nilike", + "operatorKind": "custom" + }, + { + "operatorName": "SIMILAR TO", + "exposedName": "_similar", + "operatorKind": "custom" + }, + { + "operatorName": "NOT SIMILAR TO", + "exposedName": "_nsimilar", + "operatorKind": "custom" + }, + { + "operatorName": "<>", + "exposedName": "_neq", + "operatorKind": "custom" + }, + { + "operatorName": "~~", + "exposedName": "_like", + "operatorKind": "custom" + }, + { + "operatorName": "!~~", + "exposedName": "_nlike", + "operatorKind": "custom" + }, + { + "operatorName": "~~*", + "exposedName": "_ilike", + "operatorKind": "custom" + }, + { + "operatorName": "!~~*", + "exposedName": "_nilike", + "operatorKind": "custom" + }, + { + "operatorName": "~", + "exposedName": "_regex", + "operatorKind": "custom" + }, + { + "operatorName": "!~", + "exposedName": "_nregex", + "operatorKind": "custom" + }, + { + "operatorName": "~*", + "exposedName": "_iregex", + "operatorKind": "custom" + }, + { + "operatorName": "!~*", + "exposedName": "_niregex", + "operatorKind": "custom" + } + ], + "introspectPrefixFunctionComparisonOperators": [ + "box_above", + "box_below", + "box_contain", + "box_contain_pt", + "box_contained", + "box_left", + "box_overabove", + "box_overbelow", + "box_overlap", + "box_overleft", + "box_overright", + "box_right", + "box_same", + "circle_above", + "circle_below", + "circle_contain", + "circle_contain_pt", + "circle_contained", + "circle_left", + "circle_overabove", + "circle_overbelow", + "circle_overlap", + "circle_overleft", + "circle_overright", + "circle_right", + "circle_same", + "contains_2d", + "equals", + "geography_overlaps", + "geometry_above", + "geometry_below", + "geometry_contained_3d", + "geometry_contains", + "geometry_contains_3d", + "geometry_contains_nd", + "geometry_left", + "geometry_overabove", + "geometry_overbelow", + "geometry_overlaps", + "geometry_overlaps_3d", + "geometry_overlaps_nd", + "geometry_overleft", + "geometry_overright", + "geometry_right", + "geometry_same", + "geometry_same_3d", + "geometry_same_nd", + "geometry_within", + "geometry_within_nd", + "inet_same_family", + "inter_lb", + "inter_sb", + "inter_sl", + "is_contained_2d", + "ishorizontal", + "isparallel", + "isperp", + "isvertical", + "jsonb_contained", + "jsonb_contains", + "jsonb_exists", + "jsonb_path_exists_opr", + "jsonb_path_match_opr", + "line_intersect", + "line_parallel", + "line_perp", + "lseg_intersect", + "lseg_parallel", + "lseg_perp", + "network_overlap", + "network_sub", + "network_sup", + "on_pb", + "on_pl", + "on_ppath", + "on_ps", + "on_sb", + "on_sl", + "overlaps_2d", + "path_contain_pt", + "path_inter", + "point_above", + "point_below", + "point_horiz", + "point_left", + "point_right", + "point_vert", + "poly_above", + "poly_below", + "poly_contain", + "poly_contain_pt", + "poly_contained", + "poly_left", + "poly_overabove", + "poly_overbelow", + "poly_overlap", + "poly_overleft", + "poly_overright", + "poly_right", + "poly_same", + "pt_contained_poly", + "st_3dintersects", + "st_contains", + "st_containsproperly", + "st_coveredby", + "st_covers", + "st_crosses", + "st_disjoint", + "st_equals", + "st_intersects", + "st_isvalid", + "st_orderingequals", + "st_overlaps", + "st_relatematch", + "st_touches", + "st_within", + "starts_with", + "ts_match_qv", + "ts_match_tq", + "ts_match_tt", + "ts_match_vq", + "tsq_mcontained", + "tsq_mcontains", + "xmlexists", + "xmlvalidate", + "xpath_exists" + ] + }, + "mutationsVersion": "veryExperimentalWip" +} diff --git a/static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/native_queries/summarize_organizations.sql b/static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/native_queries/summarize_organizations.sql new file mode 100644 index 000000000..58c5e163d --- /dev/null +++ b/static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/native_queries/summarize_organizations.sql @@ -0,0 +1,22 @@ +SELECT + 'The organization ' || org.name || ' has ' || no_committees :: text || ' committees, ' || 'the largest of which has ' || max_members || ' members.' AS result +FROM + ( + SELECT + orgs.* + FROM + unnest({{organizations}}) AS orgs + ) AS org + JOIN LATERAL ( + SELECT + count(committee.*) AS no_committees, + max(members_agg.no_members) AS max_members + FROM + unnest(org.committees) AS committee + JOIN LATERAL ( + SELECT + count(*) AS no_members + FROM + unnest(committee.members) AS members + ) AS members_agg ON TRUE + ) AS coms ON TRUE diff --git a/static/postgres/broken-queries-ndc-metadata/configuration.json b/static/postgres/broken-queries-ndc-metadata/configuration.json index 6666e6c74..cbb9f44f1 100644 --- a/static/postgres/broken-queries-ndc-metadata/configuration.json +++ b/static/postgres/broken-queries-ndc-metadata/configuration.json @@ -300,7 +300,7 @@ }, "typeRepresentations": { "int4": "int32", - "int8": "json", + "int8": "int64", "numeric": "bigDecimal" } }, diff --git a/static/postgres/v3-chinook-ndc-metadata/configuration.json b/static/postgres/v3-chinook-ndc-metadata/configuration.json index b39e0384f..6d7a19493 100644 --- a/static/postgres/v3-chinook-ndc-metadata/configuration.json +++ b/static/postgres/v3-chinook-ndc-metadata/configuration.json @@ -1095,7 +1095,7 @@ "only_occurring_here1": { "name": "only_occurring_here1", "type": { - "scalarType": "bit" + "scalarType": "int8" }, "description": null } @@ -1186,32 +1186,6 @@ } }, "nativeQueries": { - "organization_identity_function": { - "sql": { - "inline": "SELECT {{organization}} as result_the_column" - }, - "columns": { - "result_the_field": { - "name": "result_the_column", - "type": { - "compositeType": "organization" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "organization": { - "name": "organization", - "type": { - "compositeType": "organization" - }, - "nullable": "nullable", - "description": null - } - }, - "description": "A native query used to test support for composite types" - }, "address_identity_function": { "sql": { "inline": "SELECT {{address}} as result" @@ -1620,6 +1594,32 @@ }, "description": "A native query used to test support for composite types" }, + "organization_identity_function": { + "sql": { + "inline": "SELECT {{organization}} as result_the_column" + }, + "columns": { + "result_the_field": { + "name": "result_the_column", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "organization": { + "name": "organization", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + }, "summarize_organizations": { "sql": { "file": "./native_queries/summarize_organizations.sql" @@ -3712,7 +3712,7 @@ "float8": "float64", "int2": "int16", "int4": "int32", - "int8": "json", + "int8": "int64", "numeric": "bigDecimal", "text": "string", "time": "time", diff --git a/static/yugabyte/v3-chinook-ndc-metadata/configuration.json b/static/yugabyte/v3-chinook-ndc-metadata/configuration.json index 57908c9dc..e8774e29b 100644 --- a/static/yugabyte/v3-chinook-ndc-metadata/configuration.json +++ b/static/yugabyte/v3-chinook-ndc-metadata/configuration.json @@ -838,7 +838,7 @@ "only_occurring_here1": { "name": "only_occurring_here1", "type": { - "scalarType": "bit" + "scalarType": "int8" }, "description": null } @@ -929,32 +929,6 @@ } }, "nativeQueries": { - "organization_identity_function": { - "sql": { - "inline": "SELECT {{organization}} as result_the_column" - }, - "columns": { - "result_the_field": { - "name": "result_the_column", - "type": { - "compositeType": "organization" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "organization": { - "name": "organization", - "type": { - "compositeType": "organization" - }, - "nullable": "nullable", - "description": null - } - }, - "description": "A native query used to test support for composite types" - }, "address_identity_function": { "sql": "SELECT {{address}} as result", "columns": { @@ -1341,6 +1315,32 @@ }, "description": "A native query used to test support for composite types" }, + "organization_identity_function": { + "sql": { + "inline": "SELECT {{organization}} as result_the_column" + }, + "columns": { + "result_the_field": { + "name": "result_the_column", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "organization": { + "name": "organization", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + }, "summarize_organizations": { "sql": "SELECT 'The organization ' || org.name || ' has ' || no_committees::text || ' committees, ' || 'the largest of which has ' || max_members || ' members.' AS result FROM (SELECT orgs.* FROM unnest({{organizations}}) as orgs) AS org JOIN LATERAL ( SELECT count(committee.*) AS no_committees, max(members_agg.no_members) AS max_members FROM unnest(org.committees) AS committee JOIN LATERAL ( SELECT count(*) as no_members FROM unnest(committee.members) AS members) AS members_agg ON true) AS coms ON true", "columns": { @@ -3294,7 +3294,7 @@ "float8": "float64", "int2": "int16", "int4": "int32", - "int8": "json", + "int8": "int64", "numeric": "bigDecimal", "text": "string", "time": "time", From f8dc828e0a3030fc2aa8520113e13601bb69a1d4 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 12:45:50 +0300 Subject: [PATCH 02/16] Refactor, rename type reps, use user defs --- crates/configuration/src/version3/mod.rs | 21 +++- crates/connectors/ndc-postgres/src/schema.rs | 10 +- .../metadata/src/metadata/database.rs | 16 ++- .../translation/src/translation/helpers.rs | 111 ++++++++---------- .../src/translation/query/fields.rs | 81 +++++++++---- ...uery_tests__types__select_value_types.snap | 4 +- ...uery_tests__types__select_value_types.snap | 4 +- ...schema_tests__schema_test__get_schema.snap | 4 +- ...y_tests__basic__select_int_and_string.snap | 2 +- ...es__select_where_album_id_equals_self.snap | 2 +- ...s__select_where_album_id_greater_than.snap | 14 +-- ...ere_album_id_greater_than_or_equal_to.snap | 16 +-- ..._where_album_id_less_than_or_equal_to.snap | 2 +- ...__predicates__select_where_name_ilike.snap | 14 +-- ...sts__predicates__select_where_name_in.snap | 2 +- ..._predicates__select_where_name_iregex.snap | 2 +- ...s__predicates__select_where_name_like.snap | 14 +-- ...predicates__select_where_name_niregex.snap | 10 +- ..._predicates__select_where_name_not_in.snap | 10 +- ...redicates__select_where_name_not_like.snap | 10 +- ..._predicates__select_where_name_nregex.snap | 20 ++-- ...redicates__select_where_name_nsimilar.snap | 10 +- ...__predicates__select_where_name_regex.snap | 2 +- ...predicates__select_where_name_similar.snap | 10 +- ...predicates__select_where_variable_int.snap | 4 +- ...s__very_nested_recursive_relationship.snap | 10 +- ...uery_tests__types__select_value_types.snap | 4 +- ...schema_tests__schema_test__get_schema.snap | 4 +- ...ation_tests__get_configuration_schema.snap | 16 ++- ...tests__get_rawconfiguration_v3_schema.snap | 16 ++- ...v3_initial_configuration_is_unchanged.snap | 2 +- ..._openapi__up_to_date_generated_schema.snap | 16 ++- ...uery_tests__types__select_value_types.snap | 4 +- .../configuration.json | 4 +- .../summarize_organizations.sql | 0 .../configuration.json | 4 +- static/schema.json | 12 +- 37 files changed, 297 insertions(+), 190 deletions(-) rename static/ndc-metadata-snapshots/{6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497 => 3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5}/configuration.json (99%) rename static/ndc-metadata-snapshots/{6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497 => 3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5}/native_queries/summarize_organizations.sql (100%) diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index 2a179ecaf..1a14f01d8 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -106,7 +106,9 @@ pub async fn introspect( .introspection_options .introspect_prefix_function_comparison_operators, ) - .bind(serde_json::to_value(base_type_representations().0)?); + .bind(serde_json::to_value( + base_type_representations(args.metadata.type_representations).0, + )?); let row = connection .fetch_one(query) @@ -195,8 +197,11 @@ pub async fn introspect( }) } -fn base_type_representations() -> database::TypeRepresentations { - database::TypeRepresentations( +fn base_type_representations( + database::TypeRepresentations(existing_type_representations): database::TypeRepresentations, +) -> database::TypeRepresentations { + // Start with the default type representations + let mut type_representations: database::TypeRepresentations = database::TypeRepresentations( [ // Bit strings: // https://www.postgresql.org/docs/current/datatype-bit.html @@ -246,7 +251,7 @@ fn base_type_representations() -> database::TypeRepresentations { // This is not what we do now and is a breaking change. // This will need to be changed in the future. In the meantime, we report // The type representation to be json. - database::TypeRepresentation::Int64, + database::TypeRepresentation::Int64AsString, ), ( database::ScalarType("numeric".to_string()), @@ -282,7 +287,13 @@ fn base_type_representations() -> database::TypeRepresentations { ), ] .into(), - ) + ); + // If the user has already defined existing type representations, + // override the default ones with `insert`. + for (typ, type_rep) in existing_type_representations { + type_representations.0.insert(typ, type_rep); + } + type_representations } /// Collect all the composite types that can occur in the metadata. diff --git a/crates/connectors/ndc-postgres/src/schema.rs b/crates/connectors/ndc-postgres/src/schema.rs index 0388c40b3..187bd8c0d 100644 --- a/crates/connectors/ndc-postgres/src/schema.rs +++ b/crates/connectors/ndc-postgres/src/schema.rs @@ -626,8 +626,14 @@ fn map_type_representation( metadata::TypeRepresentation::Float64 => models::TypeRepresentation::Float64, metadata::TypeRepresentation::Int16 => models::TypeRepresentation::Int16, metadata::TypeRepresentation::Int32 => models::TypeRepresentation::Int32, - metadata::TypeRepresentation::Int64 => models::TypeRepresentation::Int64, - metadata::TypeRepresentation::BigDecimal => models::TypeRepresentation::BigDecimal, + // Int64 returns a number. + metadata::TypeRepresentation::Int64 => models::TypeRepresentation::JSON, + // Int64AsString returns a string. + metadata::TypeRepresentation::Int64AsString => models::TypeRepresentation::Int64, + // BigDecimal returns a number. + metadata::TypeRepresentation::BigDecimal => models::TypeRepresentation::JSON, + // BigDecimalAsString returns a string. + metadata::TypeRepresentation::BigDecimalAsString => models::TypeRepresentation::BigDecimal, metadata::TypeRepresentation::Timestamp => models::TypeRepresentation::Timestamp, metadata::TypeRepresentation::Timestamptz => models::TypeRepresentation::TimestampTZ, metadata::TypeRepresentation::Time => models::TypeRepresentation::String, diff --git a/crates/query-engine/metadata/src/metadata/database.rs b/crates/query-engine/metadata/src/metadata/database.rs index bfb50dc94..2634a055e 100644 --- a/crates/query-engine/metadata/src/metadata/database.rs +++ b/crates/query-engine/metadata/src/metadata/database.rs @@ -23,6 +23,16 @@ pub enum Type { ArrayType(Box), } +impl Type { + pub fn scalar_type(&self) -> Option<&ScalarType> { + match self { + Type::ScalarType(scalar_type) => Some(scalar_type), + Type::CompositeType(_) => None, + Type::ArrayType(_) => None, + } + } +} + /// Information about a composite type. These are very similar to tables, but with the crucial /// difference that composite types do not support constraints (such as NOT NULL). #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] @@ -225,10 +235,14 @@ pub enum TypeRepresentation { Int16, /// int4 Int32, - /// int8 + /// int8 as integer Int64, + /// int8 as string + Int64AsString, /// numeric BigDecimal, + /// numeric as string + BigDecimalAsString, /// timestamp Timestamp, /// timestamp with timezone diff --git a/crates/query-engine/translation/src/translation/helpers.rs b/crates/query-engine/translation/src/translation/helpers.rs index e46f05cf2..314cb4323 100644 --- a/crates/query-engine/translation/src/translation/helpers.rs +++ b/crates/query-engine/translation/src/translation/helpers.rs @@ -91,16 +91,12 @@ pub enum CollectionInfo<'env> { #[derive(Debug)] /// Metadata information about a specific collection or composite type. -pub enum CollectionOrCompositeTypeInfo<'env> { +pub enum CompositeTypeInfo<'env> { CollectionInfo(CollectionInfo<'env>), - CompositeTypeInfo(CompositeTypeInfo), -} - -#[derive(Debug)] -/// Information about composite types. -pub struct CompositeTypeInfo { - pub name: String, - pub info: metadata::CompositeType, + CompositeTypeInfo { + name: String, + info: metadata::CompositeType, + }, } impl<'request> Env<'request> { @@ -120,22 +116,20 @@ impl<'request> Env<'request> { } /// Lookup collection or composite type. - pub fn lookup_collection_or_composite_type( + pub fn lookup_composite_type( &self, type_name: &'request str, - ) -> Result, Error> { + ) -> Result, Error> { let it_is_a_collection = self.lookup_collection(type_name); match it_is_a_collection { - Ok(collection_info) => Ok(CollectionOrCompositeTypeInfo::CollectionInfo( - collection_info, - )), + Ok(collection_info) => Ok(CompositeTypeInfo::CollectionInfo(collection_info)), Err(Error::CollectionNotFound(_)) => { let its_a_type = self.metadata.composite_types.0.get(type_name).map(|t| { - CollectionOrCompositeTypeInfo::CompositeTypeInfo(CompositeTypeInfo { + CompositeTypeInfo::CompositeTypeInfo { name: t.name.clone(), info: t.clone(), - }) + } }); its_a_type.ok_or(Error::CollectionNotFound(type_name.to_string())) @@ -144,20 +138,6 @@ impl<'request> Env<'request> { } } - pub fn lookup_composite_type(&self, type_name: &str) -> Result { - let its_a_type = - self.metadata - .composite_types - .0 - .get(type_name) - .map(|t| CompositeTypeInfo { - name: t.name.clone(), - info: t.clone(), - }); - - its_a_type.ok_or(Error::CollectionNotFound(type_name.to_string())) - } - /// Lookup a collection's information in the metadata. pub fn lookup_collection( &self, @@ -226,18 +206,13 @@ impl<'request> Env<'request> { /// Lookup type representation of a type. pub fn lookup_type_representation( &self, - typ: &metadata::Type, + scalar_type: &metadata::ScalarType, ) -> Option { - match typ { - metadata::Type::ScalarType(scalar_type) => self - .metadata - .type_representations - .0 - .get(scalar_type) - .cloned(), - metadata::Type::ArrayType(_) => None, - metadata::Type::CompositeType(_) => None, - } + self.metadata + .type_representations + .0 + .get(scalar_type) + .cloned() } /// Try to get the variables table reference. This will fail if no variables were passed @@ -280,34 +255,48 @@ impl CollectionInfo<'_> { } } -impl CollectionOrCompositeTypeInfo<'_> { +impl CompositeTypeInfo<'_> { /// Lookup a column in a collection. pub fn lookup_column(&self, column_name: &str) -> Result { match self { - CollectionOrCompositeTypeInfo::CollectionInfo(collection_info) => { + CompositeTypeInfo::CollectionInfo(collection_info) => { collection_info.lookup_column(column_name) } - CollectionOrCompositeTypeInfo::CompositeTypeInfo(composite_type) => { - composite_type.lookup_column(column_name) - } + CompositeTypeInfo::CompositeTypeInfo { name, info } => info + .fields + .get(column_name) + .map(|field_info| ColumnInfo { + name: sql::ast::ColumnName(field_info.name.clone()), + r#type: field_info.r#type.clone(), + }) + .ok_or(Error::ColumnNotFoundInCollection( + column_name.to_string(), + name.clone(), + )), } } -} -impl CompositeTypeInfo { - /// Lookup a column in a composite type. - pub fn lookup_column(&self, column_name: &str) -> Result { - self.info - .fields - .get(column_name) - .map(|field_info| ColumnInfo { - name: sql::ast::ColumnName(field_info.name.clone()), - r#type: field_info.r#type.clone(), - }) - .ok_or(Error::ColumnNotFoundInCollection( - column_name.to_string(), - self.name.clone(), - )) + pub fn fields(&self) -> Vec<(&String, &String)> { + match self { + CompositeTypeInfo::CompositeTypeInfo { name: _, info } => info + .fields + .iter() + .map(|(name, field)| (name, &field.name)) + .collect::>(), + + CompositeTypeInfo::CollectionInfo(collection_info) => match collection_info { + CollectionInfo::Table { name: _, info } => info + .columns + .iter() + .map(|(name, column)| (name, &column.name)) + .collect::>(), + CollectionInfo::NativeQuery { name: _, info } => info + .columns + .iter() + .map(|(name, column)| (name, &column.name)) + .collect::>(), + }, + } } } diff --git a/crates/query-engine/translation/src/translation/query/fields.rs b/crates/query-engine/translation/src/translation/query/fields.rs index 3a1afb83f..df364d312 100644 --- a/crates/query-engine/translation/src/translation/query/fields.rs +++ b/crates/query-engine/translation/src/translation/query/fields.rs @@ -8,7 +8,7 @@ use ndc_sdk::models; use super::relationships; use crate::translation::error::Error; use crate::translation::helpers::{ - CollectionOrCompositeTypeInfo, ColumnInfo, Env, State, TableNameAndReference, + ColumnInfo, CompositeTypeInfo, Env, State, TableNameAndReference, }; use query_engine_metadata::metadata::{Type, TypeRepresentation}; use query_engine_sql::sql; @@ -44,7 +44,7 @@ pub(crate) fn translate_fields( join_relationship_fields: &mut Vec, ) -> Result { // find the table according to the metadata. - let type_info = env.lookup_collection_or_composite_type(¤t_table.name)?; + let type_info = env.lookup_composite_type(¤t_table.name)?; // Each nested field is computed in one joined-on sub query. let mut nested_field_joins: Vec = vec![]; @@ -335,7 +335,7 @@ fn unpack_and_wrap_fields( join_relationship_fields: &mut Vec, column: &str, alias: sql::ast::ColumnAlias, - type_info: &CollectionOrCompositeTypeInfo<'_>, + type_info: &CompositeTypeInfo<'_>, nested_field_joins: &mut Vec, ) -> Result<(sql::ast::ColumnAlias, sql::ast::Expression), Error> { let column_info = type_info.lookup_column(column)?; @@ -345,7 +345,10 @@ fn unpack_and_wrap_fields( match column_info.r#type { // Scalar types can just be wrapped in a cast. Type::ScalarType(_) => { - let column_type_representation = env.lookup_type_representation(&column_info.r#type); + let column_type_representation = column_info + .r#type + .scalar_type() + .and_then(|scalar_type| env.lookup_type_representation(scalar_type)); let (alias, expression) = sql::helpers::make_column( current_table.reference.clone(), column_info.name.clone(), @@ -365,11 +368,11 @@ fn unpack_and_wrap_fields( let nested_field = models::NestedField::Object({ let composite_type = env.lookup_composite_type(composite_type)?; let mut fields = indexmap!(); - for (name, field_info) in composite_type.info.fields.iter() { + for (result_name, field_name) in composite_type.fields() { fields.insert( - name.to_string(), + result_name.to_string(), models::Field::Column { - column: field_info.name.clone(), + column: field_name.clone(), fields: None, }, ); @@ -394,19 +397,27 @@ fn unpack_and_wrap_fields( sql::ast::Expression::ColumnReference(nested_column_reference), )) } - // TODO: Arrays for composite types and nested arrays are not handled yet. - Type::ArrayType(type_boxed) => { - let inner_column_type_representation = env.lookup_type_representation(&*type_boxed); - let (alias, expression) = sql::helpers::make_column( - current_table.reference.clone(), - column_info.name.clone(), - alias, - ); - Ok(( - alias, - wrap_array_in_type_representation(expression, inner_column_type_representation), - )) - } + // TODO: Arrays for composite types are not handled yet. + Type::ArrayType(type_boxed) => match *type_boxed { + Type::ArrayType(_) => Err(Error::NestedArraysNotSupported { + field_name: column.to_string(), + }), + Type::CompositeType(_) => Err(Error::NotImplementedYet( + "an array of a composite type".to_string(), + )), + Type::ScalarType(scalar_type) => { + let inner_column_type_representation = env.lookup_type_representation(&scalar_type); + let (alias, expression) = sql::helpers::make_column( + current_table.reference.clone(), + column_info.name.clone(), + alias, + ); + Ok(( + alias, + wrap_array_in_type_representation(expression, inner_column_type_representation), + )) + } + }, } } @@ -443,15 +454,39 @@ fn wrap_in_type_representation( match column_type_representation { None => expression, Some(type_rep) => match type_rep { - TypeRepresentation::Int64 => sql::ast::Expression::Cast { + // In these situations, we expect to cast the expression according + // to the type representation. + TypeRepresentation::Int64AsString => sql::ast::Expression::Cast { expression: Box::new(expression), r#type: sql::ast::ScalarType("text".to_string()), }, - TypeRepresentation::BigDecimal => sql::ast::Expression::Cast { + TypeRepresentation::BigDecimalAsString => sql::ast::Expression::Cast { expression: Box::new(expression), r#type: sql::ast::ScalarType("text".to_string()), }, - _ => expression, + + // In these situations the type representation should be the same as + // the expression, so we don't cast it. + TypeRepresentation::Boolean => expression, + TypeRepresentation::String => expression, + TypeRepresentation::Float32 => expression, + TypeRepresentation::Float64 => expression, + TypeRepresentation::Int16 => expression, + TypeRepresentation::Int32 => expression, + TypeRepresentation::Int64 => expression, + TypeRepresentation::BigDecimal => expression, + TypeRepresentation::Timestamp => expression, + TypeRepresentation::Timestamptz => expression, + TypeRepresentation::Time => expression, + TypeRepresentation::Timetz => expression, + TypeRepresentation::Date => expression, + TypeRepresentation::UUID => expression, + TypeRepresentation::Geography => expression, + TypeRepresentation::Geometry => expression, + TypeRepresentation::Number => expression, + TypeRepresentation::Integer => expression, + TypeRepresentation::Json => expression, + TypeRepresentation::Enum(_) => expression, }, } } diff --git a/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__types__select_value_types.snap b/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__types__select_value_types.snap index 2a77143f4..c6b6da209 100644 --- a/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__types__select_value_types.snap +++ b/crates/tests/databases-tests/src/aurora/snapshots/databases_tests__aurora__query_tests__types__select_value_types.snap @@ -9,10 +9,10 @@ expression: result "bool": true, "int2": 245, "int4": 24555, - "int8": "245555555", + "int8": 245555555, "float4": 24.555, "float8": 2455.555, - "numeric": "24.555", + "numeric": 24.555, "char": "s", "varchar": "varchar string", "text": "textual text", diff --git a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__types__select_value_types.snap b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__types__select_value_types.snap index b8ca8908c..afc32602a 100644 --- a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__types__select_value_types.snap +++ b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__query_tests__types__select_value_types.snap @@ -9,10 +9,10 @@ expression: result "bool": true, "int2": 245, "int4": 24555, - "int8": "245555555", + "int8": 245555555, "float4": 24.555, "float8": 2455.555, - "numeric": "24.555", + "numeric": 24.555, "char": "s", "varchar": "varchar string", "text": "textual text", diff --git a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap index e6b2115ed..e71860256 100644 --- a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap +++ b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap @@ -1272,7 +1272,7 @@ expression: result }, "int8": { "representation": { - "type": "int64" + "type": "json" }, "aggregate_functions": { "avg": { @@ -1471,7 +1471,7 @@ expression: result }, "numeric": { "representation": { - "type": "bigdecimal" + "type": "json" }, "aggregate_functions": { "avg": { diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_int_and_string.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_int_and_string.snap index 57096385e..eaf1c5274 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_int_and_string.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_int_and_string.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": "35", + "AlbumId": 35, "title": "Garage Inc. (Disc 1)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_equals_self.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_equals_self.snap index 0f244fd3b..e55338e53 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_equals_self.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_equals_self.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": "340", + "AlbumId": 340, "Title": "Liszt - 12 Études D'Execution Transcendante" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than.snap index ffe0186f7..d4d44ea02 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than.snap @@ -6,31 +6,31 @@ expression: result { "rows": [ { - "AlbumId": "341", + "AlbumId": 341, "Title": "Great Recordings of the Century - Shubert: Schwanengesang, 4 Lieder" }, { - "AlbumId": "342", + "AlbumId": 342, "Title": "Locatelli: Concertos for Violin, Strings and Continuo, Vol. 3" }, { - "AlbumId": "343", + "AlbumId": 343, "Title": "Respighi:Pines of Rome" }, { - "AlbumId": "344", + "AlbumId": 344, "Title": "Schubert: The Late String Quartets & String Quintet (3 CD's)" }, { - "AlbumId": "345", + "AlbumId": 345, "Title": "Monteverdi: L'Orfeo" }, { - "AlbumId": "346", + "AlbumId": 346, "Title": "Mozart: Chamber Music" }, { - "AlbumId": "347", + "AlbumId": 347, "Title": "Koyaanisqatsi (Soundtrack from the Motion Picture)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than_or_equal_to.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than_or_equal_to.snap index b6d2bbca8..4be116577 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than_or_equal_to.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_greater_than_or_equal_to.snap @@ -6,35 +6,35 @@ expression: result { "rows": [ { - "AlbumId": "340", + "AlbumId": 340, "Title": "Liszt - 12 Études D'Execution Transcendante" }, { - "AlbumId": "341", + "AlbumId": 341, "Title": "Great Recordings of the Century - Shubert: Schwanengesang, 4 Lieder" }, { - "AlbumId": "342", + "AlbumId": 342, "Title": "Locatelli: Concertos for Violin, Strings and Continuo, Vol. 3" }, { - "AlbumId": "343", + "AlbumId": 343, "Title": "Respighi:Pines of Rome" }, { - "AlbumId": "344", + "AlbumId": 344, "Title": "Schubert: The Late String Quartets & String Quintet (3 CD's)" }, { - "AlbumId": "345", + "AlbumId": 345, "Title": "Monteverdi: L'Orfeo" }, { - "AlbumId": "346", + "AlbumId": 346, "Title": "Mozart: Chamber Music" }, { - "AlbumId": "347", + "AlbumId": 347, "Title": "Koyaanisqatsi (Soundtrack from the Motion Picture)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_less_than_or_equal_to.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_less_than_or_equal_to.snap index 5b8973cbf..083048e33 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_less_than_or_equal_to.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_album_id_less_than_or_equal_to.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": "1", + "AlbumId": 1, "Title": "For Those About To Rock We Salute You" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_ilike.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_ilike.snap index 5b8eb5040..44d49e59c 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_ilike.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_ilike.snap @@ -6,31 +6,31 @@ expression: result { "rows": [ { - "AlbumId": "1", + "AlbumId": 1, "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": "4", + "AlbumId": 4, "Title": "Let There Be Rock" }, { - "AlbumId": "59", + "AlbumId": 59, "Title": "Deep Purple In Rock" }, { - "AlbumId": "108", + "AlbumId": 108, "Title": "Rock In Rio [CD1]" }, { - "AlbumId": "109", + "AlbumId": 109, "Title": "Rock In Rio [CD2]" }, { - "AlbumId": "213", + "AlbumId": 213, "Title": "Pure Cult: The Best Of The Cult (For Rockers, Ravers, Lovers & Sinners) [UK]" }, { - "AlbumId": "216", + "AlbumId": 216, "Title": "Hot Rocks, 1964-1971 (Disc 1)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_in.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_in.snap index 6681842c8..99d7e07de 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_in.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_in.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": "346", + "AlbumId": 346, "Title": "Mozart: Chamber Music" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_iregex.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_iregex.snap index c5a300059..89f65b410 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_iregex.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_iregex.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": "6", + "AlbumId": 6, "Title": "Jagged Little Pill" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_like.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_like.snap index 5b8eb5040..44d49e59c 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_like.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_like.snap @@ -6,31 +6,31 @@ expression: result { "rows": [ { - "AlbumId": "1", + "AlbumId": 1, "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": "4", + "AlbumId": 4, "Title": "Let There Be Rock" }, { - "AlbumId": "59", + "AlbumId": 59, "Title": "Deep Purple In Rock" }, { - "AlbumId": "108", + "AlbumId": 108, "Title": "Rock In Rio [CD1]" }, { - "AlbumId": "109", + "AlbumId": 109, "Title": "Rock In Rio [CD2]" }, { - "AlbumId": "213", + "AlbumId": 213, "Title": "Pure Cult: The Best Of The Cult (For Rockers, Ravers, Lovers & Sinners) [UK]" }, { - "AlbumId": "216", + "AlbumId": 216, "Title": "Hot Rocks, 1964-1971 (Disc 1)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_niregex.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_niregex.snap index 626817df1..f6b90784a 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_niregex.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_niregex.snap @@ -6,23 +6,23 @@ expression: result { "rows": [ { - "AlbumId": "1", + "AlbumId": 1, "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": "2", + "AlbumId": 2, "Title": "Balls to the Wall" }, { - "AlbumId": "3", + "AlbumId": 3, "Title": "Restless and Wild" }, { - "AlbumId": "4", + "AlbumId": 4, "Title": "Let There Be Rock" }, { - "AlbumId": "5", + "AlbumId": 5, "Title": "Big Ones" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_in.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_in.snap index 626817df1..f6b90784a 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_in.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_in.snap @@ -6,23 +6,23 @@ expression: result { "rows": [ { - "AlbumId": "1", + "AlbumId": 1, "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": "2", + "AlbumId": 2, "Title": "Balls to the Wall" }, { - "AlbumId": "3", + "AlbumId": 3, "Title": "Restless and Wild" }, { - "AlbumId": "4", + "AlbumId": 4, "Title": "Let There Be Rock" }, { - "AlbumId": "5", + "AlbumId": 5, "Title": "Big Ones" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_like.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_like.snap index 307def278..a941af127 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_like.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_not_like.snap @@ -6,23 +6,23 @@ expression: result { "rows": [ { - "AlbumId": "2", + "AlbumId": 2, "Title": "Balls to the Wall" }, { - "AlbumId": "3", + "AlbumId": 3, "Title": "Restless and Wild" }, { - "AlbumId": "5", + "AlbumId": 5, "Title": "Big Ones" }, { - "AlbumId": "6", + "AlbumId": 6, "Title": "Jagged Little Pill" }, { - "AlbumId": "7", + "AlbumId": 7, "Title": "Facelift" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nregex.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nregex.snap index 9cf950ba6..a73632c50 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nregex.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nregex.snap @@ -6,43 +6,43 @@ expression: result { "rows": [ { - "AlbumId": "1", + "AlbumId": 1, "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": "2", + "AlbumId": 2, "Title": "Balls to the Wall" }, { - "AlbumId": "3", + "AlbumId": 3, "Title": "Restless and Wild" }, { - "AlbumId": "4", + "AlbumId": 4, "Title": "Let There Be Rock" }, { - "AlbumId": "5", + "AlbumId": 5, "Title": "Big Ones" }, { - "AlbumId": "7", + "AlbumId": 7, "Title": "Facelift" }, { - "AlbumId": "8", + "AlbumId": 8, "Title": "Warner 25 Anos" }, { - "AlbumId": "9", + "AlbumId": 9, "Title": "Plays Metallica By Four Cellos" }, { - "AlbumId": "10", + "AlbumId": 10, "Title": "Audioslave" }, { - "AlbumId": "11", + "AlbumId": 11, "Title": "Out Of Exile" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nsimilar.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nsimilar.snap index de5baa93b..882d56f64 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nsimilar.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_nsimilar.snap @@ -6,23 +6,23 @@ expression: result { "rows": [ { - "AlbumId": "1", + "AlbumId": 1, "Title": "For Those About To Rock We Salute You" }, { - "AlbumId": "4", + "AlbumId": 4, "Title": "Let There Be Rock" }, { - "AlbumId": "6", + "AlbumId": 6, "Title": "Jagged Little Pill" }, { - "AlbumId": "7", + "AlbumId": 7, "Title": "Facelift" }, { - "AlbumId": "8", + "AlbumId": 8, "Title": "Warner 25 Anos" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_regex.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_regex.snap index c5a300059..89f65b410 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_regex.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_regex.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": "6", + "AlbumId": 6, "Title": "Jagged Little Pill" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_similar.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_similar.snap index b5a2862d9..ff1f1e282 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_similar.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_name_similar.snap @@ -6,23 +6,23 @@ expression: result { "rows": [ { - "AlbumId": "2", + "AlbumId": 2, "Title": "Balls to the Wall" }, { - "AlbumId": "3", + "AlbumId": 3, "Title": "Restless and Wild" }, { - "AlbumId": "5", + "AlbumId": 5, "Title": "Big Ones" }, { - "AlbumId": "12", + "AlbumId": 12, "Title": "BackBeat Soundtrack" }, { - "AlbumId": "16", + "AlbumId": 16, "Title": "Black Sabbath" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_variable_int.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_variable_int.snap index 800606bec..25f2ec11c 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_variable_int.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__predicates__select_where_variable_int.snap @@ -6,7 +6,7 @@ expression: result { "rows": [ { - "AlbumId": "35", + "AlbumId": 35, "Title": "Garage Inc. (Disc 1)" } ] @@ -14,7 +14,7 @@ expression: result { "rows": [ { - "AlbumId": "222", + "AlbumId": 222, "Title": "Serie Sem Limite (Disc 1)" } ] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__relationships__very_nested_recursive_relationship.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__relationships__very_nested_recursive_relationship.snap index 2dddf0f12..e62f02314 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__relationships__very_nested_recursive_relationship.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__relationships__very_nested_recursive_relationship.snap @@ -14,7 +14,7 @@ expression: result "Artist": { "rows": [ { - "0ArtistId": "1", + "0ArtistId": 1, "Albums": { "rows": [ { @@ -48,7 +48,7 @@ expression: result "Artist": { "rows": [ { - "0ArtistId": "1", + "0ArtistId": 1, "Albums": { "rows": [ { @@ -89,7 +89,7 @@ expression: result "Artist": { "rows": [ { - "0ArtistId": "2", + "0ArtistId": 2, "Albums": { "rows": [ { @@ -123,7 +123,7 @@ expression: result "Artist": { "rows": [ { - "0ArtistId": "2", + "0ArtistId": 2, "Albums": { "rows": [ { @@ -164,7 +164,7 @@ expression: result "Artist": { "rows": [ { - "0ArtistId": "3", + "0ArtistId": 3, "Albums": { "rows": [ { diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__types__select_value_types.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__types__select_value_types.snap index d447d9ce8..6122d10bf 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__types__select_value_types.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__types__select_value_types.snap @@ -13,8 +13,8 @@ expression: result "float8": 2455.555, "int2": 245, "int4": 24555, - "int8": "245555555", - "numeric": "24.555", + "int8": 245555555, + "numeric": 24.555, "text": "textual text", "time": "02:35:59", "timestamp": "2013-11-03T02:35:59", diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__schema_tests__schema_test__get_schema.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__schema_tests__schema_test__get_schema.snap index 62ff50e29..64a5a67c3 100644 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__schema_tests__schema_test__get_schema.snap +++ b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__schema_tests__schema_test__get_schema.snap @@ -809,7 +809,7 @@ expression: result }, "int8": { "representation": { - "type": "int64" + "type": "json" }, "aggregate_functions": { "avg": { @@ -996,7 +996,7 @@ expression: result }, "numeric": { "representation": { - "type": "bigdecimal" + "type": "json" }, "aggregate_functions": { "avg": { diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap index 9721dfa84..d8f73cb5d 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap @@ -1029,12 +1029,19 @@ expression: schema ] }, { - "description": "int8", + "description": "int8 as integer", "type": "string", "enum": [ "int64" ] }, + { + "description": "int8 as string", + "type": "string", + "enum": [ + "int64AsString" + ] + }, { "description": "numeric", "type": "string", @@ -1042,6 +1049,13 @@ expression: schema "bigDecimal" ] }, + { + "description": "numeric as string", + "type": "string", + "enum": [ + "bigDecimalAsString" + ] + }, { "description": "timestamp", "type": "string", diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_rawconfiguration_v3_schema.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_rawconfiguration_v3_schema.snap index c43556a7c..8251cc794 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_rawconfiguration_v3_schema.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_rawconfiguration_v3_schema.snap @@ -1017,12 +1017,19 @@ expression: schema ] }, { - "description": "int8", + "description": "int8 as integer", "type": "string", "enum": [ "int64" ] }, + { + "description": "int8 as string", + "type": "string", + "enum": [ + "int64AsString" + ] + }, { "description": "numeric", "type": "string", @@ -1030,6 +1037,13 @@ expression: schema "bigDecimal" ] }, + { + "description": "numeric as string", + "type": "string", + "enum": [ + "bigDecimalAsString" + ] + }, { "description": "timestamp", "type": "string", diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap index 99d071d70..83bf168b0 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap @@ -2250,7 +2250,7 @@ expression: default_configuration "float8": "float64", "int2": "int16", "int4": "int32", - "int8": "int64", + "int8": "int64AsString", "numeric": "bigDecimal", "text": "string", "timestamp": "timestamp", diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__openapi_tests__openapi__up_to_date_generated_schema.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__openapi_tests__openapi__up_to_date_generated_schema.snap index 55ad90917..ec6846b14 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__openapi_tests__openapi__up_to_date_generated_schema.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__openapi_tests__openapi__up_to_date_generated_schema.snap @@ -1007,12 +1007,19 @@ expression: generated_schema_json ] }, { - "description": "int8", + "description": "int8 as integer", "type": "string", "enum": [ "int64" ] }, + { + "description": "int8 as string", + "type": "string", + "enum": [ + "int64AsString" + ] + }, { "description": "numeric", "type": "string", @@ -1020,6 +1027,13 @@ expression: generated_schema_json "bigDecimal" ] }, + { + "description": "numeric as string", + "type": "string", + "enum": [ + "bigDecimalAsString" + ] + }, { "description": "timestamp", "type": "string", diff --git a/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__types__select_value_types.snap b/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__types__select_value_types.snap index 7bf7b3c7d..57dea2d80 100644 --- a/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__types__select_value_types.snap +++ b/crates/tests/databases-tests/src/yugabyte/snapshots/databases_tests__yugabyte__query_tests__types__select_value_types.snap @@ -9,10 +9,10 @@ expression: result "bool": true, "int2": 245, "int4": 24555, - "int8": "245555555", + "int8": 245555555, "float4": 24.555, "float8": 2455.555, - "numeric": "24.555", + "numeric": 24.555, "char": "s", "varchar": "varchar string", "text": "textual text", diff --git a/static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/configuration.json b/static/ndc-metadata-snapshots/3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5/configuration.json similarity index 99% rename from static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/configuration.json rename to static/ndc-metadata-snapshots/3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5/configuration.json index 6d7a19493..b27de1a54 100644 --- a/static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/configuration.json +++ b/static/ndc-metadata-snapshots/3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5/configuration.json @@ -3712,8 +3712,8 @@ "float8": "float64", "int2": "int16", "int4": "int32", - "int8": "int64", - "numeric": "bigDecimal", + "int8": "int64AsString", + "numeric": "bigDecimalAsString", "text": "string", "time": "time", "timestamp": "timestamp", diff --git a/static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/native_queries/summarize_organizations.sql b/static/ndc-metadata-snapshots/3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5/native_queries/summarize_organizations.sql similarity index 100% rename from static/ndc-metadata-snapshots/6e098b79fe227cf6788ef3cf55d29f44067934fea51750c512c6df26e03b1497/native_queries/summarize_organizations.sql rename to static/ndc-metadata-snapshots/3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5/native_queries/summarize_organizations.sql diff --git a/static/postgres/v3-chinook-ndc-metadata/configuration.json b/static/postgres/v3-chinook-ndc-metadata/configuration.json index 6d7a19493..b27de1a54 100644 --- a/static/postgres/v3-chinook-ndc-metadata/configuration.json +++ b/static/postgres/v3-chinook-ndc-metadata/configuration.json @@ -3712,8 +3712,8 @@ "float8": "float64", "int2": "int16", "int4": "int32", - "int8": "int64", - "numeric": "bigDecimal", + "int8": "int64AsString", + "numeric": "bigDecimalAsString", "text": "string", "time": "time", "timestamp": "timestamp", diff --git a/static/schema.json b/static/schema.json index 04229371d..76faccd11 100644 --- a/static/schema.json +++ b/static/schema.json @@ -911,15 +911,25 @@ "enum": ["int32"] }, { - "description": "int8", + "description": "int8 as integer", "type": "string", "enum": ["int64"] }, + { + "description": "int8 as string", + "type": "string", + "enum": ["int64AsString"] + }, { "description": "numeric", "type": "string", "enum": ["bigDecimal"] }, + { + "description": "numeric as string", + "type": "string", + "enum": ["bigDecimalAsString"] + }, { "description": "timestamp", "type": "string", From 3e628cf736ba513e26b85d14200cbfefc0afe7ac Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 12:49:43 +0300 Subject: [PATCH 03/16] comment --- crates/configuration/src/version3/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index 1a14f01d8..b4eb57451 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -197,6 +197,8 @@ pub async fn introspect( }) } +/// Merge the type representations currenting defined in the user's configuration with +/// our base defaults. User configuration takes precedence. fn base_type_representations( database::TypeRepresentations(existing_type_representations): database::TypeRepresentations, ) -> database::TypeRepresentations { From d7097a14fd7606ab7d155cb6bb87dc719af151a5 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 12:51:07 +0300 Subject: [PATCH 04/16] comment --- crates/configuration/src/version3/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index b4eb57451..61f23678b 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -290,8 +290,9 @@ fn base_type_representations( ] .into(), ); - // If the user has already defined existing type representations, - // override the default ones with `insert`. + // If the user already has existing type representations defined, + // override the default ones using `insert`. + // We do this to not change the behaviour for the user on update. for (typ, type_rep) in existing_type_representations { type_representations.0.insert(typ, type_rep); } From ca7d2e349d1fd067a91dddb0720744fc8e5e3140 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 13:02:45 +0300 Subject: [PATCH 05/16] comments --- crates/query-engine/metadata/src/metadata/database.rs | 1 + crates/query-engine/translation/src/translation/helpers.rs | 1 + crates/query-engine/translation/src/translation/query/fields.rs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/query-engine/metadata/src/metadata/database.rs b/crates/query-engine/metadata/src/metadata/database.rs index 2634a055e..3e83321bf 100644 --- a/crates/query-engine/metadata/src/metadata/database.rs +++ b/crates/query-engine/metadata/src/metadata/database.rs @@ -24,6 +24,7 @@ pub enum Type { } impl Type { + /// If a type is a scalar type, fetch it. If not, return None. pub fn scalar_type(&self) -> Option<&ScalarType> { match self { Type::ScalarType(scalar_type) => Some(scalar_type), diff --git a/crates/query-engine/translation/src/translation/helpers.rs b/crates/query-engine/translation/src/translation/helpers.rs index 314cb4323..0fde91e20 100644 --- a/crates/query-engine/translation/src/translation/helpers.rs +++ b/crates/query-engine/translation/src/translation/helpers.rs @@ -276,6 +276,7 @@ impl CompositeTypeInfo<'_> { } } + /// Fetch all the field names (external, internal) of a composite type. pub fn fields(&self) -> Vec<(&String, &String)> { match self { CompositeTypeInfo::CompositeTypeInfo { name: _, info } => info diff --git a/crates/query-engine/translation/src/translation/query/fields.rs b/crates/query-engine/translation/src/translation/query/fields.rs index df364d312..7fd3a8424 100644 --- a/crates/query-engine/translation/src/translation/query/fields.rs +++ b/crates/query-engine/translation/src/translation/query/fields.rs @@ -397,7 +397,7 @@ fn unpack_and_wrap_fields( sql::ast::Expression::ColumnReference(nested_column_reference), )) } - // TODO: Arrays for composite types are not handled yet. + // TODO: Arrays of composite types are not handled yet. Type::ArrayType(type_boxed) => match *type_boxed { Type::ArrayType(_) => Err(Error::NestedArraysNotSupported { field_name: column.to_string(), From bedf73d28a9428f7105f8fd147922fe0b402eb85 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 13:04:33 +0300 Subject: [PATCH 06/16] changelog --- changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.md b/changelog.md index c9736ebdb..1429e2484 100644 --- a/changelog.md +++ b/changelog.md @@ -16,6 +16,8 @@ - Support ndc-spec v0.1.2 and change the type representation of types accordingly. ([#408](https://github.com/hasura/ndc-postgres/pull/408)) +- `int8` and `numeric` columns will now emit a string json representation by default. + ([#416](https://github.com/hasura/ndc-postgres/pull/416)) ### Fixed From 8f90b96f26bd4de260b84b699aae33b426fbc365 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 13:14:44 +0300 Subject: [PATCH 07/16] fix arrays --- .../src/translation/query/fields.rs | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/crates/query-engine/translation/src/translation/query/fields.rs b/crates/query-engine/translation/src/translation/query/fields.rs index 7fd3a8424..cb8d6bf4c 100644 --- a/crates/query-engine/translation/src/translation/query/fields.rs +++ b/crates/query-engine/translation/src/translation/query/fields.rs @@ -426,20 +426,44 @@ fn unpack_and_wrap_fields( /// For array columns of those type representation, we wrap the result in a cast. fn wrap_array_in_type_representation( expression: sql::ast::Expression, - inner_column_type_representation: Option, + column_type_representation: Option, ) -> sql::ast::Expression { - match inner_column_type_representation { + match column_type_representation { None => expression, Some(type_rep) => match type_rep { - TypeRepresentation::Int64 => sql::ast::Expression::Cast { + // In these situations, we expect to cast the expression according + // to the type representation. + TypeRepresentation::Int64AsString => sql::ast::Expression::Cast { expression: Box::new(expression), r#type: sql::ast::ScalarType("text[]".to_string()), }, - TypeRepresentation::BigDecimal => sql::ast::Expression::Cast { + TypeRepresentation::BigDecimalAsString => sql::ast::Expression::Cast { expression: Box::new(expression), r#type: sql::ast::ScalarType("text[]".to_string()), }, - _ => expression, + + // In these situations the type representation should be the same as + // the expression, so we don't cast it. + TypeRepresentation::Boolean => expression, + TypeRepresentation::String => expression, + TypeRepresentation::Float32 => expression, + TypeRepresentation::Float64 => expression, + TypeRepresentation::Int16 => expression, + TypeRepresentation::Int32 => expression, + TypeRepresentation::Int64 => expression, + TypeRepresentation::BigDecimal => expression, + TypeRepresentation::Timestamp => expression, + TypeRepresentation::Timestamptz => expression, + TypeRepresentation::Time => expression, + TypeRepresentation::Timetz => expression, + TypeRepresentation::Date => expression, + TypeRepresentation::UUID => expression, + TypeRepresentation::Geography => expression, + TypeRepresentation::Geometry => expression, + TypeRepresentation::Number => expression, + TypeRepresentation::Integer => expression, + TypeRepresentation::Json => expression, + TypeRepresentation::Enum(_) => expression, }, } } From 0314d626075d3bf751db30d3ee1cf84efcb7f50c Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 13:26:03 +0300 Subject: [PATCH 08/16] merge array and column casting --- .../src/translation/query/fields.rs | 128 ++++++++---------- 1 file changed, 58 insertions(+), 70 deletions(-) diff --git a/crates/query-engine/translation/src/translation/query/fields.rs b/crates/query-engine/translation/src/translation/query/fields.rs index cb8d6bf4c..0fde6f421 100644 --- a/crates/query-engine/translation/src/translation/query/fields.rs +++ b/crates/query-engine/translation/src/translation/query/fields.rs @@ -430,41 +430,19 @@ fn wrap_array_in_type_representation( ) -> sql::ast::Expression { match column_type_representation { None => expression, - Some(type_rep) => match type_rep { - // In these situations, we expect to cast the expression according - // to the type representation. - TypeRepresentation::Int64AsString => sql::ast::Expression::Cast { - expression: Box::new(expression), - r#type: sql::ast::ScalarType("text[]".to_string()), - }, - TypeRepresentation::BigDecimalAsString => sql::ast::Expression::Cast { - expression: Box::new(expression), - r#type: sql::ast::ScalarType("text[]".to_string()), - }, - - // In these situations the type representation should be the same as - // the expression, so we don't cast it. - TypeRepresentation::Boolean => expression, - TypeRepresentation::String => expression, - TypeRepresentation::Float32 => expression, - TypeRepresentation::Float64 => expression, - TypeRepresentation::Int16 => expression, - TypeRepresentation::Int32 => expression, - TypeRepresentation::Int64 => expression, - TypeRepresentation::BigDecimal => expression, - TypeRepresentation::Timestamp => expression, - TypeRepresentation::Timestamptz => expression, - TypeRepresentation::Time => expression, - TypeRepresentation::Timetz => expression, - TypeRepresentation::Date => expression, - TypeRepresentation::UUID => expression, - TypeRepresentation::Geography => expression, - TypeRepresentation::Geometry => expression, - TypeRepresentation::Number => expression, - TypeRepresentation::Integer => expression, - TypeRepresentation::Json => expression, - TypeRepresentation::Enum(_) => expression, - }, + Some(type_rep) => { + if let Some(sql::ast::ScalarType(cast_type)) = + get_type_representation_cast_type(&type_rep) + { + sql::ast::Expression::Cast { + expression: Box::new(expression), + // make it an array of cast type + r#type: sql::ast::ScalarType(format!("{cast_type}[]")), + } + } else { + expression + } + } } } @@ -477,40 +455,50 @@ fn wrap_in_type_representation( ) -> sql::ast::Expression { match column_type_representation { None => expression, - Some(type_rep) => match type_rep { - // In these situations, we expect to cast the expression according - // to the type representation. - TypeRepresentation::Int64AsString => sql::ast::Expression::Cast { - expression: Box::new(expression), - r#type: sql::ast::ScalarType("text".to_string()), - }, - TypeRepresentation::BigDecimalAsString => sql::ast::Expression::Cast { - expression: Box::new(expression), - r#type: sql::ast::ScalarType("text".to_string()), - }, - - // In these situations the type representation should be the same as - // the expression, so we don't cast it. - TypeRepresentation::Boolean => expression, - TypeRepresentation::String => expression, - TypeRepresentation::Float32 => expression, - TypeRepresentation::Float64 => expression, - TypeRepresentation::Int16 => expression, - TypeRepresentation::Int32 => expression, - TypeRepresentation::Int64 => expression, - TypeRepresentation::BigDecimal => expression, - TypeRepresentation::Timestamp => expression, - TypeRepresentation::Timestamptz => expression, - TypeRepresentation::Time => expression, - TypeRepresentation::Timetz => expression, - TypeRepresentation::Date => expression, - TypeRepresentation::UUID => expression, - TypeRepresentation::Geography => expression, - TypeRepresentation::Geometry => expression, - TypeRepresentation::Number => expression, - TypeRepresentation::Integer => expression, - TypeRepresentation::Json => expression, - TypeRepresentation::Enum(_) => expression, - }, + Some(type_rep) => { + if let Some(cast_type) = get_type_representation_cast_type(&type_rep) { + sql::ast::Expression::Cast { + expression: Box::new(expression), + r#type: cast_type, + } + } else { + expression + } + } + } +} + +/// If a type representation requires a cast, return the scalar type name. +fn get_type_representation_cast_type( + type_representation: &TypeRepresentation, +) -> Option { + match type_representation { + // In these situations, we expect to cast the expression according + // to the type representation. + TypeRepresentation::Int64AsString => Some(sql::ast::ScalarType("text".to_string())), + TypeRepresentation::BigDecimalAsString => Some(sql::ast::ScalarType("text".to_string())), + + // In these situations the type representation should be the same as + // the expression, so we don't cast it. + TypeRepresentation::Boolean => None, + TypeRepresentation::String => None, + TypeRepresentation::Float32 => None, + TypeRepresentation::Float64 => None, + TypeRepresentation::Int16 => None, + TypeRepresentation::Int32 => None, + TypeRepresentation::Int64 => None, + TypeRepresentation::BigDecimal => None, + TypeRepresentation::Timestamp => None, + TypeRepresentation::Timestamptz => None, + TypeRepresentation::Time => None, + TypeRepresentation::Timetz => None, + TypeRepresentation::Date => None, + TypeRepresentation::UUID => None, + TypeRepresentation::Geography => None, + TypeRepresentation::Geometry => None, + TypeRepresentation::Number => None, + TypeRepresentation::Integer => None, + TypeRepresentation::Json => None, + TypeRepresentation::Enum(_) => None, } } From 55dc32765017575ec3dedf8349613aa3ac91ac75 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 15:06:14 +0300 Subject: [PATCH 09/16] fix merge --- .../src/version3/metadata/database.rs | 7 ++++++- crates/configuration/src/version3/mod.rs | 14 +++++++++++--- .../query-engine/metadata/src/metadata/database.rs | 4 ---- ...gure_v3_initial_configuration_is_unchanged.snap | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/configuration/src/version3/metadata/database.rs b/crates/configuration/src/version3/metadata/database.rs index 3d484a97d..a16d894e0 100644 --- a/crates/configuration/src/version3/metadata/database.rs +++ b/crates/configuration/src/version3/metadata/database.rs @@ -232,10 +232,15 @@ pub enum TypeRepresentation { Int16, /// int4 Int32, - /// int8 + /// int8 as integer Int64, + /// int8 as string + Int64AsString, /// numeric BigDecimal, + /// numeric as string + BigDecimalAsString, + /// timestamp Timestamp, /// timestamp with timezone diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index ae18bce1f..711eb11e0 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -258,7 +258,7 @@ fn base_type_representations( ), ( database::ScalarType("numeric".to_string()), - database::TypeRepresentation::BigDecimal, + database::TypeRepresentation::BigDecimalAsString, ), ( database::ScalarType("text".to_string()), @@ -779,9 +779,15 @@ fn convert_type_representation( metadata::TypeRepresentation::Int64 => { query_engine_metadata::metadata::TypeRepresentation::Int64 } + metadata::TypeRepresentation::Int64AsString => { + query_engine_metadata::metadata::TypeRepresentation::Int64AsString + } metadata::TypeRepresentation::BigDecimal => { query_engine_metadata::metadata::TypeRepresentation::BigDecimal } + metadata::TypeRepresentation::BigDecimalAsString => { + query_engine_metadata::metadata::TypeRepresentation::BigDecimalAsString + } metadata::TypeRepresentation::Timestamp => { query_engine_metadata::metadata::TypeRepresentation::Timestamp } @@ -806,11 +812,13 @@ fn convert_type_representation( metadata::TypeRepresentation::Geometry => { query_engine_metadata::metadata::TypeRepresentation::Geometry } + // This is deprecated in ndc-spec metadata::TypeRepresentation::Number => { - query_engine_metadata::metadata::TypeRepresentation::Number + query_engine_metadata::metadata::TypeRepresentation::Json } + // This is deprecated in ndc-spec metadata::TypeRepresentation::Integer => { - query_engine_metadata::metadata::TypeRepresentation::Integer + query_engine_metadata::metadata::TypeRepresentation::Json } metadata::TypeRepresentation::Json => { query_engine_metadata::metadata::TypeRepresentation::Json diff --git a/crates/query-engine/metadata/src/metadata/database.rs b/crates/query-engine/metadata/src/metadata/database.rs index bac17eb0b..7453f3c8c 100644 --- a/crates/query-engine/metadata/src/metadata/database.rs +++ b/crates/query-engine/metadata/src/metadata/database.rs @@ -234,10 +234,6 @@ pub enum TypeRepresentation { Geography, /// geometry Geometry, - /// Any JSON number - Number, - /// Any JSON number, with no decimal part - Integer, /// An arbitrary json. Json, /// One of the specified string values diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap index 83bf168b0..9f31c4b71 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap @@ -2251,7 +2251,7 @@ expression: default_configuration "int2": "int16", "int4": "int32", "int8": "int64AsString", - "numeric": "bigDecimal", + "numeric": "bigDecimalAsString", "text": "string", "timestamp": "timestamp", "varchar": "string" From 867a734a16a7affbb0cfd4519b01facc3a911b50 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 15:10:06 +0300 Subject: [PATCH 10/16] oops --- crates/connectors/ndc-postgres/src/schema.rs | 3 --- .../query-engine/translation/src/translation/query/fields.rs | 2 -- 2 files changed, 5 deletions(-) diff --git a/crates/connectors/ndc-postgres/src/schema.rs b/crates/connectors/ndc-postgres/src/schema.rs index b1b1bb2fd..52a7762e0 100644 --- a/crates/connectors/ndc-postgres/src/schema.rs +++ b/crates/connectors/ndc-postgres/src/schema.rs @@ -642,8 +642,5 @@ fn map_type_representation( metadata::TypeRepresentation::Enum(variants) => models::TypeRepresentation::Enum { one_of: variants.clone(), }, - // Stop gap until we remove these. Done so we won't break compatability. - metadata::TypeRepresentation::Integer => models::TypeRepresentation::JSON, - metadata::TypeRepresentation::Number => models::TypeRepresentation::JSON, } } diff --git a/crates/query-engine/translation/src/translation/query/fields.rs b/crates/query-engine/translation/src/translation/query/fields.rs index 0fde6f421..c32a86f27 100644 --- a/crates/query-engine/translation/src/translation/query/fields.rs +++ b/crates/query-engine/translation/src/translation/query/fields.rs @@ -496,8 +496,6 @@ fn get_type_representation_cast_type( TypeRepresentation::UUID => None, TypeRepresentation::Geography => None, TypeRepresentation::Geometry => None, - TypeRepresentation::Number => None, - TypeRepresentation::Integer => None, TypeRepresentation::Json => None, TypeRepresentation::Enum(_) => None, } From 0df5ca1ff9bfc0bf1d4a53cf057207249bf1a50f Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 15:25:39 +0300 Subject: [PATCH 11/16] archive old data no-op --- scripts/archive-old-ndc-metadata.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/archive-old-ndc-metadata.sh b/scripts/archive-old-ndc-metadata.sh index 9bc775a92..bcafee153 100755 --- a/scripts/archive-old-ndc-metadata.sh +++ b/scripts/archive-old-ndc-metadata.sh @@ -17,5 +17,7 @@ mkdir -p "$SNAPSHOT_DIR" # create filename from hash of contents NEW_DIRECTORY="$(sha256sum "${CHINOOK_NDC_METADATA}/configuration.json" | cut -f1 -d' ')" +mkdir -p "${SNAPSHOT_DIR}/${NEW_DIRECTORY}" + # copy current NDC metadata to new path -cp -r "${CHINOOK_NDC_METADATA}" "${SNAPSHOT_DIR}/${NEW_DIRECTORY}" +cp -r "${CHINOOK_NDC_METADATA}"/* "${SNAPSHOT_DIR}/${NEW_DIRECTORY}" From 3d56da80540d4cf92e8f1005efa42f9e8b5cc346 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Thu, 11 Apr 2024 15:46:20 +0300 Subject: [PATCH 12/16] update enums --- crates/configuration/src/version3/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index 711eb11e0..fc6deeb1f 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -295,7 +295,13 @@ fn base_type_representations( // override the default ones using `insert`. // We do this to not change the behaviour for the user on update. for (typ, type_rep) in existing_type_representations { - type_representations.0.insert(typ, type_rep); + match type_rep { + // we don't want to do this for enums as they should be overwritten according to the database. + database::TypeRepresentation::Enum(_) => {} + _ => { + type_representations.0.insert(typ, type_rep); + } + } } type_representations } From 9ef3d24484e081276ee5b682451f2a75c967f04d Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Mon, 15 Apr 2024 16:15:21 +0300 Subject: [PATCH 13/16] simplify scalar type --- crates/query-engine/metadata/src/metadata/database.rs | 11 ----------- .../translation/src/translation/query/fields.rs | 7 ++----- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/crates/query-engine/metadata/src/metadata/database.rs b/crates/query-engine/metadata/src/metadata/database.rs index 7453f3c8c..6fd9960cf 100644 --- a/crates/query-engine/metadata/src/metadata/database.rs +++ b/crates/query-engine/metadata/src/metadata/database.rs @@ -21,17 +21,6 @@ pub enum Type { ArrayType(Box), } -impl Type { - /// If a type is a scalar type, fetch it. If not, return None. - pub fn scalar_type(&self) -> Option<&ScalarType> { - match self { - Type::ScalarType(scalar_type) => Some(scalar_type), - Type::CompositeType(_) => None, - Type::ArrayType(_) => None, - } - } -} - /// Information about a composite type. These are very similar to tables, but with the crucial /// difference that composite types do not support constraints (such as NOT NULL). #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/crates/query-engine/translation/src/translation/query/fields.rs b/crates/query-engine/translation/src/translation/query/fields.rs index c32a86f27..665ea136b 100644 --- a/crates/query-engine/translation/src/translation/query/fields.rs +++ b/crates/query-engine/translation/src/translation/query/fields.rs @@ -344,11 +344,8 @@ fn unpack_and_wrap_fields( // type representation. match column_info.r#type { // Scalar types can just be wrapped in a cast. - Type::ScalarType(_) => { - let column_type_representation = column_info - .r#type - .scalar_type() - .and_then(|scalar_type| env.lookup_type_representation(scalar_type)); + Type::ScalarType(scalar_type) => { + let column_type_representation = env.lookup_type_representation(&scalar_type); let (alias, expression) = sql::helpers::make_column( current_table.reference.clone(), column_info.name.clone(), From 7fa9b4f7245cddcc225380eebd68511e066c04e4 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Mon, 15 Apr 2024 17:11:05 +0300 Subject: [PATCH 14/16] array of composite type support --- crates/query-engine/sql/src/sql/ast.rs | 1 + crates/query-engine/sql/src/sql/convert.rs | 1 + .../src/translation/query/fields.rs | 66 +++++--- ...schema_tests__schema_test__get_schema.snap | 142 ++++++++++++++++++ .../src/postgres/query_tests.rs | 6 + ...v3_initial_configuration_is_unchanged.snap | 75 +++++++++ ...__basic__select_array_composite_field.snap | 29 ++++ ...schema_tests__schema_test__get_schema.snap | 142 ++++++++++++++++++ .../select_array_composite_field.json | 19 +++ .../configuration.json | 75 +++++++++ static/composite-types-complex.sql | 22 +++ .../configuration.json | 75 +++++++++ .../summarize_organizations.sql | 0 .../configuration.json | 75 +++++++++ .../configuration.json | 75 +++++++++ 15 files changed, 782 insertions(+), 21 deletions(-) create mode 100644 crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_array_composite_field.snap create mode 100644 crates/tests/tests-common/goldenfiles/select_array_composite_field.json rename static/ndc-metadata-snapshots/{3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5 => 2e7bac3a92939fc04db0a0efd85915126a096a217094c411b4f427b8716179fc}/configuration.json (98%) rename static/ndc-metadata-snapshots/{3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5 => 2e7bac3a92939fc04db0a0efd85915126a096a217094c411b4f427b8716179fc}/native_queries/summarize_organizations.sql (100%) diff --git a/crates/query-engine/sql/src/sql/ast.rs b/crates/query-engine/sql/src/sql/ast.rs index 8f93511d7..03848a003 100644 --- a/crates/query-engine/sql/src/sql/ast.rs +++ b/crates/query-engine/sql/src/sql/ast.rs @@ -271,6 +271,7 @@ pub enum Function { JsonAgg, JsonBuildArray, JsonbPopulateRecord, + Unnest, Unknown(String), } diff --git a/crates/query-engine/sql/src/sql/convert.rs b/crates/query-engine/sql/src/sql/convert.rs index 3e91f11f2..9fd6c503c 100644 --- a/crates/query-engine/sql/src/sql/convert.rs +++ b/crates/query-engine/sql/src/sql/convert.rs @@ -482,6 +482,7 @@ impl Function { Function::JsonAgg => sql.append_syntax("json_agg"), Function::JsonBuildArray => sql.append_syntax("json_build_array"), Function::JsonbPopulateRecord => sql.append_syntax("jsonb_populate_record"), + Function::Unnest => sql.append_syntax("unnest"), Function::Unknown(name) => sql.append_syntax(name), } } diff --git a/crates/query-engine/translation/src/translation/query/fields.rs b/crates/query-engine/translation/src/translation/query/fields.rs index 665ea136b..56974476d 100644 --- a/crates/query-engine/translation/src/translation/query/fields.rs +++ b/crates/query-engine/translation/src/translation/query/fields.rs @@ -235,7 +235,7 @@ fn translate_nested_field( // (unnest("%0_"."")).* // ``` let field_binding_expression = sql::ast::Expression::FunctionCall { - function: sql::ast::Function::Unknown("unnest".to_string()), + function: sql::ast::Function::Unnest, args: vec![sql::ast::Expression::ColumnReference( sql::ast::ColumnReference::AliasedColumn { table: current_table.reference.clone(), @@ -362,20 +362,7 @@ fn unpack_and_wrap_fields( // selection of all fields. Type::CompositeType(ref composite_type) => { // build a nested field selection of all fields. - let nested_field = models::NestedField::Object({ - let composite_type = env.lookup_composite_type(composite_type)?; - let mut fields = indexmap!(); - for (result_name, field_name) in composite_type.fields() { - fields.insert( - result_name.to_string(), - models::Field::Column { - column: field_name.clone(), - fields: None, - }, - ); - } - models::NestedObject { fields } - }); + let nested_field = unpack_composite_type(env, composite_type)?; // translate this as if it is a nested field selection. let (nested_field_join, nested_column_reference) = translate_nested_field( @@ -395,15 +382,34 @@ fn unpack_and_wrap_fields( )) } // TODO: Arrays of composite types are not handled yet. - Type::ArrayType(type_boxed) => match *type_boxed { + Type::ArrayType(ref type_boxed) => match **type_boxed { Type::ArrayType(_) => Err(Error::NestedArraysNotSupported { field_name: column.to_string(), }), - Type::CompositeType(_) => Err(Error::NotImplementedYet( - "an array of a composite type".to_string(), - )), - Type::ScalarType(scalar_type) => { - let inner_column_type_representation = env.lookup_type_representation(&scalar_type); + Type::CompositeType(ref composite_type) => { + // build a nested field selection of all fields. + let nested_field = models::NestedField::Array(models::NestedArray { + fields: Box::new(unpack_composite_type(env, composite_type)?), + }); + + let (nested_field_join, nested_column_reference) = translate_nested_field( + env, + state, + current_table, + &column_info, + nested_field, + join_relationship_fields, + )?; + + nested_field_joins.push(nested_field_join); + + Ok(( + alias, + sql::ast::Expression::ColumnReference(nested_column_reference), + )) + } + Type::ScalarType(ref scalar_type) => { + let inner_column_type_representation = env.lookup_type_representation(scalar_type); let (alias, expression) = sql::helpers::make_column( current_table.reference.clone(), column_info.name.clone(), @@ -497,3 +503,21 @@ fn get_type_representation_cast_type( TypeRepresentation::Enum(_) => None, } } + +/// Create an explicit NestedField that selects all fields (1 level) of a composite type. +fn unpack_composite_type(env: &Env, composite_type: &str) -> Result { + Ok(models::NestedField::Object({ + let composite_type = env.lookup_composite_type(composite_type)?; + let mut fields = indexmap!(); + for (result_name, field_name) in composite_type.fields() { + fields.insert( + result_name.to_string(), + models::Field::Column { + column: field_name.clone(), + fields: None, + }, + ); + } + models::NestedObject { fields } + })) +} diff --git a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap index e71860256..5be86ecd4 100644 --- a/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap +++ b/crates/tests/databases-tests/src/citus/snapshots/databases_tests__citus__schema_tests__schema_test__get_schema.snap @@ -2828,6 +2828,41 @@ expression: result } } }, + "chara": { + "fields": { + "name": { + "type": { + "type": "named", + "name": "text" + } + }, + "popularity": { + "type": { + "type": "named", + "name": "int8" + } + } + } + }, + "characters": { + "fields": { + "members": { + "type": { + "type": "array", + "element_type": { + "type": "named", + "name": "chara" + } + } + }, + "name": { + "type": { + "type": "named", + "name": "text" + } + } + } + }, "committee": { "fields": { "members": { @@ -2954,6 +2989,37 @@ expression: result } } }, + "group_leader": { + "fields": { + "characters": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "characters" + } + } + }, + "id": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "int4" + } + } + }, + "name": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "chara" + } + } + } + } + }, "insert_album": { "fields": { "AlbumId": { @@ -4273,6 +4339,59 @@ expression: result } } }, + "v1_insert_group_leader_object": { + "fields": { + "characters": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "characters" + } + } + }, + "id": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "int4" + } + } + }, + "name": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "chara" + } + } + } + } + }, + "v1_insert_group_leader_response": { + "description": "Responses from the 'v1_insert_group_leader' procedure", + "fields": { + "affected_rows": { + "description": "The number of rows affected by the mutation", + "type": { + "type": "named", + "name": "int4" + } + }, + "returning": { + "description": "Data from rows affected by the mutation", + "type": { + "type": "array", + "element_type": { + "type": "named", + "name": "group_leader" + } + } + } + } + }, "v1_insert_phone_numbers_object": { "fields": { "the_number": { @@ -4696,6 +4815,13 @@ expression: result "uniqueness_constraints": {}, "foreign_keys": {} }, + { + "name": "group_leader", + "arguments": {}, + "type": "group_leader", + "uniqueness_constraints": {}, + "foreign_keys": {} + }, { "name": "phone_numbers", "arguments": {}, @@ -5527,6 +5653,22 @@ expression: result "name": "v1_insert_even_numbers_response" } }, + { + "name": "v1_insert_group_leader", + "description": "Insert into the group_leader table", + "arguments": { + "_object": { + "type": { + "type": "named", + "name": "v1_insert_group_leader_object" + } + } + }, + "result_type": { + "type": "named", + "name": "v1_insert_group_leader_response" + } + }, { "name": "v1_insert_phone_numbers", "description": "Insert into the phone_numbers table", diff --git a/crates/tests/databases-tests/src/postgres/query_tests.rs b/crates/tests/databases-tests/src/postgres/query_tests.rs index 2b558c553..73f3d272b 100644 --- a/crates/tests/databases-tests/src/postgres/query_tests.rs +++ b/crates/tests/databases-tests/src/postgres/query_tests.rs @@ -108,6 +108,12 @@ mod basic { let result = run_query(create_router().await, "select_nested_column_complex").await; insta::assert_json_snapshot!(result); } + + #[tokio::test] + async fn select_array_composite_field() { + let result = run_query(create_router().await, "select_array_composite_field").await; + insta::assert_json_snapshot!(result); + } } #[cfg(test)] diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap index 9f31c4b71..4ec5a6388 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap @@ -882,6 +882,39 @@ expression: default_configuration "foreignRelations": {}, "description": null }, + "group_leader": { + "schemaName": "public", + "tableName": "group_leader", + "columns": { + "characters": { + "name": "characters", + "type": { + "compositeType": "characters" + }, + "nullable": "nullable", + "description": null + }, + "id": { + "name": "id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "name": { + "name": "name", + "type": { + "compositeType": "chara" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, "phone_numbers": { "schemaName": "public", "tableName": "phone_numbers", @@ -1104,6 +1137,48 @@ expression: default_configuration } }, "compositeTypes": { + "chara": { + "name": "chara", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + }, + "popularity": { + "name": "popularity", + "type": { + "scalarType": "int8" + }, + "description": null + } + }, + "description": null + }, + "characters": { + "name": "characters", + "fields": { + "members": { + "name": "members", + "type": { + "arrayType": { + "compositeType": "chara" + } + }, + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } + }, + "description": null + }, "discoverable_types": { "name": "discoverable_types", "fields": { diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_array_composite_field.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_array_composite_field.snap new file mode 100644 index 000000000..99122bfaf --- /dev/null +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__query_tests__basic__select_array_composite_field.snap @@ -0,0 +1,29 @@ +--- +source: crates/tests/databases-tests/src/postgres/query_tests.rs +expression: result +--- +[ + { + "rows": [ + { + "name": { + "name": "Frodo", + "popularity": "3" + }, + "characters": { + "members": [ + { + "name": "Legolas", + "popularity": "200" + }, + { + "name": "Gimli", + "popularity": "300" + } + ], + "name": "Fellowship" + } + } + ] + } +] diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__schema_tests__schema_test__get_schema.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__schema_tests__schema_test__get_schema.snap index 1a677cf96..ecc766c9f 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__schema_tests__schema_test__get_schema.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__schema_tests__schema_test__get_schema.snap @@ -2968,6 +2968,41 @@ expression: result } } }, + "chara": { + "fields": { + "name": { + "type": { + "type": "named", + "name": "text" + } + }, + "popularity": { + "type": { + "type": "named", + "name": "int8" + } + } + } + }, + "characters": { + "fields": { + "members": { + "type": { + "type": "array", + "element_type": { + "type": "named", + "name": "chara" + } + } + }, + "name": { + "type": { + "type": "named", + "name": "text" + } + } + } + }, "committee": { "fields": { "members": { @@ -4378,6 +4413,59 @@ expression: result } } }, + "experimental_insert_group_leader_object": { + "fields": { + "characters": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "characters" + } + } + }, + "id": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "int4" + } + } + }, + "name": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "chara" + } + } + } + } + }, + "experimental_insert_group_leader_response": { + "description": "Responses from the 'experimental_insert_group_leader' procedure", + "fields": { + "affected_rows": { + "description": "The number of rows affected by the mutation", + "type": { + "type": "named", + "name": "int4" + } + }, + "returning": { + "description": "Data from rows affected by the mutation", + "type": { + "type": "array", + "element_type": { + "type": "named", + "name": "group_leader" + } + } + } + } + }, "experimental_insert_phone_numbers_object": { "fields": { "the_number": { @@ -4611,6 +4699,37 @@ expression: result } } }, + "group_leader": { + "fields": { + "characters": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "characters" + } + } + }, + "id": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "int4" + } + } + }, + "name": { + "type": { + "type": "nullable", + "underlying_type": { + "type": "named", + "name": "chara" + } + } + } + } + }, "insert_album": { "fields": { "AlbumId": { @@ -5372,6 +5491,13 @@ expression: result "uniqueness_constraints": {}, "foreign_keys": {} }, + { + "name": "group_leader", + "arguments": {}, + "type": "group_leader", + "uniqueness_constraints": {}, + "foreign_keys": {} + }, { "name": "phone_numbers", "arguments": {}, @@ -6440,6 +6566,22 @@ expression: result "name": "experimental_insert_even_numbers_response" } }, + { + "name": "experimental_insert_group_leader", + "description": "Insert into the group_leader table", + "arguments": { + "_object": { + "type": { + "type": "named", + "name": "experimental_insert_group_leader_object" + } + } + }, + "result_type": { + "type": "named", + "name": "experimental_insert_group_leader_response" + } + }, { "name": "experimental_insert_phone_numbers", "description": "Insert into the phone_numbers table", diff --git a/crates/tests/tests-common/goldenfiles/select_array_composite_field.json b/crates/tests/tests-common/goldenfiles/select_array_composite_field.json new file mode 100644 index 000000000..337cf6b58 --- /dev/null +++ b/crates/tests/tests-common/goldenfiles/select_array_composite_field.json @@ -0,0 +1,19 @@ +{ + "collection": "group_leader", + "query": { + "fields": { + "name": { + "type": "column", + "column": "name", + "arguments": {} + }, + "characters": { + "type": "column", + "column": "characters", + "arguments": {} + } + } + }, + "arguments": {}, + "collection_relationships": {} +} diff --git a/static/citus/v3-chinook-ndc-metadata/configuration.json b/static/citus/v3-chinook-ndc-metadata/configuration.json index f78453929..14db16998 100644 --- a/static/citus/v3-chinook-ndc-metadata/configuration.json +++ b/static/citus/v3-chinook-ndc-metadata/configuration.json @@ -791,6 +791,39 @@ "foreignRelations": {}, "description": null }, + "group_leader": { + "schemaName": "public", + "tableName": "group_leader", + "columns": { + "characters": { + "name": "characters", + "type": { + "compositeType": "characters" + }, + "nullable": "nullable", + "description": null + }, + "id": { + "name": "id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "name": { + "name": "name", + "type": { + "compositeType": "chara" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, "phone_numbers": { "schemaName": "public", "tableName": "phone_numbers", @@ -810,6 +843,48 @@ } }, "compositeTypes": { + "chara": { + "name": "chara", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + }, + "popularity": { + "name": "popularity", + "type": { + "scalarType": "int8" + }, + "description": null + } + }, + "description": null + }, + "characters": { + "name": "characters", + "fields": { + "members": { + "name": "members", + "type": { + "arrayType": { + "compositeType": "chara" + } + }, + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } + }, + "description": null + }, "committee": { "name": "committee", "fields": { diff --git a/static/composite-types-complex.sql b/static/composite-types-complex.sql index f94fec5c4..ad7f6424d 100644 --- a/static/composite-types-complex.sql +++ b/static/composite-types-complex.sql @@ -20,3 +20,25 @@ CREATE TYPE organization AS committees committee[] ); +CREATE TYPE chara AS + ( + name text, + popularity int8 + ); + +CREATE TYPE characters AS + ( + name text, + members chara[] + ); + + +create table group_leader(id int, name chara, characters characters); + +insert into group_leader values + ( 1, + ROW('Frodo', 3)::chara, + ROW('Fellowship', + ARRAY[ROW('Legolas', 200)::chara, ROW('Gimli', 300)::chara]::chara[] + )::characters + ); diff --git a/static/ndc-metadata-snapshots/3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5/configuration.json b/static/ndc-metadata-snapshots/2e7bac3a92939fc04db0a0efd85915126a096a217094c411b4f427b8716179fc/configuration.json similarity index 98% rename from static/ndc-metadata-snapshots/3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5/configuration.json rename to static/ndc-metadata-snapshots/2e7bac3a92939fc04db0a0efd85915126a096a217094c411b4f427b8716179fc/configuration.json index b27de1a54..2de2a6f0a 100644 --- a/static/ndc-metadata-snapshots/3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5/configuration.json +++ b/static/ndc-metadata-snapshots/2e7bac3a92939fc04db0a0efd85915126a096a217094c411b4f427b8716179fc/configuration.json @@ -854,6 +854,39 @@ "foreignRelations": {}, "description": null }, + "group_leader": { + "schemaName": "public", + "tableName": "group_leader", + "columns": { + "characters": { + "name": "characters", + "type": { + "compositeType": "characters" + }, + "nullable": "nullable", + "description": null + }, + "id": { + "name": "id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "name": { + "name": "name", + "type": { + "compositeType": "chara" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, "phone_numbers": { "schemaName": "public", "tableName": "phone_numbers", @@ -1067,6 +1100,48 @@ } }, "compositeTypes": { + "chara": { + "name": "chara", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + }, + "popularity": { + "name": "popularity", + "type": { + "scalarType": "int8" + }, + "description": null + } + }, + "description": null + }, + "characters": { + "name": "characters", + "fields": { + "members": { + "name": "members", + "type": { + "arrayType": { + "compositeType": "chara" + } + }, + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } + }, + "description": null + }, "committee": { "name": "committee", "fields": { diff --git a/static/ndc-metadata-snapshots/3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5/native_queries/summarize_organizations.sql b/static/ndc-metadata-snapshots/2e7bac3a92939fc04db0a0efd85915126a096a217094c411b4f427b8716179fc/native_queries/summarize_organizations.sql similarity index 100% rename from static/ndc-metadata-snapshots/3aa159cb12381e3f958aab936622352d855f82776ae2a84e6932b9322e5bc8b5/native_queries/summarize_organizations.sql rename to static/ndc-metadata-snapshots/2e7bac3a92939fc04db0a0efd85915126a096a217094c411b4f427b8716179fc/native_queries/summarize_organizations.sql diff --git a/static/postgres/v3-chinook-ndc-metadata/configuration.json b/static/postgres/v3-chinook-ndc-metadata/configuration.json index b27de1a54..2de2a6f0a 100644 --- a/static/postgres/v3-chinook-ndc-metadata/configuration.json +++ b/static/postgres/v3-chinook-ndc-metadata/configuration.json @@ -854,6 +854,39 @@ "foreignRelations": {}, "description": null }, + "group_leader": { + "schemaName": "public", + "tableName": "group_leader", + "columns": { + "characters": { + "name": "characters", + "type": { + "compositeType": "characters" + }, + "nullable": "nullable", + "description": null + }, + "id": { + "name": "id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "name": { + "name": "name", + "type": { + "compositeType": "chara" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, "phone_numbers": { "schemaName": "public", "tableName": "phone_numbers", @@ -1067,6 +1100,48 @@ } }, "compositeTypes": { + "chara": { + "name": "chara", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + }, + "popularity": { + "name": "popularity", + "type": { + "scalarType": "int8" + }, + "description": null + } + }, + "description": null + }, + "characters": { + "name": "characters", + "fields": { + "members": { + "name": "members", + "type": { + "arrayType": { + "compositeType": "chara" + } + }, + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } + }, + "description": null + }, "committee": { "name": "committee", "fields": { diff --git a/static/yugabyte/v3-chinook-ndc-metadata/configuration.json b/static/yugabyte/v3-chinook-ndc-metadata/configuration.json index e8774e29b..4bc5265fa 100644 --- a/static/yugabyte/v3-chinook-ndc-metadata/configuration.json +++ b/static/yugabyte/v3-chinook-ndc-metadata/configuration.json @@ -791,6 +791,39 @@ "foreignRelations": {}, "description": null }, + "group_leader": { + "schemaName": "public", + "tableName": "group_leader", + "columns": { + "characters": { + "name": "characters", + "type": { + "compositeType": "characters" + }, + "nullable": "nullable", + "description": null + }, + "id": { + "name": "id", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "name": { + "name": "name", + "type": { + "compositeType": "chara" + }, + "nullable": "nullable", + "description": null + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {}, + "description": null + }, "phone_numbers": { "schemaName": "public", "tableName": "phone_numbers", @@ -810,6 +843,48 @@ } }, "compositeTypes": { + "chara": { + "name": "chara", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + }, + "popularity": { + "name": "popularity", + "type": { + "scalarType": "int8" + }, + "description": null + } + }, + "description": null + }, + "characters": { + "name": "characters", + "fields": { + "members": { + "name": "members", + "type": { + "arrayType": { + "compositeType": "chara" + } + }, + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } + }, + "description": null + }, "committee": { "name": "committee", "fields": { From 8a7a2d7a57753a9aeb77a48f96d4d1e40e0cff2f Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Tue, 16 Apr 2024 11:57:23 +0300 Subject: [PATCH 15/16] review --- .../translation/src/translation/helpers.rs | 8 +--- .../src/translation/query/fields.rs | 45 +++++++++---------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/crates/query-engine/translation/src/translation/helpers.rs b/crates/query-engine/translation/src/translation/helpers.rs index 0fde91e20..9db3d18bb 100644 --- a/crates/query-engine/translation/src/translation/helpers.rs +++ b/crates/query-engine/translation/src/translation/helpers.rs @@ -207,12 +207,8 @@ impl<'request> Env<'request> { pub fn lookup_type_representation( &self, scalar_type: &metadata::ScalarType, - ) -> Option { - self.metadata - .type_representations - .0 - .get(scalar_type) - .cloned() + ) -> Option<&metadata::TypeRepresentation> { + self.metadata.type_representations.0.get(scalar_type) } /// Try to get the variables table reference. This will fail if no variables were passed diff --git a/crates/query-engine/translation/src/translation/query/fields.rs b/crates/query-engine/translation/src/translation/query/fields.rs index 56974476d..8d8a6c694 100644 --- a/crates/query-engine/translation/src/translation/query/fields.rs +++ b/crates/query-engine/translation/src/translation/query/fields.rs @@ -381,7 +381,6 @@ fn unpack_and_wrap_fields( sql::ast::Expression::ColumnReference(nested_column_reference), )) } - // TODO: Arrays of composite types are not handled yet. Type::ArrayType(ref type_boxed) => match **type_boxed { Type::ArrayType(_) => Err(Error::NestedArraysNotSupported { field_name: column.to_string(), @@ -429,13 +428,13 @@ fn unpack_and_wrap_fields( /// For array columns of those type representation, we wrap the result in a cast. fn wrap_array_in_type_representation( expression: sql::ast::Expression, - column_type_representation: Option, + column_type_representation: Option<&TypeRepresentation>, ) -> sql::ast::Expression { match column_type_representation { None => expression, Some(type_rep) => { if let Some(sql::ast::ScalarType(cast_type)) = - get_type_representation_cast_type(&type_rep) + get_type_representation_cast_type(type_rep) { sql::ast::Expression::Cast { expression: Box::new(expression), @@ -454,12 +453,12 @@ fn wrap_array_in_type_representation( /// For columns of those type representation, we wrap the result in a cast. fn wrap_in_type_representation( expression: sql::ast::Expression, - column_type_representation: Option, + column_type_representation: Option<&TypeRepresentation>, ) -> sql::ast::Expression { match column_type_representation { None => expression, Some(type_rep) => { - if let Some(cast_type) = get_type_representation_cast_type(&type_rep) { + if let Some(cast_type) = get_type_representation_cast_type(type_rep) { sql::ast::Expression::Cast { expression: Box::new(expression), r#type: cast_type, @@ -483,24 +482,24 @@ fn get_type_representation_cast_type( // In these situations the type representation should be the same as // the expression, so we don't cast it. - TypeRepresentation::Boolean => None, - TypeRepresentation::String => None, - TypeRepresentation::Float32 => None, - TypeRepresentation::Float64 => None, - TypeRepresentation::Int16 => None, - TypeRepresentation::Int32 => None, - TypeRepresentation::Int64 => None, - TypeRepresentation::BigDecimal => None, - TypeRepresentation::Timestamp => None, - TypeRepresentation::Timestamptz => None, - TypeRepresentation::Time => None, - TypeRepresentation::Timetz => None, - TypeRepresentation::Date => None, - TypeRepresentation::UUID => None, - TypeRepresentation::Geography => None, - TypeRepresentation::Geometry => None, - TypeRepresentation::Json => None, - TypeRepresentation::Enum(_) => None, + TypeRepresentation::Boolean + | TypeRepresentation::String + | TypeRepresentation::Float32 + | TypeRepresentation::Float64 + | TypeRepresentation::Int16 + | TypeRepresentation::Int32 + | TypeRepresentation::Int64 + | TypeRepresentation::BigDecimal + | TypeRepresentation::Timestamp + | TypeRepresentation::Timestamptz + | TypeRepresentation::Time + | TypeRepresentation::Timetz + | TypeRepresentation::Date + | TypeRepresentation::UUID + | TypeRepresentation::Geography + | TypeRepresentation::Geometry + | TypeRepresentation::Json + | TypeRepresentation::Enum(_) => None, } } From f3ca5834a86b5103b5070a4b11d0b6082d1af414 Mon Sep 17 00:00:00 2001 From: Gil Mizrahi Date: Tue, 16 Apr 2024 12:27:19 +0300 Subject: [PATCH 16/16] fix snaps --- .../snapshots/tests__select_composite_column_complex.snap | 4 ++-- .../snapshots/tests__select_composite_column_simple.snap | 4 ++-- .../snapshots/tests__select_composite_variable_complex.snap | 4 ++-- .../snapshots/tests__select_composite_variable_simple.snap | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_complex.snap b/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_complex.snap index 626a38da8..e62a9a399 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_complex.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_complex.snap @@ -3,7 +3,7 @@ source: crates/query-engine/translation/tests/tests.rs expression: result --- WITH "%1_NATIVE_QUERY_make_person" AS ( - WITH "%6_NATIVE_QUERY_make_person" AS ( + WITH "%15_NATIVE_QUERY_make_person" AS ( SELECT ROW( jsonb_populate_record(cast(null as person_name), $1), @@ -13,7 +13,7 @@ WITH "%1_NATIVE_QUERY_make_person" AS ( SELECT * FROM - "%6_NATIVE_QUERY_make_person" AS "%7_NATIVE_QUERY_make_person" + "%15_NATIVE_QUERY_make_person" AS "%16_NATIVE_QUERY_make_person" ) SELECT coalesce(json_agg(row_to_json("%11_universe")), '[]') AS "universe" diff --git a/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_simple.snap b/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_simple.snap index c13f35317..f48b61221 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_simple.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__select_composite_column_simple.snap @@ -3,14 +3,14 @@ source: crates/query-engine/translation/tests/tests.rs expression: result --- WITH "%1_NATIVE_QUERY_address_identity_function" AS ( - WITH "%6_NATIVE_QUERY_address_identity_function" AS ( + WITH "%9_NATIVE_QUERY_address_identity_function" AS ( SELECT jsonb_populate_record(cast(null as person_address), $1) as result ) SELECT * FROM - "%6_NATIVE_QUERY_address_identity_function" AS "%7_NATIVE_QUERY_address_identity_function" + "%9_NATIVE_QUERY_address_identity_function" AS "%10_NATIVE_QUERY_address_identity_function" ) SELECT coalesce(json_agg(row_to_json("%5_universe")), '[]') AS "universe" diff --git a/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_complex.snap b/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_complex.snap index 110399134..5fb123b8e 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_complex.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_complex.snap @@ -12,7 +12,7 @@ FROM jsonb_to_recordset($1) AS "%0_%variables_table"("%variable_order" int, "%variables" jsonb) CROSS JOIN LATERAL ( WITH "%2_NATIVE_QUERY_make_person" AS ( - WITH "%7_NATIVE_QUERY_make_person" AS ( + WITH "%16_NATIVE_QUERY_make_person" AS ( SELECT ROW( jsonb_populate_record( @@ -28,7 +28,7 @@ FROM SELECT * FROM - "%7_NATIVE_QUERY_make_person" AS "%8_NATIVE_QUERY_make_person" + "%16_NATIVE_QUERY_make_person" AS "%17_NATIVE_QUERY_make_person" ) SELECT * diff --git a/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_simple.snap b/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_simple.snap index 7a8665066..c9ab52a8b 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_simple.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__select_composite_variable_simple.snap @@ -12,7 +12,7 @@ FROM jsonb_to_recordset($1) AS "%0_%variables_table"("%variable_order" int, "%variables" jsonb) CROSS JOIN LATERAL ( WITH "%2_NATIVE_QUERY_address_identity_function" AS ( - WITH "%7_NATIVE_QUERY_address_identity_function" AS ( + WITH "%10_NATIVE_QUERY_address_identity_function" AS ( SELECT jsonb_populate_record( cast(null as person_address), @@ -22,7 +22,7 @@ FROM SELECT * FROM - "%7_NATIVE_QUERY_address_identity_function" AS "%8_NATIVE_QUERY_address_identity_function" + "%10_NATIVE_QUERY_address_identity_function" AS "%11_NATIVE_QUERY_address_identity_function" ) SELECT *