Content-Length: 6578 | pFad | http://github.com/postgresml/postgresml/pull/1328.patch

thub.com From 7a122851864834190f5d7157b8827a05be7eb1ee Mon Sep 17 00:00:00 2001 From: Lev Date: Fri, 23 Feb 2024 09:45:48 -0800 Subject: [PATCH 1/2] Fix #1326 --- pgml-extension/src/orm/model.rs | 6 ++++-- pgml-extension/src/orm/snapshot.rs | 24 ++++++++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/pgml-extension/src/orm/model.rs b/pgml-extension/src/orm/model.rs index 0750c534e..5d1aadbde 100644 --- a/pgml-extension/src/orm/model.rs +++ b/pgml-extension/src/orm/model.rs @@ -955,7 +955,8 @@ impl Model { .map_or(snapshot::NULL_CATEGORY_KEY.to_string(), |k| k.to_string()) } pgrx_pg_sys::NUMERICOID => { - let element: Result, TryFromDatumError> = tuple.get_by_index(index); + let element: Result, TryFromDatumError> = + tuple.get_by_index(index); element .unwrap() .map_or(snapshot::NULL_CATEGORY_KEY.to_string(), |k| k.to_string()) @@ -999,7 +1000,8 @@ impl Model { features.push(element.unwrap().map_or(f32::NAN, |v| v as f32)); } pgrx_pg_sys::NUMERICOID => { - let element: Result, TryFromDatumError> = tuple.get_by_index(index); + let element: Result, TryFromDatumError> = + tuple.get_by_index(index); features.push(element.unwrap().map_or(f32::NAN, |v| v.try_into().unwrap())); } // TODO handle NULL to NaN for arrays diff --git a/pgml-extension/src/orm/snapshot.rs b/pgml-extension/src/orm/snapshot.rs index 1bc27911c..3e39487df 100644 --- a/pgml-extension/src/orm/snapshot.rs +++ b/pgml-extension/src/orm/snapshot.rs @@ -749,7 +749,7 @@ impl Snapshot { .map(|c| c.quoted_name()) .collect::>() .join(", "), - self.relation_name(), + self.relation_name_quoted(), match self.materialized { // If the snapshot is materialized, we already randomized it. true => "", @@ -990,7 +990,10 @@ impl Snapshot { "int8" => row[column.position].value::().unwrap().map(|v| v.to_string()), "float4" => row[column.position].value::().unwrap().map(|v| v.to_string()), "float8" => row[column.position].value::().unwrap().map(|v| v.to_string()), - "numeric" => row[column.position].value::().unwrap().map(|v| v.to_string()), + "numeric" => row[column.position] + .value::() + .unwrap() + .map(|v| v.to_string()), "bpchar" | "text" | "varchar" => { row[column.position].value::().unwrap().map(|v| v.to_string()) } @@ -1084,7 +1087,7 @@ impl Snapshot { check_column_size(column, vec.len()); for j in vec { - vector.push(j.rescale::<6,0>().unwrap().try_into().unwrap()) + vector.push(j.rescale::<6, 0>().unwrap().try_into().unwrap()) } } _ => error!( @@ -1101,7 +1104,10 @@ impl Snapshot { "int8" => row[column.position].value::().unwrap().map(|v| v as f32), "float4" => row[column.position].value::().unwrap(), "float8" => row[column.position].value::().unwrap().map(|v| v as f32), - "numeric" => row[column.position].value::().unwrap().map(|v| v.rescale::<6,0>().unwrap().try_into().unwrap()), + "numeric" => row[column.position] + .value::() + .unwrap() + .map(|v| v.rescale::<6, 0>().unwrap().try_into().unwrap()), _ => error!( "Unhandled type for quantitative scalar column: {} {:?}", column.name, column.pg_type @@ -1156,6 +1162,16 @@ impl Snapshot { false => self.relation_name.clone(), } } + + fn relation_name_quoted(&self) -> String { + match self.materialized { + true => format!("\"{}\"", self.snapshot_name()), + false => { + let (schema_name, table_name) = Self::fully_qualified_table(&self.relation_name); + format!("\"{}\".\"{}\"", schema_name, table_name) + } + } + } } #[inline] From fea5394100bb1842f725fe691a6b777e9682c627 Mon Sep 17 00:00:00 2001 From: Lev Date: Fri, 23 Feb 2024 10:00:24 -0800 Subject: [PATCH 2/2] Fix test --- pgml-extension/src/orm/snapshot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgml-extension/src/orm/snapshot.rs b/pgml-extension/src/orm/snapshot.rs index 3e39487df..1cecd2a8c 100644 --- a/pgml-extension/src/orm/snapshot.rs +++ b/pgml-extension/src/orm/snapshot.rs @@ -1165,7 +1165,7 @@ impl Snapshot { fn relation_name_quoted(&self) -> String { match self.materialized { - true => format!("\"{}\"", self.snapshot_name()), + true => self.snapshot_name(), // Snapshot name is already safe. false => { let (schema_name, table_name) = Self::fully_qualified_table(&self.relation_name); format!("\"{}\".\"{}\"", schema_name, table_name)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgresml/postgresml/pull/1328.patch

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy