Skip to content

Commit

Permalink
agent: rename SourceCapture's schemaMode to targetSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
mdibaiee committed Sep 19, 2024
1 parent 1c40d8b commit 7c12245
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ expression: schema
],
"type": "object"
},
"Capture": {
"description": "Capture names are paths of Unicode letters, numbers, '-', '_', or '.'. Each path component is separated by a slash '/', and a name may not begin or end in a '/'.",
"examples": [
"acmeCo/capture"
],
"pattern": "^[\\p{Letter}\\p{Number}\\-_\\.]+(/[\\p{Letter}\\p{Number}\\-_\\.]+)*$",
"type": "string"
},
"Collection": {
"description": "Collection names are paths of Unicode letters, numbers, '-', '_', or '.'. Each path component is separated by a slash '/', and a name may not begin or end in a '/'.",
"examples": [
Expand Down Expand Up @@ -402,47 +394,6 @@ expression: schema
],
"type": "object"
},
"SourceCaptureDef": {
"additionalProperties": false,
"description": "SourceCaptureDef specifies configuration for source captures",
"properties": {
"capture": {
"$ref": "#/definitions/Capture",
"description": "Capture name"
},
"deltaUpdates": {
"description": "When adding new bindings from a source capture to a materialization, should the new bindings be marked as delta updates",
"type": "boolean"
},
"schemaMode": {
"$ref": "#/definitions/SourceCaptureSchemaMode",
"default": "leaveEmpty",
"description": "When adding new bindings from a source capture to a materialization, how should the schema of the materialization binding be set"
}
},
"required": [
"capture"
],
"type": "object"
},
"SourceCaptureSchemaMode": {
"oneOf": [
{
"description": "Leave the materialization binding's schema field empty, therefore falling back to the default schema of the materialization",
"enum": [
"leaveEmpty"
],
"type": "string"
},
{
"description": "Use the 2nd-to-last component of the collection name as the schema of the materialization binding",
"enum": [
"collectionSchema"
],
"type": "string"
}
]
},
"SourceCaptureStatus": {
"description": "Status information about the `sourceCapture`",
"properties": {
Expand All @@ -454,17 +405,11 @@ expression: schema
"type": "array",
"uniqueItems": true
},
"source_capture": {
"$ref": "#/definitions/SourceCaptureDef"
},
"up_to_date": {
"description": "Whether the materialization bindings are up-to-date with respect to the `sourceCapture` bindings. In normal operation, this should always be `true`. Otherwise, there will be a controller `error` and the publication status will contain details of why the update failed.",
"type": "boolean"
}
},
"required": [
"source_capture"
],
"type": "object"
}
},
Expand Down
2 changes: 1 addition & 1 deletion crates/agent/src/integration_tests/source_captures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async fn test_source_captures_collection_name() {
"ducks/materializeA": {
"sourceCapture": {
"capture": "ducks/capture",
"schemaMode": "collectionSchema",
"targetSchema": "fromSourceName",
"deltaUpdates": true,
},
"endpoint": {
Expand Down
4 changes: 2 additions & 2 deletions crates/agent/src/resource_configs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use models::{SourceCaptureSchemaMode, SourceCapture, SourceCaptureDef};
use models::{SourceCaptureSchemaMode, SourceCapture};
use serde_json::Value;

///
Expand Down Expand Up @@ -35,7 +35,7 @@ pub fn update_materialization_resource_spec(

let source_capture_def = source_capture.to_normalized_def();

if source_capture_def.schema_mode == SourceCaptureSchemaMode::CollectionSchema {
if source_capture_def.target_schema == SourceCaptureSchemaMode::FromSourceName {
if let Some(x_schema_name_ptr) = &resource_spec_pointers.x_schema_name {
if let Some(x_schema_name_prev) = x_schema_name_ptr.create_value(resource_spec) {
let _ = std::mem::replace(x_schema_name_prev, x_schema_name.into());
Expand Down
4 changes: 2 additions & 2 deletions crates/models/src/source_capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum SourceCaptureSchemaMode {
LeaveEmpty,
/// Use the 2nd-to-last component of the collection name as the schema of the materialization
/// binding
CollectionSchema,
FromSourceName,
}

impl Default for SourceCaptureSchemaMode {
Expand All @@ -29,7 +29,7 @@ pub struct SourceCaptureDef {
/// When adding new bindings from a source capture to a materialization, how should the schema
/// of the materialization binding be set
#[serde(default, skip_serializing_if = "super::is_default")]
pub schema_mode: SourceCaptureSchemaMode,
pub target_schema: SourceCaptureSchemaMode,

/// When adding new bindings from a source capture to a materialization, should the new
/// bindings be marked as delta updates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ expression: "&schema"
},
"sourceCapture": {
"title": "Automatically materialize new bindings from a named capture",
"$ref": "#/definitions/Capture"
"$ref": "#/definitions/SourceCapture"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -1217,6 +1217,56 @@ expression: "&schema"
}
]
},
"SourceCapture": {
"anyOf": [
{
"$ref": "#/definitions/Capture"
},
{
"$ref": "#/definitions/SourceCaptureDef"
}
]
},
"SourceCaptureDef": {
"description": "SourceCaptureDef specifies configuration for source captures",
"type": "object",
"required": [
"capture"
],
"properties": {
"capture": {
"description": "Capture name",
"$ref": "#/definitions/Capture"
},
"deltaUpdates": {
"description": "When adding new bindings from a source capture to a materialization, should the new bindings be marked as delta updates",
"type": "boolean"
},
"targetSchema": {
"description": "When adding new bindings from a source capture to a materialization, how should the schema of the materialization binding be set",
"$ref": "#/definitions/SourceCaptureSchemaMode"
}
},
"additionalProperties": false
},
"SourceCaptureSchemaMode": {
"oneOf": [
{
"description": "Leave the materialization binding's schema field empty, therefore falling back to the default schema of the materialization",
"type": "string",
"enum": [
"leaveEmpty"
]
},
{
"description": "Use the 2nd-to-last component of the collection name as the schema of the materialization binding",
"type": "string",
"enum": [
"fromSourceName"
]
}
]
},
"Test": {
"description": "Test names are paths of Unicode letters, numbers, '-', '_', or '.'. Each path component is separated by a slash '/', and a name may not begin or end in a '/'.",
"examples": [
Expand Down
52 changes: 51 additions & 1 deletion flow.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@
},
"sourceCapture": {
"title": "Automatically materialize new bindings from a named capture",
"$ref": "#/definitions/Capture"
"$ref": "#/definitions/SourceCapture"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -1213,6 +1213,56 @@
}
]
},
"SourceCapture": {
"anyOf": [
{
"$ref": "#/definitions/Capture"
},
{
"$ref": "#/definitions/SourceCaptureDef"
}
]
},
"SourceCaptureDef": {
"description": "SourceCaptureDef specifies configuration for source captures",
"type": "object",
"required": [
"capture"
],
"properties": {
"capture": {
"description": "Capture name",
"$ref": "#/definitions/Capture"
},
"deltaUpdates": {
"description": "When adding new bindings from a source capture to a materialization, should the new bindings be marked as delta updates",
"type": "boolean"
},
"targetSchema": {
"description": "When adding new bindings from a source capture to a materialization, how should the schema of the materialization binding be set",
"$ref": "#/definitions/SourceCaptureSchemaMode"
}
},
"additionalProperties": false
},
"SourceCaptureSchemaMode": {
"oneOf": [
{
"description": "Leave the materialization binding's schema field empty, therefore falling back to the default schema of the materialization",
"type": "string",
"enum": [
"leaveEmpty"
]
},
{
"description": "Use the 2nd-to-last component of the collection name as the schema of the materialization binding",
"type": "string",
"enum": [
"fromSourceName"
]
}
]
},
"Test": {
"description": "Test names are paths of Unicode letters, numbers, '-', '_', or '.'. Each path component is separated by a slash '/', and a name may not begin or end in a '/'.",
"examples": [
Expand Down

0 comments on commit 7c12245

Please sign in to comment.