Skip to content

Commit 783fef7

Browse files
authored
feat: add column update_on for user functions table (#19018)
* feat: add column update_on for user functions table * chore: codefmt * chore: codefmt * chore: codefmt * fix: create_on on bind_alter_udf * chore: codefmt * fix: 05_0013_ddl_alter_udf * chore: codefmt
1 parent 72faddb commit 783fef7

File tree

22 files changed

+138
-14
lines changed

22 files changed

+138
-14
lines changed

src/meta/app/src/principal/user_defined_function.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ pub struct UserDefinedFunction {
159159
pub description: String,
160160
pub definition: UDFDefinition,
161161
pub created_on: DateTime<Utc>,
162+
pub update_on: DateTime<Utc>,
162163
}
163164

164165
impl UserDefinedFunction {
@@ -168,14 +169,16 @@ impl UserDefinedFunction {
168169
definition: &str,
169170
description: &str,
170171
) -> Self {
172+
let now = Utc::now();
171173
Self {
172174
name: name.to_string(),
173175
description: description.to_string(),
174176
definition: UDFDefinition::LambdaUDF(LambdaUDF {
175177
parameters,
176178
definition: definition.to_string(),
177179
}),
178-
created_on: Utc::now(),
180+
created_on: now,
181+
update_on: now,
179182
}
180183
}
181184

@@ -191,6 +194,7 @@ impl UserDefinedFunction {
191194
description: &str,
192195
immutable: Option<bool>,
193196
) -> Self {
197+
let now = Utc::now();
194198
Self {
195199
name: name.to_string(),
196200
description: description.to_string(),
@@ -204,7 +208,8 @@ impl UserDefinedFunction {
204208
return_type,
205209
immutable,
206210
}),
207-
created_on: Utc::now(),
211+
created_on: now,
212+
update_on: now,
208213
}
209214
}
210215

@@ -219,6 +224,7 @@ impl UserDefinedFunction {
219224
description: &str,
220225
immutable: Option<bool>,
221226
) -> Self {
227+
let now = Utc::now();
222228
Self {
223229
name: name.to_string(),
224230
description: description.to_string(),
@@ -233,7 +239,8 @@ impl UserDefinedFunction {
233239
packages: vec![],
234240
immutable,
235241
}),
236-
created_on: Utc::now(),
242+
created_on: now,
243+
update_on: now,
237244
}
238245
}
239246

src/meta/proto-conv/src/udf_from_to_protobuf_impl.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,14 +546,21 @@ impl FromToProto for mt::UserDefinedFunction {
546546
}
547547
};
548548

549+
let created_on = match p.created_on {
550+
Some(c) => DateTime::<Utc>::from_pb(c)?,
551+
None => DateTime::<Utc>::default(),
552+
};
553+
let update_on = match p.update_on {
554+
Some(u) => DateTime::<Utc>::from_pb(u)?,
555+
None => created_on,
556+
};
557+
549558
Ok(mt::UserDefinedFunction {
550559
name: p.name,
551560
description: p.description,
552561
definition: udf_def,
553-
created_on: match p.created_on {
554-
Some(c) => DateTime::<Utc>::from_pb(c)?,
555-
None => DateTime::<Utc>::default(),
556-
},
562+
created_on,
563+
update_on,
557564
})
558565
}
559566

@@ -589,6 +596,7 @@ impl FromToProto for mt::UserDefinedFunction {
589596
description: self.description.clone(),
590597
definition: Some(udf_def),
591598
created_on: Some(self.created_on.to_pb()?),
599+
update_on: Some(self.update_on.to_pb()?),
592600
})
593601
}
594602
}

src/meta/proto-conv/src/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ const META_CHANGE_LOG: &[(u64, &str)] = &[
189189
(157, "2025-10-22: Add: TableDataType TimestampTz"),
190190
(158, "2025-10-22: Add: Server UDTF"),
191191
(159, "2025-11-18: Add: Grant/OwnershipMaskingPolicyObject and masking policy privileges"),
192+
(160, "2025-11-27: Add: udf.proto/UserDefinedFunction add update_on field"),
192193
// Dear developer:
193194
// If you're gonna add a new metadata version, you'll have to add a test for it.
194195
// You could just copy an existing test file(e.g., `../tests/it/v024_table_meta.rs`)

src/meta/proto-conv/tests/it/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,4 @@ mod v156_data_mask_args;
151151
mod v157_type_timestamp_tz;
152152
mod v158_udtf_server;
153153
mod v159_grant_object_masking_policy;
154+
mod v160_udf_update_on;

src/meta/proto-conv/tests/it/v058_udf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ fn test_decode_v57_udf() -> anyhow::Result<()> {
6464
immutable: None,
6565
}),
6666
created_on: DateTime::<Utc>::default(),
67+
update_on: DateTime::<Utc>::default(),
6768
};
6869

