Repository navigation
Schema conflict resolution #1821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7c96bfd
c414d87
3c7cb19
c491c3e
df5a206
0296b24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -485,9 +485,32 @@ pub async fn setup_logstream_metadata( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tenant_id.as_deref().unwrap_or(DEFAULT_TENANT), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let schema = PARSEABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .get_or_create_stream(stream, tenant_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .updated_schema(arrow_schema.clone()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let stream_ref = PARSEABLE.get_or_create_stream(stream, tenant_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Once a dataset is coordinated, its persisted schema uses canonical names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // while surviving IPC files still contain raw ingest names. Resolve each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // file independently before merging, rather than merging those raw types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // directly into the canonical schema during recovery. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Disabling bootstrap must not revert an already canonical dataset to raw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // conversion: existing coordinated streams still require their mappings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let schema = if PARSEABLE.options.mode == Mode::Ingest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| && !static_schema_flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| && PARSEABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .metastore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .get_global_schema(stream, tenant_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .await? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .is_some() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stream_ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .restore_global_schema( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| arrow_schema.clone(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tenant_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| time_partition.as_ref(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| custom_partition.as_ref(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .await? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stream_ref.updated_schema(arrow_schema.clone()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+495
to
+513
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
rg -nP -C4 '\bget_schema_raw\s*\(' --type=rust
rg -nP -C4 'fn\s+recordbatch_cloned\b' --type=rust
rg -nP -C6 'fn\s+(fields_mismatch|override_data_type|commit_schema)\b' --type=rustRepository: parseablehq/parseable Length of output: 7832 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- changed function and restore_global_schema references ---'
rg -n -C12 'setup_logstream_metadata|restore_global_schema' src/migration/mod.rs src/parseable src || true
printf '%s\n' '--- Stream schema methods and global schema state ---'
rg -n -C10 'fn (get_schema_raw|updated_schema|global_schema|uses_global_schema)|global_schema' src/parseable/streams.rs || true
printf '%s\n' '--- staging recordbatch_cloned complete block ---'
sed -n '230,330p' src/parseable/staging/writer.rs
printf '%s\n' '--- adapt_batch definitions and callers ---'
rg -n -C12 '\badapt_batch\b' src || true
printf '%s\n' '--- ingest schema validation/merge callers ---'
rg -n -C10 'fields_mismatch|override_data_type|commit_schema|merge.*schema|schema.*merge|get_schema_raw' src/handlers src/event src/parseable/streams.rs || trueRepository: parseablehq/parseable Length of output: 42382 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- setup_logstream_metadata complete block ---'
sed -n '443,535p' src/migration/mod.rs
printf '%s\n' '--- restore_global_schema complete block ---'
sed -n '2597,2685p' src/parseable/streams.rs
printf '%s\n' '--- recordbatches_cloned complete block ---'
sed -n '1198,1265p' src/parseable/streams.rs
printf '%s\n' '--- staging recordbatch_cloned and adapt_batch ---'
sed -n '245,335p' src/parseable/staging/writer.rs
rg -n -C8 'fn adapt_batch|adapt_batch\(' src/parseable/staging/writer.rs src/parseable/streams.rs src
printf '%s\n' '--- ingest callers using metadata schema ---'
sed -n '280,390p' src/handlers/http/modal/utils/ingest_utils.rs
sed -n '150,235p' src/event/format/json.rs
sed -n '140,180p' src/event/mod.rsRepository: parseablehq/parseable Length of output: 39268 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- callers and surrounding conversion flow ---'
rg -n -C18 'recordbatches_cloned\(' src/parseable/streams.rs src
sed -n '1120,1260p' src/parseable/streams.rs
printf '%s\n' '--- JSON schema/conflict flow ---'
rg -n -C16 'detect_schema_conflicts|rename_per_record_type_mismatches|fields_mismatch|into_recordbatch' src/event/format/json.rs
printf '%s\n' '--- batch adapter complete implementation ---'
sed -n '1,100p' src/utils/arrow/batch_adapter.rs
printf '%s\n' '--- changed diff for the relevant files ---'
git diff --no-ext-diff --unified=35 e3e4c8c5aab8f2df7887ef015942edfeb59c2f5d 135e5309fa6234cf0c1b04ec070d1549691d5e62 -- src/migration/mod.rs src/parseable/streams.rs src/utils/arrow/batch_adapter.rs src/event/format/json.rs src/event/mod.rsRepository: parseablehq/parseable Length of output: 43494 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- Stream::push and Event::process callers ---'
rg -n -C18 '\.push\(|fn process|stream\.push|push\(' src/event src/handlers src/connectors src/parseable/streams.rs | rg -n -C8 'process|stream\.push|\.push\(' || true
printf '%s\n' '--- all direct calls to Stream::push by source context ---'
rg -n -C12 'push\(' src --type=rust | rg -n -C8 'stream|Stream|event|rb|record' || true
printf '%s\n' '--- conflict detection and rename implementations ---'
rg -n -C24 'fn (detect_schema_conflicts|rename_conflicting_fields_in_json|rename_per_record_type_mismatches)' src/event
printf '%s\n' '--- format-specific Event implementations ---'
rg -n -C8 'impl EventFormat|into_recordbatch|RecordBatch' src/event/format src/event/mod.rsRepository: parseablehq/parseable Length of output: 45665 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- direct Stream::push references ---'
rg -n -F -- 'stream.push(' src || true
rg -n -F -- '.push(stream' src || true
printf '%s\n' '--- Event::process declaration and body ---'
rg -n -F -- 'pub fn process' src/event src/handlers || true
sed -n '40,150p' src/event/mod.rs
printf '%s\n' '--- Stream::push declaration and body ---'
sed -n '754,810p' src/parseable/streams.rs
printf '%s\n' '--- Event construction outside JSON ---'
rg -n -C8 'Event \{' src --type=rust | head -n 240Repository: parseablehq/parseable Length of output: 21202 Keep the raw local schema in
For a raw batch with Keep the raw local schema in Suggested fix {
stream_ref
.restore_global_schema(
arrow_schema.clone(),
tenant_id,
time_partition.as_ref(),
custom_partition.as_ref(),
)
- .await?
+ .await?;
+ stream_ref.updated_schema(arrow_schema.clone())
} else {
stream_ref.updated_schema(arrow_schema.clone())
};The JSON path renames detected conflicts before 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let schema = HashMap::from_iter( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| schema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.