Working extract-tables for multi-statement inputs #1227
Merged
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.
Description
Working extract-tables for multi-statement inputs, using an unholy combination of sqlparse and sqlglot.
sqlparse is more lenient and can chop up multiple statements even though it doesn't understand
\T. sqlglot is stricter, and chokes when it sees\T, but is better at the simple task of extracting table names from a valid statement, and provides a much better interface.We could also use
sqlglot.tokenize()and split on the semicolon token, which would be more verbose.Closes #1122, in which the table name was always given as
DUALwhen multiple statements were in the same input leading with\T sql-insert.Checklist
changelog.md.AUTHORSfile (or it's already there).