Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mutable SQL commands should be used with Spi::update().#1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
montanalow merged 1 commit intopostgresml:masterfromhiguoxing:fix-spi-call
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionpgml-extension/src/orm/dataset.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -95,7 +95,7 @@ impl Display for TextDataset {
fn drop_table_if_exists(table_name: &str) {
// Avoid the existence for DROP TABLE IF EXISTS warning by checking the schema for the table first
let table_count = Spi::get_one_with_args::<i64>("SELECT COUNT(*) FROM information_schema.tables WHERE table_name = $1 AND table_schema = 'pgml'", vec![
(PgBuiltInOids::TEXTOID.oid(), table_name.clone().into_datum())
(PgBuiltInOids::TEXTOID.oid(), table_name.into_datum())
]).unwrap().unwrap();
if table_count == 1 {
Spi::run(&format!(r#"DROP TABLE pgml.{table_name} CASCADE"#)).unwrap();
Expand Down
8 changes: 4 additions & 4 deletionspgml-extension/src/orm/model.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,8 +96,8 @@ impl Model {
let dataset = snapshot.tabular_dataset();
let status = Status::in_progress;
// Create the model record.
Spi::connect(|client| {
let result = client.select("
Spi::connect(|mutclient| {
let result = client.update("
INSERT INTO pgml.models (project_id, snapshot_id, algorithm, runtime, hyperparams, status, search, search_params, search_args, num_features)
VALUES ($1, $2, cast($3 AS pgml.algorithm), cast($4 AS pgml.runtime), $5, cast($6 as pgml.status), $7, $8, $9, $10)
RETURNING id, project_id, snapshot_id, algorithm, runtime, hyperparams, status, metrics, search, search_params, search_args, created_at, updated_at;",
Expand DownExpand Up@@ -168,8 +168,8 @@ impl Model {
let dataset = snapshot.text_dataset();

// Create the model record.
Spi::connect(|client| {
let result = client.select("
Spi::connect(|mutclient| {
let result = client.update("
INSERT INTO pgml.models (project_id, snapshot_id, algorithm, runtime, hyperparams, status, search, search_params, search_args, num_features)
VALUES ($1, $2, cast($3 AS pgml.algorithm), cast($4 AS pgml.runtime), $5, cast($6 as pgml.status), $7, $8, $9, $10)
RETURNING id, project_id, snapshot_id, algorithm, runtime::TEXT, hyperparams, status, metrics, search, search_params, search_args, created_at, updated_at;",
Expand Down
6 changes: 3 additions & 3 deletionspgml-extension/src/orm/snapshot.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -508,7 +508,7 @@ impl Snapshot {
let preprocessors: HashMap<String, Preprocessor> =
serde_json::from_value(preprocess.0).expect("is valid");

Spi::connect(|client| {
Spi::connect(|mutclient| {
let mut columns: Vec<Column> = Vec::new();
client.select("SELECT column_name::TEXT, udt_name::TEXT, is_nullable::BOOLEAN, ordinal_position::INTEGER FROM information_schema.columns WHERE table_schema = $1 AND table_name = $2 ORDER BY ordinal_position ASC",
None,
Expand DownExpand Up@@ -587,7 +587,7 @@ impl Snapshot {
}
}

let result = client.select("INSERT INTO pgml.snapshots (relation_name, y_column_name, test_size, test_sampling, status, columns, materialized) VALUES ($1, $2, $3, $4::pgml.sampling, $5::pgml.status, $6, $7) RETURNING id, relation_name, y_column_name, test_size, test_sampling::TEXT, status::TEXT, columns, analysis, created_at, updated_at;",
let result = client.update("INSERT INTO pgml.snapshots (relation_name, y_column_name, test_size, test_sampling, status, columns, materialized) VALUES ($1, $2, $3, $4::pgml.sampling, $5::pgml.status, $6, $7) RETURNING id, relation_name, y_column_name, test_size, test_sampling::TEXT, status::TEXT, columns, analysis, created_at, updated_at;",
Some(1),
Some(vec![
(PgBuiltInOids::TEXTOID.oid(), relation_name.into_datum()),
Expand DownExpand Up@@ -623,7 +623,7 @@ impl Snapshot {
if s.test_sampling == Sampling::random {
sql += " ORDER BY random()";
}
client.select(&sql, None, None).unwrap();
client.update(&sql, None, None).unwrap();
}
snapshot = Some(s);
});
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp