Keep original SQL for CreateExternalTable #12653
Draft
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.
Currently, the CreateExternalTable::definition field is just a stringfied version of the statement. Its slightly awkward to have the definition not be the same as what a user provided.
Which issue does this PR close?
Closes #12652
Rationale for this change
The CreateExternalTable::definition field isn't the same as what was provided to the SQL parser.
What changes are included in this PR?
This is a first draft at updating the CreateExternalTable::definition value to reflect what was provided.
Heads up, if folks are generally on board with the motivation here, I'm pretty sure we'll want to move the "render SQL between these two token indices" logic to live in the sqlparser crate. Here I've just implemented a less than optimal approach directly in
DFParser
to sketch out that the idea is vaguely possible. If folks are on board with this, I'd be more than happy to split that out and provide a proper implementation in the sqlparser crate that this change could then use.Are these changes tested?
Yes-ish. I've updated the sql parser tests to match. Though there are tests in other parts of the project that are now failing after the change that I've not investigated. I'll obviously go chase down all those loose ends if/when there's consensus that this change is wanted at all.
Are there any user-facing changes?
Yes, though I expect a few requests for changes as I just wrote enough to show that it could work before polishing up into a complete PR.
datafusion_sql::parser::Statement::CreateExternalTable
now has anOption<String>
element.I'm assuming the public enum change warrants the API change label, so I'll add that.