-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add update_record_with_output
function and tests
#130
Conversation
Signed-off-by: Andrew Lamb <andrew@nerdnetworks.org>
6eb4711
to
dc4b704
Compare
}) | ||
} | ||
|
||
// No update possible, return the original record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you look at update_record
? https://github.com/risinglightdb/sqllogictest-rs/blob/46752d1b536f186e3f976bdfce4968ce761ab230/sqllogictest-bin/src/lib.rs
I think they are highly alike, but it contains more updatable edge cases. How do you think the differences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I forgot out update_record
I think it is cleaner to update the Record
and then use the Display
logic to print it back out, rather than write to a new file directly. However, there is nothing wrong with generating the text directly (but there may be more chance of inconsistencies)
I am out of time for coding today, sadly, but I will think on this question and see if I can come to a conclusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xxchan if I want to refactor update_record
and avoid breaking your tests, what is the best way to do so? I have been running cargo test
but I guess that is not the only thing 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alamb I did the refactor. You can take a look whether it looks good to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a look - and it looks good to me @xxchan -- thank you 🙏
The only thing I would normally do is to write some more tests to cover these cases (and also illustrate how the updates work)-- perhaps I can do that as a follow on PR?
Signed-off-by: xxchan <xxchan22f@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wonderful @xxchan -- thank you for pushing this over the line
/// By default ([`default_validator`]), we will use compare normalized results. | ||
pub type Validator = fn(actual: &[Vec<String>], expected: &[String]) -> bool; | ||
|
||
pub fn default_validator(actual: &[Vec<String>], expected: &[String]) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
let record_output = runner.apply_record(record.clone()).await; | ||
match update_record_with_output(&record, &record_output, "\t", default_validator) { | ||
Some(new_record) => { | ||
writeln!(outfile, "{new_record}")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
expected_results, | ||
}, | ||
RecordOutput::Query { | ||
// FIXME: maybe we should use output's types instead of orignal query's types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I agree it should use the output query types
}) | ||
} | ||
|
||
// No update possible, return the original record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a look - and it looks good to me @xxchan -- thank you 🙏
The only thing I would normally do is to write some more tests to cover these cases (and also illustrate how the updates work)-- perhaps I can do that as a follow on PR?
@xxchan would you like me to add tests to this PR or do you plan to merge this one and have me add more tests as a follow on PR? |
Let's merge it first and improve it later, since it generally looks good and works well in my manual testing. |
Here is a follow on PR #131 |
Draft as it builds on #129Rationale
I want to be able to update Records given the output of a particular run (see apache/datafusion#4570)
Changes
update_record_with_output
functionI think this is my last planned PR to
sqllogictest
for a bit (I want to go try and integrated this into DataFusion upstream first)