fix(cli): fail on formatting errors during text output#46
fix(cli): fail on formatting errors during text output#46wackywendell wants to merge 4 commits intomainfrom
Conversation
b02b450 to
74698d6
Compare
2fae074 to
c045ecf
Compare
| use crate::parser::ExpressionParser; | ||
|
|
||
| fn parse_exact(rule: Rule, input: &str) -> pest::iterators::Pair<Rule> { | ||
| fn parse_exact(rule: Rule, input: &'_ str) -> pest::iterators::Pair<'_, Rule> { |
There was a problem hiding this comment.
Needed for newer Rust clippy version
| ), | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
These have been disabled for a long time, no need to keep them
Return an error when text formatting reports errors in convert/validate while keeping best-effort output, with tests.
d19db33 to
f2c18b5
Compare
| } | ||
| #[cfg(not(feature = "serde"))] | ||
| { | ||
| return Err("YAML support requires the 'serde' feature. Install with: cargo install substrait-explain --features cli,serde".into()); |
There was a problem hiding this comment.
Removing the return and ; creates an expression, but is anything done with this expression now? Is there still error propagation?
There was a problem hiding this comment.
Yes - an expression without a ; at the end of a function (or any {…} block) is the same as a return. This is considered more idiomatic in Rust; see this clippy lint.
Note also that this function returns a Result<…>; if you add a ; to this line without the Result, it would fail to compile because there would be nothing returned from this branch.
| let RexType::ScalarFunction(func) = condition.rex_type.as_mut().unwrap() else { | ||
| panic!("Expected ScalarFunction"); | ||
| }; | ||
| func.function_reference = 999; // Invalid - doesn't exist in extensions |
There was a problem hiding this comment.
Is this a formatting issue or is this validation of the reference?
There was a problem hiding this comment.
It's both - it's invalid as a plan, therefore can't be formatted. At formatting time, we use the function reference to look up the function name in the extensions, and then print the function name in the expression; if the function reference is valid, then the function name can't be printed.
Return a terminal error when text formatting reports errors in convert/validate while keeping best-effort output.
Also a bit of code cleanup.
Before
Note that
!{RexType}and!{ReadRel}are not recognized, but no warnings are printed; also exit code 0 is for 'success'.After
Note the errors and the non-zero exit code.