stock-bot/tools/curate-etl/src/run_curate_posts.rs

799 lines
28 KiB
Rust

//! File-to-file `curate-posts` runner (`M2.2i` / `M2.2u`).
//!
//! Streams a concatenated raw BSON `ceoPosts` dump file alongside `provider_mapping.tsv` into an
//! atomically published `<out_dir>/events/year=YYYY/part-posts.parquet` dataset via
//! [`curate_posts`] and [`write_posts_events_dataset`].
//!
//! # Co-Publication with `curate-events`
//! [`crate::run_curate_events`] (filings + earnings) writes `<out_dir>/events/year=YYYY/part.parquet`
//! and this runner writes `<out_dir>/events/year=YYYY/part-posts.parquet` (`kind = "ceo_post"`).
//! Both share `<out_dir>/events/.write.lock` and remain independently re-runnable in the same
//! `curatedRoot` without clobbering each other's partition files.
//!
//! # Contract & Point-in-Time Rules
//! - Field names are supplied via [`CuratePostsArgs`] (validated via
//! [`CeoPostsFieldNames::validate`] before reading inputs).
//! - Numeric timestamp unit ([`CeoPostsTimestampUnit`]) has **no default** and must be chosen
//! explicitly by the caller because the live MongoDB `ceoPosts` numeric unit (`Seconds` vs.
//! `Millis`) is unverified in the repository. BSON `DateTime` values are always epoch
//! milliseconds regardless of unit.
//! - `provider_mapping.tsv` uses the strict headerless 5-column TSV format from
//! [`crate::run_curate_bars::load_provider_mapping_tsv`].
//! - All decoded [`CeoPost`] rows are passed directly to [`curate_and_write_posts`] (which splits
//! `bot == "1"` newswire vs. retail, enforces the `edited` text `known_at` guard, resolves
//! `provider_mapping` on the Eastern local posting date of `posted_at`, and drops unmapped or
//! unsupported-date rows into stats).
//! - **In-memory accumulation:** [`RawBsonChunkReader`] bounds only the raw BSON chunk buffer
//! (`peak_chunk_bytes`); decoded posts and their text accumulate in memory before
//! [`curate_and_write_posts`] runs, as [`crate::curate_posts::curate_posts`] requires.
//! - **Empty / all-unmapped behavior:** returns `Ok` with `rows_written == 0` and
//! `files_written == 0` without creating `<out_dir>/events`.
//! - **Fail-closed safety:** invalid `out_dir`, input-output path overlap, invalid field names,
//! blank `mapping_source`, unreadable inputs, malformed/overlapping `provider_mapping.tsv`,
//! truncated/corrupt BSON framing or element bytes, and curation timestamp overflow errors return
//! a typed [`RunCuratePostsError`] before touching `out_dir`.
//!
//! # Counter Conservation Invariants
//! Every successful [`CuratePostsRunReport`] satisfies:
//! - `docs_framed as usize == decode.docs_in == decode.rows_out + decode.skipped_total()`
//! - `decode.rows_out == curate_stats.builder.input`
//! - `curate_stats.builder.input == curate_stats.builder.newswire + curate_stats.builder.retail + curate_stats.builder.duplicates_dropped + curate_stats.builder.rejected_invalid`
//! - `curate_stats.rows_in == curate_stats.builder.newswire + curate_stats.builder.retail == curate_stats.rows_out + curate_stats.dropped_unmapped + curate_stats.dropped_unsupported_date + curate_stats.listing_duplicate_collapsed`
//! - `write_stats.rows_written == curate_stats.rows_out`
use std::collections::{BTreeSet, HashSet};
use std::error::Error;
use std::fmt::{self, Write as _};
use std::fs::{self, File};
use std::io;
use std::path::{Component, Path, PathBuf};
use std::sync::Arc;
use std::time::Instant;
use crate::bson_ceo_posts::{
BsonCeoPostsDecodeStats, BsonCeoPostsError, CeoPostsFieldNames, CeoPostsTimestampUnit,
};
use crate::bson_stream::{
decode_ceo_posts_chunks, BsonCeoPostsStreamError, BsonStreamError, BsonStreamOptions,
RawBsonChunkReader,
};
use crate::curate_posts::{curate_posts, CuratePostsStats, CuratePostsWriteError};
use crate::events::partition_year_utc;
use crate::parquet_events::{
write_posts_events_dataset, EventsParquetRow, EventsWriteOptions, EventsWriteStats,
POSTS_PART_FILE_NAME,
};
use crate::posts::CeoPost;
use crate::provider_mapping::{ProviderMappingError, ProviderMappingTable};
use crate::run_curate_bars::{load_provider_mapping_tsv, RunCurateBarsError};
/// Default `mapping_source` passed to `provider_mapping` lookups for `ceoPosts`.
pub const DEFAULT_MAPPING_SOURCE: &str = "ceo";
/// Arguments for [`run_curate_posts`].
///
/// `timestamp_unit` intentionally has no default: callers must explicitly choose
/// [`CeoPostsTimestampUnit::Seconds`] or [`CeoPostsTimestampUnit::Millis`].
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CuratePostsArgs {
pub ceo_posts: PathBuf,
pub provider_mapping: PathBuf,
pub out_dir: PathBuf,
pub timestamp_unit: CeoPostsTimestampUnit,
pub key_field: String,
pub spiel_id_field: String,
pub timestamp_field: String,
pub edited_field: String,
pub bot_field: String,
pub user_id_field: String,
pub text_field: String,
pub mapping_source: String,
}
impl CuratePostsArgs {
/// Borrows the configured BSON field names as [`CeoPostsFieldNames`].
#[inline]
pub fn field_names(&self) -> CeoPostsFieldNames<'_> {
CeoPostsFieldNames {
key: self.key_field.as_str(),
spiel_id: self.spiel_id_field.as_str(),
timestamp: self.timestamp_field.as_str(),
edited: self.edited_field.as_str(),
bot: self.bot_field.as_str(),
user_id: self.user_id_field.as_str(),
text: self.text_field.as_str(),
}
}
}
/// Full run report produced by [`run_curate_posts`] and [`run_curate_posts_with_reader`].
#[derive(Debug, Clone, PartialEq)]
pub struct CuratePostsRunReport {
pub docs_framed: u64,
pub bytes_read: u64,
pub peak_chunk_bytes: usize,
pub decode: BsonCeoPostsDecodeStats,
pub curate_stats: CuratePostsStats,
pub write_stats: EventsWriteStats,
pub elapsed_secs: f64,
}
/// Typed errors returned by [`run_curate_posts`] and [`run_curate_posts_with_reader`].
///
/// Every variant's `Display` output is a single line naming the offending path (and line number or
/// byte offset where applicable).
#[derive(Debug)]
pub enum RunCuratePostsError {
InvalidOutDir {
path: PathBuf,
detail: String,
},
InspectOutDir {
path: PathBuf,
source: io::Error,
},
InvalidFieldNames {
source: BsonCeoPostsError,
},
EmptyMappingSource,
OpenInput {
label: &'static str,
path: PathBuf,
source: io::Error,
},
ReadInput {
label: &'static str,
path: PathBuf,
source: io::Error,
},
TsvParse {
path: PathBuf,
line: usize,
detail: String,
},
ProviderMapping {
path: PathBuf,
source: ProviderMappingError,
},
BsonStream {
path: PathBuf,
source: BsonStreamError,
},
CorruptBson {
path: PathBuf,
offset: u64,
source: BsonCeoPostsError,
},
CurateWrite {
out_dir: PathBuf,
source: CuratePostsWriteError,
},
}
struct SingleLineWriter<'a, 'b> {
f: &'a mut fmt::Formatter<'b>,
}
impl fmt::Write for SingleLineWriter<'_, '_> {
fn write_str(&mut self, s: &str) -> fmt::Result {
let mut rest = s;
while let Some(idx) = rest.find(['\n', '\r']) {
let (head, tail) = rest.split_at(idx);
if !head.is_empty() {
self.f.write_str(head)?;
}
let mut chars = tail.chars();
match chars.next() {
Some('\n') => self.f.write_str("\\n")?,
Some('\r') => self.f.write_str("\\r")?,
_ => unreachable!(),
}
rest = chars.as_str();
}
if !rest.is_empty() {
self.f.write_str(rest)?;
}
Ok(())
}
}
impl fmt::Display for RunCuratePostsError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut w = SingleLineWriter { f };
match self {
Self::InvalidOutDir { path, detail } => {
write!(w, "invalid --out '{}': {detail}", path.display())
}
Self::InspectOutDir { path, source } => {
write!(
w,
"failed to inspect output path '{}': {source}",
path.display()
)
}
Self::InvalidFieldNames { source } => write!(w, "{source}"),
Self::EmptyMappingSource => {
write!(w, "invalid --mapping-source: must not be empty or blank")
}
Self::OpenInput {
label,
path,
source,
} => write!(w, "failed to open {label} '{}': {source}", path.display()),
Self::ReadInput {
label,
path,
source,
} => write!(w, "failed to read {label} '{}': {source}", path.display()),
Self::TsvParse { path, line, detail } => {
write!(w, "{}:{line}: {detail}", path.display())
}
Self::ProviderMapping { path, source } => {
write!(w, "invalid provider_mapping '{}': {source}", path.display())
}
Self::BsonStream { path, source } => {
write!(w, "failed reading ceo-posts '{}': {source}", path.display())
}
Self::CorruptBson {
path,
offset,
source,
} => write!(
w,
"corrupt ceo-posts BSON '{}' at byte offset {offset}: {source}",
path.display()
),
Self::CurateWrite { out_dir, source } => {
write!(w, "curate/write to '{}' failed: {source}", out_dir.display())
}
}
}
}
impl Error for RunCuratePostsError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
Self::InspectOutDir { source, .. } => Some(source),
Self::InvalidFieldNames { source } => Some(source),
Self::OpenInput { source, .. } | Self::ReadInput { source, .. } => Some(source),
Self::ProviderMapping { source, .. } => Some(source),
Self::BsonStream { source, .. } => Some(source),
Self::CorruptBson { source, .. } => Some(source),
Self::CurateWrite { source, .. } => Some(source),
Self::InvalidOutDir { .. } | Self::EmptyMappingSource | Self::TsvParse { .. } => None,
}
}
}
/// Resolves `path` to an absolute normalized path while preserving OS symlink-before-`..`
/// semantics: if `path` exists it is canonicalized directly; otherwise components are walked
/// left-to-right, canonicalizing each existing prefix before resolving `..`, and only lexically
/// normalizing `..` within any non-existent suffix.
fn resolve_normalized_path(path: &Path) -> PathBuf {
if let Ok(canon) = path.canonicalize() {
return canon;
}
let abs = if path.is_absolute() {
path.to_path_buf()
} else if let Ok(cwd) = std::env::current_dir() {
cwd.join(path)
} else {
path.to_path_buf()
};
if let Ok(canon) = abs.canonicalize() {
return canon;
}
let mut resolved = PathBuf::new();
for comp in abs.components() {
match comp {
Component::Prefix(prefix) => resolved.push(prefix.as_os_str()),
Component::RootDir => resolved.push(Component::RootDir.as_os_str()),
Component::CurDir => {}
Component::Normal(seg) => {
resolved.push(seg);
if let Ok(canon) = resolved.canonicalize() {
resolved = canon;
}
}
Component::ParentDir => {
resolved.push(Component::ParentDir.as_os_str());
if let Ok(canon) = resolved.canonicalize() {
resolved = canon;
} else {
resolved.pop();
if matches!(resolved.components().next_back(), Some(Component::Normal(_))) {
resolved.pop();
}
}
}
}
}
resolved
}
fn validate_out_dir_and_inputs(
out_dir: &Path,
ceo_posts_path: &Path,
provider_mapping_path: &Path,
) -> Result<(), RunCuratePostsError> {
if out_dir.as_os_str().is_empty() {
return Err(RunCuratePostsError::InvalidOutDir {
path: out_dir.to_path_buf(),
detail: "output directory path must not be empty".to_string(),
});
}
// Reject `..` after a missing path component: `fs::metadata` reports `NotFound` for the
// unresolved path, while `create_dir_all` would create the missing component and traverse `..`.
let mut prefix = PathBuf::new();
let mut saw_missing = false;
for component in out_dir.components() {
match component {
Component::ParentDir => {
if saw_missing {
return Err(RunCuratePostsError::InvalidOutDir {
path: out_dir.to_path_buf(),
detail: "output path must not contain '..' after a missing component"
.to_string(),
});
}
prefix.push(component);
}
Component::CurDir => {
if !saw_missing {
prefix.push(component);
}
}
Component::RootDir | Component::Prefix(_) => {
prefix.push(component);
}
Component::Normal(_) => {
prefix.push(component);
if !saw_missing {
match fs::metadata(&prefix) {
Ok(_) => {}
Err(err) if err.kind() == io::ErrorKind::NotFound => {
saw_missing = true;
}
Err(source) => {
return Err(RunCuratePostsError::InspectOutDir {
path: prefix,
source,
});
}
}
}
}
}
}
let events_dir = out_dir.join("events");
match fs::metadata(out_dir) {
Ok(meta) if !meta.is_dir() => {
return Err(RunCuratePostsError::InvalidOutDir {
path: out_dir.to_path_buf(),
detail: "path exists and is not a directory".to_string(),
});
}
Ok(_) => match fs::metadata(&events_dir) {
Ok(meta) if !meta.is_dir() => {
return Err(RunCuratePostsError::InvalidOutDir {
path: events_dir,
detail: "events output path exists and is not a directory".to_string(),
});
}
Ok(_) => {}
Err(err) if err.kind() == io::ErrorKind::NotFound => {}
Err(source) => {
return Err(RunCuratePostsError::InspectOutDir {
path: events_dir,
source,
});
}
},
Err(err) if err.kind() == io::ErrorKind::NotFound => {}
Err(source) => {
return Err(RunCuratePostsError::InspectOutDir {
path: out_dir.to_path_buf(),
source,
});
}
}
let resolved_out = resolve_normalized_path(out_dir);
let resolved_events = resolve_normalized_path(&events_dir);
for (label, input_path) in [
("ceo-posts", ceo_posts_path),
("provider-mapping", provider_mapping_path),
] {
let resolved_in = resolve_normalized_path(input_path);
if resolved_in == resolved_out
|| resolved_in == resolved_events
|| resolved_in.starts_with(&resolved_events)
{
return Err(RunCuratePostsError::InvalidOutDir {
path: out_dir.to_path_buf(),
detail: format!(
"output directory would overlap {label} input '{}'",
input_path.display()
),
});
}
}
Ok(())
}
/// Checks each destination `year=YYYY` partition directory and its `part-posts.parquet` path
/// against all resolved input paths before publishing.
///
/// Catches symlinked year directories (e.g. `<out>/events/year=2024 -> /external/dir`) whose
/// resolved target lies outside `<out>/events` and would otherwise let
/// `write_posts_events_dataset` overwrite an input located at `/external/dir/part-posts.parquet`.
fn validate_partition_outputs_and_inputs(
out_dir: &Path,
ceo_posts_path: &Path,
provider_mapping_path: &Path,
rows: &[EventsParquetRow],
) -> Result<(), RunCuratePostsError> {
if rows.is_empty() {
return Ok(());
}
let mut years = BTreeSet::new();
for row in rows {
years.insert(partition_year_utc(row.ts_micros));
}
let resolved_inputs = [
(
"ceo-posts",
ceo_posts_path,
resolve_normalized_path(ceo_posts_path),
),
(
"provider-mapping",
provider_mapping_path,
resolve_normalized_path(provider_mapping_path),
),
];
let events_dir = out_dir.join("events");
for year in years {
let year_dir = events_dir.join(format!("year={year:04}"));
let resolved_year_dir = resolve_normalized_path(&year_dir);
let resolved_part_via_dir = resolved_year_dir.join(POSTS_PART_FILE_NAME);
let resolved_part = resolve_normalized_path(&year_dir.join(POSTS_PART_FILE_NAME));
for (label, input_path, resolved_in) in &resolved_inputs {
if *resolved_in == resolved_year_dir
|| *resolved_in == resolved_part_via_dir
|| *resolved_in == resolved_part
{
return Err(RunCuratePostsError::InvalidOutDir {
path: year_dir,
detail: format!(
"partition output '{}' would overlap {label} input '{}'",
resolved_part_via_dir.display(),
input_path.display()
),
});
}
}
}
Ok(())
}
fn map_tsv_error(path: &Path, err: RunCurateBarsError) -> RunCuratePostsError {
match err {
RunCurateBarsError::OpenInput {
label,
path,
source,
} => RunCuratePostsError::OpenInput {
label,
path,
source,
},
RunCurateBarsError::ReadInput {
label,
path,
source,
} => RunCuratePostsError::ReadInput {
label,
path,
source,
},
RunCurateBarsError::TsvParse { path, line, detail } => {
RunCuratePostsError::TsvParse { path, line, detail }
}
RunCurateBarsError::ProviderMapping { path, source } => {
RunCuratePostsError::ProviderMapping { path, source }
}
other => RunCuratePostsError::TsvParse {
path: path.to_path_buf(),
line: 0,
detail: other.to_string(),
},
}
}
fn bson_error_offset(err: &BsonCeoPostsError) -> u64 {
match err {
BsonCeoPostsError::TruncatedDocument { offset, .. }
| BsonCeoPostsError::CorruptDocumentLength { offset, .. }
| BsonCeoPostsError::CorruptBson { offset, .. } => *offset,
BsonCeoPostsError::InvalidFieldNames { .. } => 0,
}
}
struct DecodedPostsInputs {
mapping: ProviderMappingTable,
posts: Vec<CeoPost<Arc<str>>>,
docs_framed: u64,
bytes_read: u64,
peak_chunk_bytes: usize,
decode: BsonCeoPostsDecodeStats,
}
fn decode_inputs_from_opener<R, F>(
provider_mapping_path: &Path,
mapping_source: &str,
fields: &CeoPostsFieldNames<'_>,
timestamp_unit: CeoPostsTimestampUnit,
ceo_posts_path: &Path,
open_posts: F,
) -> Result<DecodedPostsInputs, RunCuratePostsError>
where
R: io::Read,
F: FnOnce() -> Result<R, RunCuratePostsError>,
{
fields
.validate()
.map_err(|source| RunCuratePostsError::InvalidFieldNames { source })?;
if mapping_source.trim().is_empty() {
return Err(RunCuratePostsError::EmptyMappingSource);
}
let mapping_rows = load_provider_mapping_tsv(provider_mapping_path)
.map_err(|err| map_tsv_error(provider_mapping_path, err))?;
let mapping = ProviderMappingTable::from_rows(mapping_rows).map_err(|source| {
RunCuratePostsError::ProviderMapping {
path: provider_mapping_path.to_path_buf(),
source,
}
})?;
let stream = open_posts()?;
let mut reader = RawBsonChunkReader::with_options(stream, BsonStreamOptions::default())
.map_err(|source| RunCuratePostsError::BsonStream {
path: ceo_posts_path.to_path_buf(),
source,
})?;
let mut key_interner: HashSet<Arc<str>> = HashSet::new();
let mut posts: Vec<CeoPost<Arc<str>>> = Vec::new();
let decode = decode_ceo_posts_chunks(&mut reader, fields, timestamp_unit, |raw| {
let key = if let Some(existing) = key_interner.get(raw.key) {
Arc::clone(existing)
} else {
let arc: Arc<str> = Arc::from(raw.key);
key_interner.insert(Arc::clone(&arc));
arc
};
posts.push(CeoPost {
key,
spiel_id: raw.spiel_id,
timestamp_ms: raw.timestamp_ms,
edited_ms: raw.edited_ms,
bot: raw.bot,
user_id: raw.user_id,
text: raw.text,
});
})
.map_err(|err| match err {
BsonCeoPostsStreamError::Stream(source) => RunCuratePostsError::BsonStream {
path: ceo_posts_path.to_path_buf(),
source,
},
BsonCeoPostsStreamError::Decode(source) => match &source {
BsonCeoPostsError::InvalidFieldNames { .. } => {
RunCuratePostsError::InvalidFieldNames { source }
}
_ => {
let offset = bson_error_offset(&source);
RunCuratePostsError::CorruptBson {
path: ceo_posts_path.to_path_buf(),
offset,
source,
}
}
},
})?;
Ok(DecodedPostsInputs {
mapping,
posts,
docs_framed: reader.docs_framed(),
bytes_read: reader.bytes_read(),
peak_chunk_bytes: reader.buffer_capacity(),
decode,
})
}
fn run_curate_posts_from_opener<R, F>(
provider_mapping_path: &Path,
mapping_source: &str,
fields: &CeoPostsFieldNames<'_>,
timestamp_unit: CeoPostsTimestampUnit,
ceo_posts_path: &Path,
open_posts: F,
out_dir: &Path,
) -> Result<CuratePostsRunReport, RunCuratePostsError>
where
R: io::Read,
F: FnOnce() -> Result<R, RunCuratePostsError>,
{
let start = Instant::now();
validate_out_dir_and_inputs(out_dir, ceo_posts_path, provider_mapping_path)?;
let decoded = decode_inputs_from_opener(
provider_mapping_path,
mapping_source,
fields,
timestamp_unit,
ceo_posts_path,
open_posts,
)?;
let curated = curate_posts(decoded.posts, mapping_source, &decoded.mapping).map_err(|err| {
RunCuratePostsError::CurateWrite {
out_dir: out_dir.to_path_buf(),
source: CuratePostsWriteError::Curate(err),
}
})?;
// Re-check output directory and per-year partition overlap immediately before writing.
validate_out_dir_and_inputs(out_dir, ceo_posts_path, provider_mapping_path)?;
validate_partition_outputs_and_inputs(
out_dir,
ceo_posts_path,
provider_mapping_path,
&curated.rows,
)?;
let write_stats =
write_posts_events_dataset(out_dir, &curated.rows, EventsWriteOptions::default()).map_err(
|err| RunCuratePostsError::CurateWrite {
out_dir: out_dir.to_path_buf(),
source: CuratePostsWriteError::Parquet(err),
},
)?;
Ok(CuratePostsRunReport {
docs_framed: decoded.docs_framed,
bytes_read: decoded.bytes_read,
peak_chunk_bytes: decoded.peak_chunk_bytes,
decode: decoded.decode,
curate_stats: curated.stats,
write_stats,
elapsed_secs: start.elapsed().as_secs_f64(),
})
}
/// Runs the end-to-end `curate-posts` file-to-Parquet pipeline via [`curate_and_write_posts`].
///
/// Any validation, clobber-guard, I/O, TSV, mapping, BSON framing/corruption, or curation error
/// returns before touching `args.out_dir`.
pub fn run_curate_posts(
args: &CuratePostsArgs,
) -> Result<CuratePostsRunReport, RunCuratePostsError> {
run_curate_posts_from_opener(
&args.provider_mapping,
&args.mapping_source,
&args.field_names(),
args.timestamp_unit,
&args.ceo_posts,
|| {
File::open(&args.ceo_posts).map_err(|source| RunCuratePostsError::OpenInput {
label: "ceo-posts",
path: args.ceo_posts.clone(),
source,
})
},
&args.out_dir,
)
}
/// Runs `curate-posts` from an arbitrary raw-BSON [`io::Read`] stream.
pub fn run_curate_posts_with_reader<R: io::Read>(
provider_mapping_path: &Path,
mapping_source: &str,
fields: &CeoPostsFieldNames<'_>,
timestamp_unit: CeoPostsTimestampUnit,
ceo_posts_input: (&Path, R),
out_dir: &Path,
) -> Result<CuratePostsRunReport, RunCuratePostsError> {
let (ceo_path, stream) = ceo_posts_input;
run_curate_posts_from_opener(
provider_mapping_path,
mapping_source,
fields,
timestamp_unit,
ceo_path,
|| Ok(stream),
out_dir,
)
}
/// Formats [`CuratePostsRunReport`] into a deterministic machine-readable `key=value` summary.
///
/// Only the final `timing:` line contains wall-clock time (`elapsed_secs`).
pub fn format_curate_posts_report(report: &CuratePostsRunReport) -> String {
let d = &report.decode;
let b = &report.curate_stats.builder;
let c = &report.curate_stats;
let w = &report.write_stats;
format!(
"curate-etl curate-posts\n\
\x20 ceo_bson: docs_framed={} bytes_read={} peak_chunk_bytes={} docs_in={} rows_out={} skipped={} (missing_key={} wrong_key_type={} empty_key={} missing_spiel_id={} wrong_spiel_id_type={} empty_spiel_id={} missing_ts={} wrong_ts_type={} invalid_ts={} ts_oor={} invalid_edited={} wrong_text_type={}) emitted=(edited_zero_or_false={} nulled_bot={} nulled_user_id={} empty_text={})\n\
\x20 builder: input={} newswire={} retail={} edited={} edited_before_posted={} dup_dropped={} rejected_invalid={}\n\
\x20 curate: rows_in={} rows_out={} newswire_out={} retail_out={} listings_out={} dropped_unmapped={} dropped_unsupported_date={} listing_dup_collapsed={}\n\
\x20 write: files={} row_groups={} rows_written={} bytes_written={}\n\
\x20 timing: elapsed_secs={:.6}",
report.docs_framed,
report.bytes_read,
report.peak_chunk_bytes,
d.docs_in,
d.rows_out,
d.skipped_total(),
d.skipped_missing_key,
d.skipped_wrong_key_type,
d.skipped_empty_key,
d.skipped_missing_spiel_id,
d.skipped_wrong_spiel_id_type,
d.skipped_empty_spiel_id,
d.skipped_missing_timestamp,
d.skipped_wrong_timestamp_type,
d.skipped_invalid_timestamp,
d.skipped_timestamp_out_of_range,
d.skipped_invalid_edited,
d.skipped_wrong_text_type,
d.edited_zero_or_false,
d.nulled_wrong_type_bot,
d.nulled_wrong_type_user_id,
d.empty_text,
b.input,
b.newswire,
b.retail,
b.edited,
b.edited_before_posted,
b.duplicates_dropped,
b.rejected_invalid,
c.rows_in,
c.rows_out,
c.newswire_out,
c.retail_out,
c.listings_out,
c.dropped_unmapped,
c.dropped_unsupported_date,
c.listing_duplicate_collapsed,
w.files_written,
w.row_groups_written,
w.rows_written,
w.bytes_written,
report.elapsed_secs,
)
}
#[cfg(test)]
#[path = "run_curate_posts_tests.rs"]
mod tests;