6970
common::test_pb_from_to(func_name!(), want())?;

src/meta/proto-conv/tests/it/v079_udf_created_on.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ fn test_decode_v79_udf_python() -> anyhow::Result<()> {
6767
immutable: None,
6868
}),
6969
created_on: DateTime::<Utc>::from_timestamp(1702603569, 0).unwrap(),
70+
update_on: DateTime::<Utc>::from_timestamp(1702603569, 0).unwrap(),
7071
};
7172

7273
common::test_pb_from_to(func_name!(), want())?;
@@ -91,6 +92,7 @@ fn test_decode_v79_udf_sql() -> anyhow::Result<()> {
9192
definition: "(p) -> (NOT is_null(p))".to_string(),
9293
}),
9394
created_on: DateTime::<Utc>::from_timestamp(170267984, 0).unwrap(),
95+
update_on: DateTime::<Utc>::from_timestamp(170267984, 0).unwrap(),
9496
};
9597

9698
common::test_pb_from_to(func_name!(), want())?;

src/meta/proto-conv/tests/it/v081_udf_script.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fn test_decode_v81_udf_python() -> anyhow::Result<()> {
6868
immutable: None,
6969
}),
7070
created_on: DateTime::<Utc>::from_timestamp(1702603569, 0).unwrap(),
71+
update_on: DateTime::<Utc>::from_timestamp(1702603569, 0).unwrap(),
7172
};
7273

7374
common::test_pb_from_to(func_name!(), want())?;
@@ -91,6 +92,7 @@ fn test_decode_v81_udf_sql() -> anyhow::Result<()> {
9192
definition: "(p) -> (NOT is_null(p))".to_string(),
9293
}),
9394
created_on: DateTime::<Utc>::from_timestamp(170267984, 0).unwrap(),
95+
update_on: DateTime::<Utc>::from_timestamp(170267984, 0).unwrap(),
9496
};
9597

9698
common::test_pb_from_to(func_name!(), want())?;
@@ -124,6 +126,7 @@ fn test_decode_udf_script() -> anyhow::Result<()> {
124126
immutable: None,
125127
}),
126128
created_on: DateTime::<Utc>::default(),
129+
update_on: DateTime::<Utc>::default(),
127130
};
128131

129132
common::test_pb_from_to(func_name!(), want())?;

src/meta/proto-conv/tests/it/v115_add_udaf_script.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fn test_decode_v115_add_udaf_script() -> anyhow::Result<()> {
6565
packages: vec![],
6666
}),
6767
created_on: DateTime::<Utc>::default(),
68+
update_on: DateTime::<Utc>::default(),
6869
};
6970

7071
common::test_pb_from_to(func_name!(), want())?;

src/meta/proto-conv/tests/it/v130_udf_imports_packages.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fn test_decode_v130_udf_script() -> anyhow::Result<()> {
6262
immutable: None,
6363
}),
6464
created_on: DateTime::<Utc>::default(),
65+
update_on: DateTime::<Utc>::default(),
6566
};
6667

6768
common::test_pb_from_to(func_name!(), want())?;

src/meta/proto-conv/tests/it/v135_udf_immutable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ fn test_decode_v135_udf_server() -> anyhow::Result<()> {
6666
immutable: Some(true),
6767
}),
6868
created_on: DateTime::<Utc>::default(),
69+
update_on: DateTime::<Utc>::default(),
6970
};
7071

7172
common::test_pb_from_to(func_name!(), want())?;
@@ -101,6 +102,7 @@ fn test_decode_v135_udf_script() -> anyhow::Result<()> {
101102
immutable: Some(true),
102103
}),
103104
created_on: DateTime::<Utc>::default(),
105+
update_on: DateTime::<Utc>::default(),
104106
};
105107

106108
common::test_pb_from_to(func_name!(), want())?;

0 commit comments

Comments
 (0)