Skip to content

Commit 6a091cd

Browse files
committed
fix: keep key types only without field names
1 parent 41099c3 commit 6a091cd

File tree

8 files changed

+24
-19
lines changed

8 files changed

+24
-19
lines changed

src/builder/analyzer.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ fn add_collector(
643643
struct ExportDataFieldsInfo {
644644
local_collector_ref: AnalyzedLocalCollectorReference,
645645
primary_key_def: AnalyzedPrimaryKeyDef,
646-
primary_key_schema: Arc<[FieldSchema]>,
646+
primary_key_schema: Box<[FieldSchema]>,
647647
value_fields_idx: Vec<u32>,
648648
value_stable: bool,
649649
}
@@ -852,7 +852,7 @@ impl AnalyzerContext {
852852
let primary_key_schema = pk_fields_idx
853853
.iter()
854854
.map(|idx| collector_schema.fields[*idx].without_attrs())
855-
.collect::<Arc<[_]>>();
855+
.collect::<Box<[_]>>();
856856
let mut value_fields_schema: Vec<FieldSchema> = vec![];
857857
let mut value_fields_idx = vec![];
858858
for (idx, field) in collector_schema.fields.iter().enumerate() {
@@ -911,7 +911,13 @@ impl AnalyzerContext {
911911
setup_key: data_coll_output.setup_key,
912912
desired_setup_state: data_coll_output.desired_setup_state,
913913
setup_by_user: export_op.spec.setup_by_user,
914-
key_schema: Some(data_fields_info.primary_key_schema.clone()),
914+
key_type: Some(
915+
data_fields_info
916+
.primary_key_schema
917+
.iter()
918+
.map(|field| field.value_type.typ.clone())
919+
.collect::<Box<[_]>>(),
920+
),
915921
};
916922
targets_analyzed_ss[*idx] = Some(export_op_ss);
917923

@@ -941,7 +947,7 @@ impl AnalyzerContext {
941947
setup_key,
942948
desired_setup_state,
943949
setup_by_user: false,
944-
key_schema: None,
950+
key_type: None,
945951
};
946952
declarations_analyzed_ss.push(decl_ss);
947953
}

src/builder/exec_ctx.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct AnalyzedTargetSetupState {
2424
pub desired_setup_state: serde_json::Value,
2525
pub setup_by_user: bool,
2626
/// None for declarations.
27-
pub key_schema: Option<Arc<[schema::FieldSchema]>>,
27+
pub key_type: Option<Box<[schema::ValueType]>>,
2828
}
2929

3030
pub struct AnalyzedSetupState {
@@ -123,9 +123,9 @@ fn build_target_id(
123123
let mut compatible_target_ids = HashSet::<Option<i32>>::new();
124124
let mut reusable_schema_version_ids = HashSet::<Option<i32>>::new();
125125
for existing_state in existing_target_states.iter().flat_map(|v| v.iter()) {
126-
let compatibility = if let Some(key_schema) = &analyzed_target_ss.key_schema
127-
&& let Some(existing_key_schema) = &existing_state.common.key_schema
128-
&& key_schema != existing_key_schema
126+
let compatibility = if let Some(key_type) = &analyzed_target_ss.key_type
127+
&& let Some(existing_key_type) = &existing_state.common.key_type
128+
&& key_type != existing_key_type
129129
{
130130
SetupStateCompatibility::NotCompatible
131131
} else if analyzed_target_ss.setup_by_user != existing_state.common.setup_by_user {
@@ -190,7 +190,7 @@ fn build_target_id(
190190
schema_version_id,
191191
max_schema_version_id: max_schema_version_id.max(schema_version_id),
192192
setup_by_user: analyzed_target_ss.setup_by_user,
193-
key_schema: analyzed_target_ss.key_schema.clone(),
193+
key_type: analyzed_target_ss.key_type.clone(),
194194
},
195195
state: analyzed_target_ss.desired_setup_state.clone(),
196196
});

src/builder/plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub struct AnalyzedExportOp {
105105
pub export_target_factory: Arc<dyn TargetFactory + Send + Sync>,
106106
pub export_context: Arc<dyn Any + Send + Sync>,
107107
pub primary_key_def: AnalyzedPrimaryKeyDef,
108-
pub primary_key_schema: Arc<[FieldSchema]>,
108+
pub primary_key_schema: Box<[FieldSchema]>,
109109
/// idx for value fields - excluding the primary key field.
110110
pub value_fields: Vec<u32>,
111111
/// If true, value is never changed on the same primary key.

src/ops/factory_bases.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ pub struct TypedExportDataCollectionBuildOutput<F: TargetFactoryBase + ?Sized> {
363363
pub struct TypedExportDataCollectionSpec<F: TargetFactoryBase + ?Sized> {
364364
pub name: String,
365365
pub spec: F::Spec,
366-
pub key_fields_schema: Arc<[FieldSchema]>,
366+
pub key_fields_schema: Box<[FieldSchema]>,
367367
pub value_fields_schema: Vec<FieldSchema>,
368368
pub index_options: IndexOptions,
369369
}

src/ops/interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ pub struct ExportDataCollectionBuildOutput {
258258
pub struct ExportDataCollectionSpec {
259259
pub name: String,
260260
pub spec: serde_json::Value,
261-
pub key_fields_schema: Arc<[FieldSchema]>,
261+
pub key_fields_schema: Box<[FieldSchema]>,
262262
pub value_fields_schema: Vec<FieldSchema>,
263263
pub index_options: IndexOptions,
264264
}

src/ops/targets/postgres.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn bind_value_field<'arg>(
132132
pub struct ExportContext {
133133
db_ref: Option<spec::AuthEntryReference<DatabaseConnectionSpec>>,
134134
db_pool: PgPool,
135-
key_fields_schema: Vec<FieldSchema>,
135+
key_fields_schema: Box<[FieldSchema]>,
136136
value_fields_schema: Vec<FieldSchema>,
137137
upsert_sql_prefix: String,
138138
upsert_sql_suffix: String,
@@ -144,7 +144,7 @@ impl ExportContext {
144144
db_ref: Option<spec::AuthEntryReference<DatabaseConnectionSpec>>,
145145
db_pool: PgPool,
146146
table_name: String,
147-
key_fields_schema: Vec<FieldSchema>,
147+
key_fields_schema: Box<[FieldSchema]>,
148148
value_fields_schema: Vec<FieldSchema>,
149149
) -> Result<Self> {
150150
let key_fields = key_fields_schema
@@ -632,7 +632,7 @@ impl TargetFactoryBase for Factory {
632632
db_ref,
633633
db_pool.clone(),
634634
table_name,
635-
d.key_fields_schema.iter().cloned().collect(),
635+
d.key_fields_schema,
636636
d.value_fields_schema,
637637
)?);
638638
Ok(export_context)

src/ops/targets/shared/property_graph.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<AuthEntry> std::fmt::Display for GraphElementType<AuthEntry> {
112112

113113
pub struct GraphElementSchema {
114114
pub elem_type: ElementType,
115-
pub key_fields: Arc<[schema::FieldSchema]>,
115+
pub key_fields: Box<[schema::FieldSchema]>,
116116
pub value_fields: Vec<schema::FieldSchema>,
117117
}
118118

@@ -349,7 +349,7 @@ pub struct DataCollectionGraphMappingInput<'a, AuthEntry> {
349349
pub mapping: &'a GraphElementMapping,
350350
pub index_options: &'a spec::IndexOptions,
351351

352-
pub key_fields_schema: Arc<[FieldSchema]>,
352+
pub key_fields_schema: Box<[FieldSchema]>,
353353
pub value_fields_schema: Vec<FieldSchema>,
354354
}
355355

@@ -435,7 +435,6 @@ pub fn analyze_graph_mappings<'a, AuthEntry: 'a>(
435435
.key_fields_schema
436436
.into_iter()
437437
.enumerate()
438-
.map(|(idx, f)| (idx, f.clone()))
439438
.collect(),
440439
data_coll_input
441440
.value_fields_schema

src/setup/states.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub struct TargetSetupStateCommon {
181181
#[serde(default)]
182182
pub setup_by_user: bool,
183183
#[serde(default)]
184-
pub key_schema: Option<Arc<[schema::FieldSchema]>>,
184+
pub key_type: Option<Box<[schema::ValueType]>>,
185185
}
186186

187187
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]

0 commit comments

Comments
 (0)