/* 
This file is auto generated by pgrx.

The ordering of items is not stable, it is driven by a dependency graph.
*/

-- src/bindings/xgboost.rs:20
-- pgml::bindings::xgboost::xgboost_version
CREATE  FUNCTION pgml."xgboost_version"() RETURNS TEXT /* alloc::string::String */
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'xgboost_version_wrapper';

-- src/api.rs:86
-- pgml::api::version
CREATE  FUNCTION pgml."version"() RETURNS TEXT /* alloc::string::String */
IMMUTABLE STRICT PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'version_wrapper';

-- src/api.rs:70
-- pgml::api::validate_shared_library
CREATE  FUNCTION pgml."validate_shared_library"() RETURNS void
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'validate_shared_library_wrapper';

-- src/api.rs:31
-- pgml::api::validate_python_dependencies
CREATE  FUNCTION pgml."validate_python_dependencies"() RETURNS bool /* bool */
IMMUTABLE STRICT PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'validate_python_dependencies_wrapper';

-- src/api.rs:622
-- pgml::api::transform
CREATE  FUNCTION pgml."transform"(
	"task" TEXT, /* alloc::string::String */
	"args" jsonb DEFAULT '{}', /* pgrx::datum::json::JsonB */
	"inputs" TEXT[] DEFAULT ARRAY[]::TEXT[], /* alloc::vec::Vec<&str> */
	"cache" bool DEFAULT false /* bool */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'transform_string_wrapper';

-- src/api.rs:607
-- pgml::api::transform
CREATE  FUNCTION pgml."transform"(
	"task" jsonb, /* pgrx::datum::json::JsonB */
	"args" jsonb DEFAULT '{}', /* pgrx::datum::json::JsonB */
	"inputs" TEXT[] DEFAULT ARRAY[]::TEXT[], /* alloc::vec::Vec<&str> */
	"cache" bool DEFAULT false /* bool */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'transform_json_wrapper';

-- src/vectors.rs:329
-- pgml::vectors::sum_s_state
CREATE  FUNCTION pgml."sum_s_state"(
	"this" real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	"arg_one" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* core::option::Option<alloc::vec::Vec<f32>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'sum_s_state_wrapper';

-- src/vectors.rs:329
-- pgml::vectors::sum_s_finalize
CREATE  FUNCTION pgml."sum_s_finalize"(
	"this" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'sum_s_finalize_wrapper';

-- src/vectors.rs:329
-- pgml::vectors::sum_s_combine
CREATE  FUNCTION pgml."sum_s_combine"(
	"this" real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	"v" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* core::option::Option<alloc::vec::Vec<f32>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'sum_s_combine_wrapper';

-- src/vectors.rs:329
-- pgml::vectors::SumS
CREATE AGGREGATE pgml.sum (
	real[] /* core::option::Option<alloc::vec::Vec<f32>> */
)
(
	SFUNC = pgml."sum_s_state", /* pgml::vectors::SumS::state */
	STYPE = real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	FINALFUNC = pgml."sum_s_finalize", /* pgml::vectors::SumS::final */
	COMBINEFUNC = pgml."sum_s_combine" /* pgml::vectors::SumS::combine */
);

-- src/vectors.rs:392
-- pgml::vectors::sum_d_state
CREATE  FUNCTION pgml."sum_d_state"(
	"this" double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	"arg_one" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'sum_d_state_wrapper';

-- src/vectors.rs:392
-- pgml::vectors::sum_d_finalize
CREATE  FUNCTION pgml."sum_d_finalize"(
	"this" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'sum_d_finalize_wrapper';

-- src/vectors.rs:392
-- pgml::vectors::sum_d_combine
CREATE  FUNCTION pgml."sum_d_combine"(
	"this" double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	"v" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'sum_d_combine_wrapper';

-- src/vectors.rs:392
-- pgml::vectors::SumD
CREATE AGGREGATE pgml.sum (
	double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
)
(
	SFUNC = pgml."sum_d_state", /* pgml::vectors::SumD::state */
	STYPE = double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	FINALFUNC = pgml."sum_d_finalize", /* pgml::vectors::SumD::final */
	COMBINEFUNC = pgml."sum_d_combine" /* pgml::vectors::SumD::combine */
);

-- src/vectors.rs:63
-- pgml::vectors::subtract
CREATE  FUNCTION pgml."subtract"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"subtahend" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'subtract_vector_s_wrapper';

-- src/vectors.rs:72
-- pgml::vectors::subtract
CREATE  FUNCTION pgml."subtract"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"subtahend" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'subtract_vector_d_wrapper';

-- src/vectors.rs:15
-- pgml::vectors::subtract
CREATE  FUNCTION pgml."subtract"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"subtahend" real /* f32 */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'subtract_scalar_s_wrapper';

-- src/vectors.rs:20
-- pgml::vectors::subtract
CREATE  FUNCTION pgml."subtract"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"subtahend" double precision /* f64 */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'subtract_scalar_d_wrapper';

-- src/api.rs:826
-- pgml::api::sklearn_regression_metrics
CREATE  FUNCTION pgml."sklearn_regression_metrics"(
	"ground_truth" real[], /* alloc::vec::Vec<f32> */
	"y_hat" real[] /* alloc::vec::Vec<f32> */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
STRICT 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'sklearn_regression_metrics_wrapper';

-- src/api.rs:820
-- pgml::api::sklearn_r2_score
CREATE  FUNCTION pgml."sklearn_r2_score"(
	"ground_truth" real[], /* alloc::vec::Vec<f32> */
	"y_hat" real[] /* alloc::vec::Vec<f32> */
) RETURNS real /* f32 */
STRICT 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'sklearn_r2_score_wrapper';

-- src/api.rs:814
-- pgml::api::sklearn_f1_score
CREATE  FUNCTION pgml."sklearn_f1_score"(
	"ground_truth" real[], /* alloc::vec::Vec<f32> */
	"y_hat" real[] /* alloc::vec::Vec<f32> */
) RETURNS real /* f32 */
STRICT 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'sklearn_f1_score_wrapper';

-- src/api.rs:836
-- pgml::api::sklearn_classification_metrics
CREATE  FUNCTION pgml."sklearn_classification_metrics"(
	"ground_truth" real[], /* alloc::vec::Vec<f32> */
	"y_hat" real[], /* alloc::vec::Vec<f32> */
	"num_classes" bigint /* i64 */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
STRICT 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'sklearn_classification_metrics_wrapper';

-- src/api.rs:59
-- pgml::api::python_version
CREATE  FUNCTION pgml."python_version"() RETURNS TEXT /* alloc::string::String */
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'python_version_wrapper';

-- src/api.rs:53
-- pgml::api::python_pip_freeze
CREATE  FUNCTION pgml."python_pip_freeze"() RETURNS TABLE (
	"package" TEXT  /* alloc::string::String */
)
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'python_pip_freeze_wrapper';

-- src/api.rs:41
-- pgml::api::python_package_version
CREATE  FUNCTION pgml."python_package_version"(
	"name" TEXT /* &str */
) RETURNS TEXT /* alloc::string::String */
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'python_package_version_wrapper';

-- src/api.rs:425
-- pgml::api::predict_proba
CREATE  FUNCTION pgml."predict_proba"(
	"project_name" TEXT, /* &str */
	"features" real[] /* alloc::vec::Vec<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_proba_wrapper';

-- src/api.rs:453
-- pgml::api::predict_proba
CREATE  FUNCTION pgml."predict_proba"(
	"model_id" bigint, /* i64 */
	"features" real[] /* alloc::vec::Vec<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_model_proba_wrapper';

-- src/api.rs:459
-- pgml::api::predict_joint
CREATE  FUNCTION pgml."predict_joint"(
	"model_id" bigint, /* i64 */
	"features" real[] /* alloc::vec::Vec<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_model_joint_wrapper';

-- src/api.rs:430
-- pgml::api::predict_joint
CREATE  FUNCTION pgml."predict_joint"(
	"project_name" TEXT, /* &str */
	"features" real[] /* alloc::vec::Vec<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_joint_wrapper';

-- src/api.rs:465
-- pgml::api::predict_batch
CREATE  FUNCTION pgml."predict_batch"(
	"model_id" bigint, /* i64 */
	"features" real[] /* alloc::vec::Vec<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_model_batch_wrapper';

-- src/api.rs:435
-- pgml::api::predict_batch
CREATE  FUNCTION pgml."predict_batch"(
	"project_name" TEXT, /* &str */
	"features" real[] /* alloc::vec::Vec<f32> */
) RETURNS SETOF real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_batch_wrapper';

-- src/api.rs:442
-- pgml::api::predict
CREATE  FUNCTION pgml."predict"(
	"project_name" TEXT, /* &str */
	"row" anyelement /* pgrx::datum::anyelement::AnyElement */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_row_wrapper';

-- src/api.rs:471
-- pgml::api::predict
CREATE  FUNCTION pgml."predict"(
	"model_id" bigint, /* i64 */
	"row" anyelement /* pgrx::datum::anyelement::AnyElement */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_model_row_wrapper';

-- src/api.rs:447
-- pgml::api::predict
CREATE  FUNCTION pgml."predict"(
	"model_id" bigint, /* i64 */
	"features" real[] /* alloc::vec::Vec<f32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_model_wrapper';

-- src/api.rs:412
-- pgml::api::predict
CREATE  FUNCTION pgml."predict"(
	"project_name" TEXT, /* &str */
	"features" bigint[] /* alloc::vec::Vec<i64> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_i64_wrapper';

-- src/api.rs:407
-- pgml::api::predict
CREATE  FUNCTION pgml."predict"(
	"project_name" TEXT, /* &str */
	"features" INT[] /* alloc::vec::Vec<i32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_i32_wrapper';

-- src/api.rs:402
-- pgml::api::predict
CREATE  FUNCTION pgml."predict"(
	"project_name" TEXT, /* &str */
	"features" smallint[] /* alloc::vec::Vec<i16> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_i16_wrapper';

-- src/api.rs:397
-- pgml::api::predict
CREATE  FUNCTION pgml."predict"(
	"project_name" TEXT, /* &str */
	"features" double precision[] /* alloc::vec::Vec<f64> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_f64_wrapper';

-- src/api.rs:392
-- pgml::api::predict
CREATE  FUNCTION pgml."predict"(
	"project_name" TEXT, /* &str */
	"features" real[] /* alloc::vec::Vec<f32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_f32_wrapper';

-- src/api.rs:417
-- pgml::api::predict
CREATE  FUNCTION pgml."predict"(
	"project_name" TEXT, /* &str */
	"features" bool[] /* alloc::vec::Vec<bool> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'predict_bool_wrapper';

-- src/vectors.rs:223
-- pgml::vectors::normalize_max
CREATE  FUNCTION pgml."normalize_max"(
	"vector" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'normalize_max_s_wrapper';

-- src/vectors.rs:234
-- pgml::vectors::normalize_max
CREATE  FUNCTION pgml."normalize_max"(
	"vector" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'normalize_max_d_wrapper';

-- src/vectors.rs:203
-- pgml::vectors::normalize_l2
CREATE  FUNCTION pgml."normalize_l2"(
	"vector" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'normalize_l2_s_wrapper';

-- src/vectors.rs:213
-- pgml::vectors::normalize_l2
CREATE  FUNCTION pgml."normalize_l2"(
	"vector" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'normalize_l2_d_wrapper';

-- src/vectors.rs:183
-- pgml::vectors::normalize_l1
CREATE  FUNCTION pgml."normalize_l1"(
	"vector" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'normalize_l1_s_wrapper';

-- src/vectors.rs:193
-- pgml::vectors::normalize_l1
CREATE  FUNCTION pgml."normalize_l1"(
	"vector" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'normalize_l1_d_wrapper';

-- src/vectors.rs:165
-- pgml::vectors::norm_max
CREATE  FUNCTION pgml."norm_max"(
	"vector" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'norm_max_s_wrapper';

-- src/vectors.rs:174
-- pgml::vectors::norm_max
CREATE  FUNCTION pgml."norm_max"(
	"vector" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision /* f64 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'norm_max_d_wrapper';

-- src/vectors.rs:149
-- pgml::vectors::norm_l2
CREATE  FUNCTION pgml."norm_l2"(
	"vector" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'norm_l2_s_wrapper';

-- src/vectors.rs:157
-- pgml::vectors::norm_l2
CREATE  FUNCTION pgml."norm_l2"(
	"vector" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision /* f64 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'norm_l2_d_wrapper';

-- src/vectors.rs:133
-- pgml::vectors::norm_l1
CREATE  FUNCTION pgml."norm_l1"(
	"vector" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'norm_l1_s_wrapper';

-- src/vectors.rs:141
-- pgml::vectors::norm_l1
CREATE  FUNCTION pgml."norm_l1"(
	"vector" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision /* f64 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'norm_l1_d_wrapper';

-- src/vectors.rs:117
-- pgml::vectors::norm_l0
CREATE  FUNCTION pgml."norm_l0"(
	"vector" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'norm_l0_s_wrapper';

-- src/vectors.rs:125
-- pgml::vectors::norm_l0
CREATE  FUNCTION pgml."norm_l0"(
	"vector" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision /* f64 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'norm_l0_d_wrapper';

-- src/vectors.rs:81
-- pgml::vectors::multiply
CREATE  FUNCTION pgml."multiply"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"multiplicand" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'multiply_vector_s_wrapper';

-- src/vectors.rs:90
-- pgml::vectors::multiply
CREATE  FUNCTION pgml."multiply"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"multiplicand" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'multiply_vector_d_wrapper';

-- src/vectors.rs:25
-- pgml::vectors::multiply
CREATE  FUNCTION pgml."multiply"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"multiplicand" real /* f32 */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'multiply_scalar_s_wrapper';

-- src/vectors.rs:30
-- pgml::vectors::multiply
CREATE  FUNCTION pgml."multiply"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"multiplicand" double precision /* f64 */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'multiply_scalar_d_wrapper';

-- src/vectors.rs:723
-- pgml::vectors::min_s_state
CREATE  FUNCTION pgml."min_s_state"(
	"this" real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	"arg_one" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* core::option::Option<alloc::vec::Vec<f32>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_s_state_wrapper';

-- src/vectors.rs:723
-- pgml::vectors::min_s_finalize
CREATE  FUNCTION pgml."min_s_finalize"(
	"this" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_s_finalize_wrapper';

-- src/vectors.rs:723
-- pgml::vectors::min_s_combine
CREATE  FUNCTION pgml."min_s_combine"(
	"this" real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	"v" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* core::option::Option<alloc::vec::Vec<f32>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_s_combine_wrapper';

-- src/vectors.rs:723
-- pgml::vectors::MinS
CREATE AGGREGATE pgml.min (
	real[] /* core::option::Option<alloc::vec::Vec<f32>> */
)
(
	SFUNC = pgml."min_s_state", /* pgml::vectors::MinS::state */
	STYPE = real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	FINALFUNC = pgml."min_s_finalize", /* pgml::vectors::MinS::final */
	COMBINEFUNC = pgml."min_s_combine" /* pgml::vectors::MinS::combine */
);

-- src/vectors.rs:790
-- pgml::vectors::min_d_state
CREATE  FUNCTION pgml."min_d_state"(
	"this" double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	"arg_one" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_d_state_wrapper';

-- src/vectors.rs:790
-- pgml::vectors::min_d_finalize
CREATE  FUNCTION pgml."min_d_finalize"(
	"this" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_d_finalize_wrapper';

-- src/vectors.rs:790
-- pgml::vectors::min_d_combine
CREATE  FUNCTION pgml."min_d_combine"(
	"this" double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	"v" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_d_combine_wrapper';

-- src/vectors.rs:790
-- pgml::vectors::MinD
CREATE AGGREGATE pgml.min (
	double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
)
(
	SFUNC = pgml."min_d_state", /* pgml::vectors::MinD::state */
	STYPE = double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	FINALFUNC = pgml."min_d_finalize", /* pgml::vectors::MinD::final */
	COMBINEFUNC = pgml."min_d_combine" /* pgml::vectors::MinD::combine */
);

-- src/vectors.rs:857
-- pgml::vectors::min_abs_s_state
CREATE  FUNCTION pgml."min_abs_s_state"(
	"this" real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	"arg_one" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* core::option::Option<alloc::vec::Vec<f32>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_abs_s_state_wrapper';

-- src/vectors.rs:857
-- pgml::vectors::min_abs_s_finalize
CREATE  FUNCTION pgml."min_abs_s_finalize"(
	"this" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_abs_s_finalize_wrapper';

-- src/vectors.rs:857
-- pgml::vectors::min_abs_s_combine
CREATE  FUNCTION pgml."min_abs_s_combine"(
	"this" real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	"v" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* core::option::Option<alloc::vec::Vec<f32>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_abs_s_combine_wrapper';

-- src/vectors.rs:857
-- pgml::vectors::MinAbsS
CREATE AGGREGATE pgml.min_abs (
	real[] /* core::option::Option<alloc::vec::Vec<f32>> */
)
(
	SFUNC = pgml."min_abs_s_state", /* pgml::vectors::MinAbsS::state */
	STYPE = real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	FINALFUNC = pgml."min_abs_s_finalize", /* pgml::vectors::MinAbsS::final */
	COMBINEFUNC = pgml."min_abs_s_combine" /* pgml::vectors::MinAbsS::combine */
);

-- src/vectors.rs:924
-- pgml::vectors::min_abs_d_state
CREATE  FUNCTION pgml."min_abs_d_state"(
	"this" double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	"arg_one" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_abs_d_state_wrapper';

-- src/vectors.rs:924
-- pgml::vectors::min_abs_d_finalize
CREATE  FUNCTION pgml."min_abs_d_finalize"(
	"this" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_abs_d_finalize_wrapper';

-- src/vectors.rs:924
-- pgml::vectors::min_abs_d_combine
CREATE  FUNCTION pgml."min_abs_d_combine"(
	"this" double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	"v" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'min_abs_d_combine_wrapper';

-- src/vectors.rs:924
-- pgml::vectors::MinAbsD
CREATE AGGREGATE pgml.min_abs (
	double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
)
(
	SFUNC = pgml."min_abs_d_state", /* pgml::vectors::MinAbsD::state */
	STYPE = double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	FINALFUNC = pgml."min_abs_d_finalize", /* pgml::vectors::MinAbsD::final */
	COMBINEFUNC = pgml."min_abs_d_combine" /* pgml::vectors::MinAbsD::combine */
);

-- src/vectors.rs:589
-- pgml::vectors::max_s_state
CREATE  FUNCTION pgml."max_s_state"(
	"this" real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	"arg_one" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* core::option::Option<alloc::vec::Vec<f32>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_s_state_wrapper';

-- src/vectors.rs:589
-- pgml::vectors::max_s_finalize
CREATE  FUNCTION pgml."max_s_finalize"(
	"this" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_s_finalize_wrapper';

-- src/vectors.rs:589
-- pgml::vectors::max_s_combine
CREATE  FUNCTION pgml."max_s_combine"(
	"this" real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	"v" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* core::option::Option<alloc::vec::Vec<f32>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_s_combine_wrapper';

-- src/vectors.rs:589
-- pgml::vectors::MaxS
CREATE AGGREGATE pgml.max (
	real[] /* core::option::Option<alloc::vec::Vec<f32>> */
)
(
	SFUNC = pgml."max_s_state", /* pgml::vectors::MaxS::state */
	STYPE = real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	FINALFUNC = pgml."max_s_finalize", /* pgml::vectors::MaxS::final */
	COMBINEFUNC = pgml."max_s_combine" /* pgml::vectors::MaxS::combine */
);

-- src/vectors.rs:656
-- pgml::vectors::max_d_state
CREATE  FUNCTION pgml."max_d_state"(
	"this" double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	"arg_one" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_d_state_wrapper';

-- src/vectors.rs:656
-- pgml::vectors::max_d_finalize
CREATE  FUNCTION pgml."max_d_finalize"(
	"this" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_d_finalize_wrapper';

-- src/vectors.rs:656
-- pgml::vectors::max_d_combine
CREATE  FUNCTION pgml."max_d_combine"(
	"this" double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	"v" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_d_combine_wrapper';

-- src/vectors.rs:656
-- pgml::vectors::MaxD
CREATE AGGREGATE pgml.max (
	double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
)
(
	SFUNC = pgml."max_d_state", /* pgml::vectors::MaxD::state */
	STYPE = double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	FINALFUNC = pgml."max_d_finalize", /* pgml::vectors::MaxD::final */
	COMBINEFUNC = pgml."max_d_combine" /* pgml::vectors::MaxD::combine */
);

-- src/vectors.rs:455
-- pgml::vectors::max_abs_s_state
CREATE  FUNCTION pgml."max_abs_s_state"(
	"this" real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	"arg_one" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* core::option::Option<alloc::vec::Vec<f32>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_abs_s_state_wrapper';

-- src/vectors.rs:455
-- pgml::vectors::max_abs_s_finalize
CREATE  FUNCTION pgml."max_abs_s_finalize"(
	"this" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_abs_s_finalize_wrapper';

-- src/vectors.rs:455
-- pgml::vectors::max_abs_s_combine
CREATE  FUNCTION pgml."max_abs_s_combine"(
	"this" real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	"v" real[] /* core::option::Option<alloc::vec::Vec<f32>> */
) RETURNS real[] /* core::option::Option<alloc::vec::Vec<f32>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_abs_s_combine_wrapper';

-- src/vectors.rs:455
-- pgml::vectors::MaxAbsS
CREATE AGGREGATE pgml.max_abs (
	real[] /* core::option::Option<alloc::vec::Vec<f32>> */
)
(
	SFUNC = pgml."max_abs_s_state", /* pgml::vectors::MaxAbsS::state */
	STYPE = real[], /* core::option::Option<alloc::vec::Vec<f32>> */
	FINALFUNC = pgml."max_abs_s_finalize", /* pgml::vectors::MaxAbsS::final */
	COMBINEFUNC = pgml."max_abs_s_combine" /* pgml::vectors::MaxAbsS::combine */
);

-- src/vectors.rs:522
-- pgml::vectors::max_abs_d_state
CREATE  FUNCTION pgml."max_abs_d_state"(
	"this" double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	"arg_one" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_abs_d_state_wrapper';

-- src/vectors.rs:522
-- pgml::vectors::max_abs_d_finalize
CREATE  FUNCTION pgml."max_abs_d_finalize"(
	"this" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_abs_d_finalize_wrapper';

-- src/vectors.rs:522
-- pgml::vectors::max_abs_d_combine
CREATE  FUNCTION pgml."max_abs_d_combine"(
	"this" double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	"v" double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
) RETURNS double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
IMMUTABLE PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'max_abs_d_combine_wrapper';

-- src/vectors.rs:522
-- pgml::vectors::MaxAbsD
CREATE AGGREGATE pgml.max_abs (
	double precision[] /* core::option::Option<alloc::vec::Vec<f64>> */
)
(
	SFUNC = pgml."max_abs_d_state", /* pgml::vectors::MaxAbsD::state */
	STYPE = double precision[], /* core::option::Option<alloc::vec::Vec<f64>> */
	FINALFUNC = pgml."max_abs_d_finalize", /* pgml::vectors::MaxAbsD::final */
	COMBINEFUNC = pgml."max_abs_d_combine" /* pgml::vectors::MaxAbsD::combine */
);

-- src/api.rs:510
-- pgml::api::load_dataset
CREATE  FUNCTION pgml."load_dataset"(
	"source" TEXT, /* &str */
	"subset" TEXT DEFAULT NULL, /* core::option::Option<alloc::string::String> */
	"limit" bigint DEFAULT NULL, /* core::option::Option<i64> */
	"kwargs" jsonb DEFAULT '{}' /* pgrx::datum::json::JsonB */
) RETURNS TABLE (
	"table_name" TEXT,  /* alloc::string::String */
	"rows" bigint  /* i64 */
)
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'load_dataset_wrapper';

-- src/api.rs:889
-- pgml::api::load_all
CREATE  FUNCTION pgml."load_all"(
	"path" TEXT /* &str */
) RETURNS void
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'load_all_wrapper';

-- src/api.rs:646
-- pgml::api::generate
CREATE  FUNCTION pgml."generate"(
	"project_name" TEXT, /* &str */
	"inputs" TEXT[], /* alloc::vec::Vec<&str> */
	"config" jsonb DEFAULT '{}' /* pgrx::datum::json::JsonB */
) RETURNS TEXT[] /* alloc::vec::Vec<alloc::string::String> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'generate_batch_wrapper';

-- src/api.rs:637
-- pgml::api::generate
CREATE  FUNCTION pgml."generate"(
	"project_name" TEXT, /* &str */
	"inputs" TEXT, /* &str */
	"config" jsonb DEFAULT '{}' /* pgrx::datum::json::JsonB */
) RETURNS TEXT /* alloc::string::String */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'generate_wrapper';

-- src/api.rs:550
-- pgml::api::embed
CREATE  FUNCTION pgml."embed"(
	"transformer" TEXT, /* &str */
	"inputs" TEXT[], /* alloc::vec::Vec<&str> */
	"kwargs" jsonb DEFAULT '{}' /* pgrx::datum::json::JsonB */
) RETURNS real[][] /* alloc::vec::Vec<alloc::vec::Vec<f32>> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'embed_batch_wrapper';

-- src/api.rs:541
-- pgml::api::embed
CREATE  FUNCTION pgml."embed"(
	"transformer" TEXT, /* &str */
	"text" TEXT, /* &str */
	"kwargs" jsonb DEFAULT '{}' /* pgrx::datum::json::JsonB */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'embed_wrapper';

-- src/api.rs:851
-- pgml::api::dump_all
CREATE  FUNCTION pgml."dump_all"(
	"path" TEXT /* &str */
) RETURNS void
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'dump_all_wrapper';

-- src/vectors.rs:283
-- pgml::vectors::dot_product
CREATE  FUNCTION pgml."dot_product"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"other" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'dot_product_s_wrapper';

-- src/vectors.rs:292
-- pgml::vectors::dot_product
CREATE  FUNCTION pgml."dot_product"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"other" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision /* f64 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'dot_product_d_wrapper';

-- src/vectors.rs:99
-- pgml::vectors::divide
CREATE  FUNCTION pgml."divide"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"dividend" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'divide_vector_s_wrapper';

-- src/vectors.rs:108
-- pgml::vectors::divide
CREATE  FUNCTION pgml."divide"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"dividend" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'divide_vector_d_wrapper';

-- src/vectors.rs:35
-- pgml::vectors::divide
CREATE  FUNCTION pgml."divide"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"dividend" real /* f32 */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'divide_scalar_s_wrapper';

-- src/vectors.rs:40
-- pgml::vectors::divide
CREATE  FUNCTION pgml."divide"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"dividend" double precision /* f64 */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'divide_scalar_d_wrapper';

-- src/vectors.rs:263
-- pgml::vectors::distance_l2
CREATE  FUNCTION pgml."distance_l2"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"other" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'distance_l2_s_wrapper';

-- src/vectors.rs:273
-- pgml::vectors::distance_l2
CREATE  FUNCTION pgml."distance_l2"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"other" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision /* f64 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'distance_l2_d_wrapper';

-- src/vectors.rs:245
-- pgml::vectors::distance_l1
CREATE  FUNCTION pgml."distance_l1"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"other" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'distance_l1_s_wrapper';

-- src/vectors.rs:254
-- pgml::vectors::distance_l1
CREATE  FUNCTION pgml."distance_l1"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"other" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision /* f64 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'distance_l1_d_wrapper';

-- src/vectors.rs:301
-- pgml::vectors::cosine_similarity
CREATE  FUNCTION pgml."cosine_similarity"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"other" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real /* f32 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'cosine_similarity_s_wrapper';

-- src/vectors.rs:314
-- pgml::vectors::cosine_similarity
CREATE  FUNCTION pgml."cosine_similarity"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"other" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision /* f64 */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'cosine_similarity_d_wrapper';

-- src/api.rs:577
-- pgml::api::clear_gpu_cache
CREATE  FUNCTION pgml."clear_gpu_cache"(
	"memory_usage" real DEFAULT NULL /* core::option::Option<f32> */
) RETURNS bool /* bool */
IMMUTABLE PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'clear_gpu_cache_wrapper';

-- src/api.rs:585
-- pgml::api::chunk
CREATE  FUNCTION pgml."chunk"(
	"splitter" TEXT, /* &str */
	"text" TEXT, /* &str */
	"kwargs" jsonb DEFAULT '{}' /* pgrx::datum::json::JsonB */
) RETURNS TABLE (
	"chunk_index" bigint,  /* i64 */
	"chunk" TEXT  /* alloc::string::String */
)
IMMUTABLE STRICT PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'chunk_wrapper';

-- src/vectors.rs:45
-- pgml::vectors::add
CREATE  FUNCTION pgml."add"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"addend" real[] /* pgrx::datum::array::Array<f32> */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'add_vector_s_wrapper';

-- src/vectors.rs:54
-- pgml::vectors::add
CREATE  FUNCTION pgml."add"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"addend" double precision[] /* pgrx::datum::array::Array<f64> */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'add_vector_d_wrapper';

-- src/vectors.rs:5
-- pgml::vectors::add
CREATE  FUNCTION pgml."add"(
	"vector" real[], /* pgrx::datum::array::Array<f32> */
	"addend" real /* f32 */
) RETURNS real[] /* alloc::vec::Vec<f32> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'add_scalar_s_wrapper';

-- src/vectors.rs:10
-- pgml::vectors::add
CREATE  FUNCTION pgml."add"(
	"vector" double precision[], /* pgrx::datum::array::Array<f64> */
	"addend" double precision /* f64 */
) RETURNS double precision[] /* alloc::vec::Vec<f64> */
IMMUTABLE STRICT PARALLEL SAFE 
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'add_scalar_d_wrapper';

-- src/api.rs:25
-- pgml::api::activate_venv
CREATE  FUNCTION pgml."activate_venv"(
	"venv" TEXT /* &str */
) RETURNS bool /* bool */
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'activate_venv_wrapper';

-- src/orm/task.rs:4
-- pgml::orm::task::Task
CREATE TYPE pgml.Task AS ENUM (
	'regression',
	'classification',
	'question_answering',
	'summarization',
	'translation',
	'text_classification',
	'text_generation',
	'text2text',
	'cluster',
	'embedding'
);

-- src/orm/strategy.rs:4
-- pgml::orm::strategy::Strategy
CREATE TYPE pgml.Strategy AS ENUM (
	'new_score',
	'best_score',
	'most_recent',
	'rollback'
);

-- src/orm/status.rs:4
-- pgml::orm::status::Status
CREATE TYPE pgml.Status AS ENUM (
	'in_progress',
	'successful',
	'failed'
);

-- src/orm/search.rs:4
-- pgml::orm::search::Search
CREATE TYPE pgml.Search AS ENUM (
	'grid',
	'random'
);

-- src/orm/sampling.rs:4
-- pgml::orm::sampling::Sampling
CREATE TYPE pgml.Sampling AS ENUM (
	'random',
	'last'
);

-- src/api.rs:491
-- pgml::api::snapshot
CREATE  FUNCTION pgml."snapshot"(
	"relation_name" TEXT, /* &str */
	"y_column_name" TEXT, /* &str */
	"test_size" real DEFAULT 0.25, /* f32 */
	"test_sampling" pgml.Sampling DEFAULT 'last', /* pgml::orm::sampling::Sampling */
	"preprocess" jsonb DEFAULT '{}' /* pgrx::datum::json::JsonB */
) RETURNS TABLE (
	"relation" TEXT,  /* alloc::string::String */
	"y_column_name" TEXT  /* alloc::string::String */
)
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'snapshot_wrapper';

-- src/api.rs:664
-- pgml::api::tune
CREATE  FUNCTION pgml."tune"(
	"project_name" TEXT, /* &str */
	"task" TEXT DEFAULT NULL, /* core::option::Option<&str> */
	"relation_name" TEXT DEFAULT NULL, /* core::option::Option<&str> */
	"y_column_name" TEXT DEFAULT NULL, /* core::option::Option<&str> */
	"model_name" TEXT DEFAULT NULL, /* core::option::Option<&str> */
	"hyperparams" jsonb DEFAULT '{}', /* pgrx::datum::json::JsonB */
	"test_size" real DEFAULT 0.25, /* f32 */
	"test_sampling" pgml.Sampling DEFAULT 'last', /* pgml::orm::sampling::Sampling */
	"automatic_deploy" bool DEFAULT true, /* core::option::Option<bool> */
	"materialize_snapshot" bool DEFAULT false /* bool */
) RETURNS TABLE (
	"status" TEXT,  /* alloc::string::String */
	"task" TEXT,  /* alloc::string::String */
	"algorithm" TEXT,  /* alloc::string::String */
	"deployed" bool  /* bool */
)
PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'tune_wrapper';

-- src/orm/runtime.rs:4
-- pgml::orm::runtime::Runtime
CREATE TYPE pgml.Runtime AS ENUM (
	'python',
	'rust',
	'openai'
);

-- src/orm/algorithm.rs:4
-- pgml::orm::algorithm::Algorithm
CREATE TYPE pgml.Algorithm AS ENUM (
	'linear',
	'xgboost',
	'xgboost_random_forest',
	'svm',
	'lasso',
	'elastic_net',
	'ridge',
	'kmeans',
	'dbscan',
	'knn',
	'random_forest',
	'least_angle',
	'lasso_least_angle',
	'orthogonal_matching_pursuit',
	'bayesian_ridge',
	'automatic_relevance_determination',
	'stochastic_gradient_descent',
	'perceptron',
	'passive_aggressive',
	'ransac',
	'theil_sen',
	'huber',
	'quantile',
	'kernel_ridge',
	'gaussian_process',
	'nu_svm',
	'ada_boost',
	'bagging',
	'extra_trees',
	'gradient_boosting_trees',
	'hist_gradient_boosting',
	'linear_svm',
	'lightgbm',
	'transformers',
	'affinity_propagation',
	'birch',
	'feature_agglomeration',
	'mini_batch_kmeans',
	'mean_shift',
	'optics',
	'spectral',
	'spectral_bi',
	'spectral_co',
	'catboost'
);

-- src/api.rs:307
-- pgml::api::deploy
CREATE  FUNCTION pgml."deploy"(
	"project_name" TEXT, /* &str */
	"strategy" pgml.Strategy, /* pgml::orm::strategy::Strategy */
	"algorithm" pgml.Algorithm DEFAULT NULL /* core::option::Option<pgml::orm::algorithm::Algorithm> */
) RETURNS TABLE (
	"project" TEXT,  /* alloc::string::String */
	"strategy" TEXT,  /* alloc::string::String */
	"algorithm" TEXT  /* alloc::string::String */
)
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'deploy_wrapper';

-- src/api.rs:92
-- pgml::api::train
CREATE  FUNCTION pgml."train"(
	"project_name" TEXT, /* &str */
	"task" TEXT DEFAULT NULL, /* core::option::Option<&str> */
	"relation_name" TEXT DEFAULT NULL, /* core::option::Option<&str> */
	"y_column_name" TEXT DEFAULT NULL, /* core::option::Option<&str> */
	"algorithm" pgml.Algorithm DEFAULT 'linear', /* pgml::orm::algorithm::Algorithm */
	"hyperparams" jsonb DEFAULT '{}', /* pgrx::datum::json::JsonB */
	"search" pgml.Search DEFAULT NULL, /* core::option::Option<pgml::orm::search::Search> */
	"search_params" jsonb DEFAULT '{}', /* pgrx::datum::json::JsonB */
	"search_args" jsonb DEFAULT '{}', /* pgrx::datum::json::JsonB */
	"test_size" real DEFAULT 0.25, /* f32 */
	"test_sampling" pgml.Sampling DEFAULT 'last', /* pgml::orm::sampling::Sampling */
	"runtime" pgml.Runtime DEFAULT NULL, /* core::option::Option<pgml::orm::runtime::Runtime> */
	"automatic_deploy" bool DEFAULT true, /* core::option::Option<bool> */
	"materialize_snapshot" bool DEFAULT false, /* bool */
	"preprocess" jsonb DEFAULT '{}' /* pgrx::datum::json::JsonB */
) RETURNS TABLE (
	"project" TEXT,  /* alloc::string::String */
	"task" TEXT,  /* alloc::string::String */
	"algorithm" TEXT,  /* alloc::string::String */
	"deployed" bool  /* bool */
)
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'train_wrapper';

-- src/api.rs:138
-- pgml::api::train_joint
CREATE  FUNCTION pgml."train_joint"(
	"project_name" TEXT, /* &str */
	"task" TEXT DEFAULT NULL, /* core::option::Option<&str> */
	"relation_name" TEXT DEFAULT NULL, /* core::option::Option<&str> */
	"y_column_name" TEXT[] DEFAULT NULL, /* core::option::Option<alloc::vec::Vec<alloc::string::String>> */
	"algorithm" pgml.Algorithm DEFAULT 'linear', /* pgml::orm::algorithm::Algorithm */
	"hyperparams" jsonb DEFAULT '{}', /* pgrx::datum::json::JsonB */
	"search" pgml.Search DEFAULT NULL, /* core::option::Option<pgml::orm::search::Search> */
	"search_params" jsonb DEFAULT '{}', /* pgrx::datum::json::JsonB */
	"search_args" jsonb DEFAULT '{}', /* pgrx::datum::json::JsonB */
	"test_size" real DEFAULT 0.25, /* f32 */
	"test_sampling" pgml.Sampling DEFAULT 'last', /* pgml::orm::sampling::Sampling */
	"runtime" pgml.Runtime DEFAULT NULL, /* core::option::Option<pgml::orm::runtime::Runtime> */
	"automatic_deploy" bool DEFAULT true, /* core::option::Option<bool> */
	"materialize_snapshot" bool DEFAULT false, /* bool */
	"preprocess" jsonb DEFAULT '{}' /* pgrx::datum::json::JsonB */
) RETURNS TABLE (
	"project" TEXT,  /* alloc::string::String */
	"task" TEXT,  /* alloc::string::String */
	"algorithm" TEXT,  /* alloc::string::String */
	"deployed" bool  /* bool */
)
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'train_joint_wrapper';

-- src/lib.rs:22
---
--- Validate we have the necessary Python dependencies.
---
SELECT pgml.validate_python_dependencies();
SELECT pgml.validate_shared_library();

--- 
--- Track of updates to data
---
CREATE OR REPLACE FUNCTION pgml.auto_updated_at(tbl regclass) 
RETURNS VOID 
AS $$
    DECLARE name_parts TEXT[];
    DECLARE name TEXT; 
BEGIN
    name_parts := string_to_array(tbl::TEXT, '.');
    name := name_parts[array_upper(name_parts, 1)];

    EXECUTE format('DROP TRIGGER IF EXISTS %s_auto_updated_at ON %s', name, tbl);
    EXECUTE format('CREATE TRIGGER %s_auto_updated_at BEFORE UPDATE ON %s
                    FOR EACH ROW EXECUTE PROCEDURE pgml.set_updated_at()', name, tbl);
END;
$$
LANGUAGE plpgsql;


---
--- Called via trigger whenever a row changes
---
CREATE OR REPLACE FUNCTION pgml.set_updated_at() 
RETURNS TRIGGER 
AS $$
BEGIN
    IF (
        NEW IS DISTINCT FROM OLD
        AND NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at
    ) THEN
        NEW.updated_at := clock_timestamp();
    END IF;
    RETURN new;
END;
$$
LANGUAGE plpgsql;


---
--- Projects organize work
---
CREATE TABLE IF NOT EXISTS pgml.projects(
	id BIGSERIAL PRIMARY KEY,
	name TEXT NOT NULL,
	task pgml.task NOT NULL,
	created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT clock_timestamp(),
	updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT clock_timestamp()
);
SELECT pgml.auto_updated_at('pgml.projects');
CREATE UNIQUE INDEX IF NOT EXISTS projects_name_idx ON pgml.projects(name);


---
--- Snapshots freeze data for training
---
CREATE TABLE IF NOT EXISTS pgml.snapshots(
	id BIGSERIAL PRIMARY KEY,
	relation_name TEXT NOT NULL,
	y_column_name TEXT[],
	test_size FLOAT4 NOT NULL,
	test_sampling pgml.sampling NOT NULL,
	status TEXT NOT NULL,
	columns JSONB,
	analysis JSONB,
	created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT clock_timestamp(),
	updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT clock_timestamp(),
	materialized BOOLEAN DEFAULT false
);
SELECT pgml.auto_updated_at('pgml.snapshots');


---
--- Models save the learned parameters
---
CREATE TABLE IF NOT EXISTS pgml.models(
	id BIGSERIAL PRIMARY KEY,
	project_id BIGINT NOT NULL,
	snapshot_id BIGINT,
	num_features INT NOT NULL,
	algorithm TEXT NOT NULL,
	runtime pgml.runtime DEFAULT 'python'::pgml.runtime,
	hyperparams JSONB NOT NULL,
	status TEXT NOT NULL,
	metrics JSONB,
	search TEXT,
	search_params JSONB NOT NULL,
	search_args JSONB NOT NULL,
	created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT clock_timestamp(),
	updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT clock_timestamp(),
	CONSTRAINT project_id_fk FOREIGN KEY(project_id) REFERENCES pgml.projects(id) ON DELETE CASCADE,
	CONSTRAINT snapshot_id_fk FOREIGN KEY(snapshot_id) REFERENCES pgml.snapshots(id) ON DELETE SET NULL
);
CREATE INDEX IF NOT EXISTS models_project_id_idx ON pgml.models(project_id);
CREATE INDEX IF NOT EXISTS models_snapshot_id_idx ON pgml.models(snapshot_id);
SELECT pgml.auto_updated_at('pgml.models');


---
--- Deployments determine which model is live
---
CREATE TABLE IF NOT EXISTS pgml.deployments(
	id BIGSERIAL PRIMARY KEY,
	project_id BIGINT NOT NULL,
	model_id BIGINT NOT NULL,
	strategy pgml.strategy NOT NULL,
	created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT clock_timestamp(),
	CONSTRAINT project_id_fk FOREIGN KEY(project_id) REFERENCES pgml.projects(id) ON DELETE CASCADE,
	CONSTRAINT model_id_fk FOREIGN KEY(model_id) REFERENCES pgml.models(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS deployments_project_id_created_at_idx ON pgml.deployments(project_id);
CREATE INDEX IF NOT EXISTS deployments_model_id_created_at_idx ON pgml.deployments(model_id);
SELECT pgml.auto_updated_at('pgml.deployments');

---
--- Distribute serialized models consistently for HA
---
CREATE TABLE IF NOT EXISTS pgml.files(
	id BIGSERIAL PRIMARY KEY,
	model_id BIGINT NOT NULL,
	path TEXT NOT NULL,
	part INTEGER NOT NULL,
	created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT clock_timestamp(),
	updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT clock_timestamp(),
	data BYTEA NOT NULL,
	CONSTRAINT model_id_fk FOREIGN KEY(model_id) REFERENCES pgml.models(id) ON DELETE CASCADE
);
CREATE UNIQUE INDEX IF NOT EXISTS files_model_id_path_part_idx ON pgml.files(model_id, path, part);
SELECT pgml.auto_updated_at('pgml.files');

---
--- Quick status check on the system.
---
DROP VIEW IF EXISTS pgml.overview;
CREATE VIEW pgml.overview AS
SELECT
	   p.name,
	   d.created_at AS deployed_at,
       p.task,
       m.algorithm,
       m.runtime,
       s.relation_name,
       s.y_column_name,
       s.test_sampling,
       s.test_size
FROM pgml.projects p
INNER JOIN pgml.models m ON p.id = m.project_id
INNER JOIN pgml.deployments d ON d.project_id = p.id
AND d.model_id = m.id
INNER JOIN pgml.snapshots s ON s.id = m.snapshot_id
ORDER BY d.created_at DESC;


---
--- List details of trained models.
---
DROP VIEW IF EXISTS pgml.trained_models;
CREATE VIEW pgml.trained_models AS
SELECT
	m.id,	
	p.name,
	p.task,
	m.algorithm,
	m.runtime,
	m.created_at,
	s.test_sampling,
	s.test_size,
	d.model_id IS NOT NULL AS deployed
FROM pgml.projects p
INNER JOIN pgml.models m ON p.id = m.project_id
INNER JOIN pgml.snapshots s ON s.id = m.snapshot_id
LEFT JOIN (
	SELECT DISTINCT ON(project_id)
		project_id, model_id, created_at
	FROM pgml.deployments
	ORDER BY project_id, created_at desc
) d ON d.model_id = m.id
ORDER BY m.created_at DESC;


---
--- List details of deployed models.
---
DROP VIEW IF EXISTS pgml.deployed_models;
CREATE VIEW pgml.deployed_models AS
SELECT
	m.id,
	p.name,
	p.task,
	m.algorithm,
	m.runtime,
	d.created_at as deployed_at 
FROM pgml.projects p
INNER JOIN (
	SELECT DISTINCT ON(project_id)
		project_id, model_id, created_at
	FROM pgml.deployments
	ORDER BY project_id, created_at desc
) d ON d.project_id = p.id
INNER JOIN pgml.models m ON m.id = d.model_id
ORDER BY p.name ASC;

