@@ -54,14 +54,14 @@ pub async fn create_dataset_from_snapshot_impl(
5454 // Validate / resolve events
5555 for event in snapshot. metadata . iter_mut ( ) {
5656 match event {
57- MetadataEvent :: Seed ( _) => Err ( InvalidSnapshotError {
58- reason : "Seed event is generated and cannot be specified explicitly" . to_owned ( ) ,
59- }
57+ MetadataEvent :: Seed ( _) => Err ( InvalidSnapshotError :: new (
58+ "Seed event is generated and cannot be specified explicitly" ,
59+ )
6060 . into ( ) ) ,
61- MetadataEvent :: SetPollingSource ( _) => {
61+ MetadataEvent :: SetPollingSource ( _) | MetadataEvent :: AddPushSource ( _ ) => {
6262 if snapshot. kind != DatasetKind :: Root {
6363 Err ( InvalidSnapshotError {
64- reason : "SetPollingSource is only allowed on root datasets" . to_owned ( ) ,
64+ reason : format ! ( "Event is only allowed on root datasets: {:?}" , event ) ,
6565 }
6666 . into ( ) )
6767 } else {
@@ -70,26 +70,32 @@ pub async fn create_dataset_from_snapshot_impl(
7070 }
7171 MetadataEvent :: SetTransform ( e) => {
7272 if snapshot. kind != DatasetKind :: Derivative {
73- Err ( InvalidSnapshotError {
74- reason : "SetTransform is only allowed on derivative datasets" . to_owned ( ) ,
75- }
73+ Err ( InvalidSnapshotError :: new (
74+ "SetTransform is only allowed on derivative datasets" ,
75+ )
7676 . into ( ) )
7777 } else {
7878 resolve_transform_inputs ( dataset_repo, & snapshot. name , & mut e. inputs ) . await
7979 }
8080 }
81+ MetadataEvent :: SetDataSchema ( _) => {
82+ // It shouldn't be common to provide schema as part of the snapshot. In most
83+ // cases it will inferred upon first ingest/transform. But no reason not to
84+ // allow it.
85+ Ok ( ( ) )
86+ }
8187 MetadataEvent :: SetAttachments ( _)
8288 | MetadataEvent :: SetInfo ( _)
8389 | MetadataEvent :: SetLicense ( _)
8490 | MetadataEvent :: SetVocab ( _) => Ok ( ( ) ) ,
8591 MetadataEvent :: AddData ( _)
8692 | MetadataEvent :: ExecuteQuery ( _)
87- | MetadataEvent :: SetWatermark ( _) => Err ( InvalidSnapshotError {
88- reason : format ! (
89- "Event is not allowed to appear in a DatasetSnapshot: {:?}" ,
90- event
91- ) ,
92- }
93+ | MetadataEvent :: SetWatermark ( _)
94+ | MetadataEvent :: DisablePollingSource ( _ )
95+ | MetadataEvent :: DisablePushSource ( _ ) => Err ( InvalidSnapshotError :: new ( format ! (
96+ "Event is not allowed to appear in a DatasetSnapshot: {:?}" ,
97+ event
98+ ) )
9399 . into ( ) ) ,
94100 } ?;
95101 }
0 commit comments