Skip to content

Fix #1326 #1328

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions pgml-extension/src/orm/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<AnyNumeric>, TryFromDatumError> = tuple.get_by_index(index);
let element: Result<Option<AnyNumeric>, TryFromDatumError> =
tuple.get_by_index(index);
element
.unwrap()
.map_or(snapshot::NULL_CATEGORY_KEY.to_string(), |k| k.to_string())
Expand Down Expand Up @@ -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<Option<AnyNumeric>, TryFromDatumError> = tuple.get_by_index(index);
let element: Result<Option<AnyNumeric>, 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
Expand Down
24 changes: 20 additions & 4 deletions pgml-extension/src/orm/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ impl Snapshot {
.map(|c| c.quoted_name())
.collect::<Vec<String>>()
.join(", "),
self.relation_name(),
self.relation_name_quoted(),
match self.materialized {
// If the snapshot is materialized, we already randomized it.
true => "",
Expand Down Expand Up @@ -990,7 +990,10 @@ impl Snapshot {
"int8" => row[column.position].value::<i64>().unwrap().map(|v| v.to_string()),
"float4" => row[column.position].value::<f32>().unwrap().map(|v| v.to_string()),
"float8" => row[column.position].value::<f64>().unwrap().map(|v| v.to_string()),
"numeric" => row[column.position].value::<AnyNumeric>().unwrap().map(|v| v.to_string()),
"numeric" => row[column.position]
.value::<AnyNumeric>()
.unwrap()
.map(|v| v.to_string()),
"bpchar" | "text" | "varchar" => {
row[column.position].value::<String>().unwrap().map(|v| v.to_string())
}
Expand Down Expand Up @@ -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!(
Expand All @@ -1101,7 +1104,10 @@ impl Snapshot {
"int8" => row[column.position].value::<i64>().unwrap().map(|v| v as f32),
"float4" => row[column.position].value::<f32>().unwrap(),
"float8" => row[column.position].value::<f64>().unwrap().map(|v| v as f32),
"numeric" => row[column.position].value::<AnyNumeric>().unwrap().map(|v| v.rescale::<6,0>().unwrap().try_into().unwrap()),
"numeric" => row[column.position]
.value::<AnyNumeric>()
.unwrap()
.map(|v| v.rescale::<6, 0>().unwrap().try_into().unwrap()),
_ => error!(
"Unhandled type for quantitative scalar column: {} {:?}",
column.name, column.pg_type
Expand Down Expand Up @@ -1156,6 +1162,16 @@ impl Snapshot {
false => self.relation_name.clone(),
}
}

fn relation_name_quoted(&self) -> String {
match self.materialized {
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)
}
}
}
}

#[inline]
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy