Skip to content

Commit 597bae5

Browse files
ajhlee-dbtfa-assistant
authored andcommitted
[Adapters] [Redshift] Fix macro crash with empty column comment for persist_docs (#5765)
* Serialize dbt column description with default for None case * Add changelog * Rerecord affected tests GitOrigin-RevId: c2bfbf0ce7bc16f4d5e1dd398f489e6d39b6f449
1 parent 81e5d98 commit 597bae5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

crates/dbt-schemas/src/schemas/dbt_column.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{collections::BTreeMap, sync::Arc};
22

33
use dbt_common::FsResult;
44
use dbt_serde_yaml::JsonSchema;
5-
use serde::{Deserialize, Serialize};
5+
use serde::{Deserialize, Serialize, Serializer};
66
use serde_with::skip_serializing_none;
77

88
// Type aliases for clarity
@@ -20,6 +20,8 @@ use super::{common::Constraint, data_tests::DataTests};
2020
pub struct DbtColumn {
2121
pub name: String,
2222
pub data_type: Option<String>,
23+
#[serialize_always]
24+
#[serde(serialize_with = "serialize_dbt_column_desc")]
2325
pub description: Option<String>,
2426
pub constraints: Vec<Constraint>,
2527
pub meta: BTreeMap<String, YmlValue>,
@@ -30,6 +32,13 @@ pub struct DbtColumn {
3032
pub deprecated_config: ColumnConfig,
3133
}
3234

35+
fn serialize_dbt_column_desc<S>(description: &Option<String>, s: S) -> Result<S::Ok, S::Error>
36+
where
37+
S: Serializer,
38+
{
39+
s.serialize_str(description.as_deref().unwrap_or(""))
40+
}
41+
3342
pub type DbtColumnRef = Arc<DbtColumn>;
3443

3544
#[skip_serializing_none]

0 commit comments

Comments
 (0)