fix(cli): refuse a --split-date or --axis that names nothing it built (improvise-tpm8)
This commit is contained in:
committed by
Edward Langley
parent
053699b652
commit
0c56a4b9a1
@@ -1919,3 +1919,27 @@ improvise-d0n6. The same with a raw `2024`, a generated group. Removing the
|
|||||||
`spelling_clash` call fails it the same way. The control,
|
`spelling_clash` call fails it the same way. The control,
|
||||||
`a_raw_date_spelled_like_nothing_generated_is_kept_ungrouped`, passes either
|
`a_raw_date_spelled_like_nothing_generated_is_kept_ungrouped`, passes either
|
||||||
way, so a blanket refusal of every unparsed value fails it.
|
way, so a blanket refusal of every unparsed value fails it.
|
||||||
|
|
||||||
|
### the_date_step_will_not_advance_over_a_spelling_clash
|
||||||
|
|
||||||
|
improvise-d0n6 (Copilot on PR #322, and the adversarial review's B1). The
|
||||||
|
spelling-clash refusal sat only in the build, so a wizard with a raw `2024` in
|
||||||
|
a `%Y-%m-%d` column passed ConfigureDates and failed on NameModel, three steps
|
||||||
|
from the `s` that fixes it. Before the check joined `validation_error` the
|
||||||
|
test failed with the step already `DefineFormulas`; removing that call again
|
||||||
|
reproduces it. It also toggles to the split shape and requires the step to
|
||||||
|
advance, so a check that blocks forever fails.
|
||||||
|
|
||||||
|
### split_date_naming_an_unknown_or_non_date_field_is_refused
|
||||||
|
|
||||||
|
improvise-tpm8 class. `--split-date Nope` and `--split-date Revenue` (a
|
||||||
|
measure) exited 0 and did nothing. Both now exit 1 naming the flag and the
|
||||||
|
field; removing the check in `run_headless_import` fails both rows.
|
||||||
|
|
||||||
|
### an_axis_naming_a_category_the_import_did_not_build_is_refused
|
||||||
|
|
||||||
|
improvise-8jk6.3 review. `--extract Date:Month --axis Date_Month:column` used
|
||||||
|
to build one `Date` category and drop the `--axis` for the vanished
|
||||||
|
`Date_Month`, exit 0. It now exits 1 naming the category and `--split-date`.
|
||||||
|
This also refuses any `--axis` naming an absent category, which was silently
|
||||||
|
ignored before this PR as well.
|
||||||
|
|||||||
+18
@@ -312,6 +312,14 @@ fn run_headless_import(
|
|||||||
model_file: Option<PathBuf>,
|
model_file: Option<PathBuf>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
apply_config_to_pipeline(&mut pipeline, config);
|
apply_config_to_pipeline(&mut pipeline, config);
|
||||||
|
if let Some(field) = config.split_dates.iter().find(|f| {
|
||||||
|
!pipeline
|
||||||
|
.proposals
|
||||||
|
.iter()
|
||||||
|
.any(|p| &p.field == *f && p.kind == import::analyzer::FieldKind::TimeCategory)
|
||||||
|
}) {
|
||||||
|
anyhow::bail!("--split-date '{field}' is not a date column of this import");
|
||||||
|
}
|
||||||
if pipeline.on_duplicate == DuplicatePolicy::Refuse {
|
if pipeline.on_duplicate == DuplicatePolicy::Refuse {
|
||||||
let collisions = pipeline.collisions();
|
let collisions = pipeline.collisions();
|
||||||
if !collisions.is_empty() {
|
if !collisions.is_empty() {
|
||||||
@@ -322,6 +330,16 @@ fn run_headless_import(
|
|||||||
for warning in &warnings {
|
for warning in &warnings {
|
||||||
eprintln!("warning: {warning}");
|
eprintln!("warning: {warning}");
|
||||||
}
|
}
|
||||||
|
if let Some((cat, _)) = config
|
||||||
|
.axes
|
||||||
|
.iter()
|
||||||
|
.find(|(cat, _)| wb.model.category(cat).is_none())
|
||||||
|
{
|
||||||
|
anyhow::bail!(
|
||||||
|
"--axis names '{cat}', which this import did not build \
|
||||||
|
(a date's parts are one category unless --split-date names it)"
|
||||||
|
);
|
||||||
|
}
|
||||||
apply_axis_overrides(&mut wb, &config.axes);
|
apply_axis_overrides(&mut wb, &config.axes);
|
||||||
|
|
||||||
if let Some(path) = output.or(model_file) {
|
if let Some(path) = output.or(model_file) {
|
||||||
|
|||||||
@@ -697,7 +697,10 @@ fn an_axis_naming_a_category_the_import_did_not_build_is_refused() {
|
|||||||
);
|
);
|
||||||
assert!(!out.status.success(), "{}", stderr_of(&out));
|
assert!(!out.status.success(), "{}", stderr_of(&out));
|
||||||
let err = stderr_of(&out);
|
let err = stderr_of(&out);
|
||||||
assert!(err.contains("Date_Month") && err.contains("--split-date"), "{err}");
|
assert!(
|
||||||
|
err.contains("Date_Month") && err.contains("--split-date"),
|
||||||
|
"{err}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// code-maat's reports: three schemas, a stray note, and room for the output.
|
/// code-maat's reports: three schemas, a stray note, and room for the output.
|
||||||
|
|||||||
Reference in New Issue
Block a user