martin-g commented on code in PR #18857:
URL: https://github.com/apache/datafusion/pull/18857#discussion_r2549858900
##########
datafusion/sqllogictest/src/util.rs:
##########
@@ -82,13 +82,36 @@ pub fn df_value_validator(
actual: &[Vec<String>],
expected: &[String],
) -> bool {
+ // Support ignore marker <slt:ignore> to skip volatile parts of output.
+ const IGNORE_MARKER: &str = "<slt:ignore>";
+ let contains_ignore_marker = expected.iter().any(|line|
line.contains(IGNORE_MARKER));
+
let normalized_expected =
expected.iter().map(normalizer).collect::<Vec<_>>();
let normalized_actual = actual
.iter()
.map(|strs| strs.iter().join(" "))
.map(|str| str.trim_end().to_string())
.collect_vec();
+ // If ignore marker present, perform fragment-based matching on the full
snapshot.
+ if contains_ignore_marker {
+ let expected_snapshot = normalized_expected.join("\n");
+ let actual_snapshot = normalized_actual.join("\n");
+ let fragments: Vec<&str> =
expected_snapshot.split(IGNORE_MARKER).collect();
+ let mut pos = 0;
+ for frag in fragments {
+ if frag.is_empty() {
+ continue;
+ }
+ if let Some(idx) = actual_snapshot[pos..].find(frag) {
+ pos += idx + frag.len();
Review Comment:
I think this logic won't detect a prefix in the actual_snapshot.
Let's say the first expected fragment is "Hello" but the actual_snapshot
starts with "Anything here before Hello". The `find()` will set the position to
the correct index but `Anything here before ` will be ignored and assumed as
matching.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]