WIP: Implement multiline query output#230
Draft
davisp wants to merge 1 commit intorisinglightdb:mainfrom
Draft
Conversation
f33f3d8 to
0d936dd
Compare
This is a first pass at adding support for matching query output line by line without attempting to parse column types and values. This just relies on the database driver to return DBOutput::MultiLine variants. Ideally we could inform the driver on every SQL run, but I think that's part of a bigger refactor where we refactor the DB and AsyncDB traits so that they're aware of whether we're expecting statement or results output. Signed-off-by: Paul J. Davis <paul.davis@tiledb.com>
0d936dd to
569d8b4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a first pass at adding support for matching query output line by line without attempting to parse column types and values. The general idea here is that we can use a
query multilinedirective to compare query results line by line, rather than attempting to parse and validate individual values. The idea being that this allows custom database drivers to just output formatted tables like such:So far this PR appears to behave as intended by applying it to a personal project. The testing is extremely light, and there are a few different ways I could see implementing this feature. However, this seemed like the most direct approach after I spent at least 30m skimming the current implementation. I have verified that both matching and file updating work from the library implementation. I have not run this against the CLI version or attempted to add engine support. I can look into adding that as well if its desired.
The implementation is slightly wonky in that it just relies on the implementations of DB and AsyncDB to return a new DBOutput::MultiLine variant from the
run(sql: &str)method. However, given the current state of those traits, I don't think there's much better to be done at the moment.Speaking of those traits, and improving things, I think it'd be possible to do a progressive upgrade to those traits to add
run_statement,run_query, andrun_multiline_querymethods that default just callrun. However, I didn't feel like mixing up that level of change with this PR given this is already a bit half baked.Let me know if there's any interest in me fleshing this out into a full PR with lots more test coverage and any CLI/engine stuff that needs to happen. Also, thanks for sqllogictest! Its a great tool that's proving rather useful!