Repository navigation
fix: refuse CREATE TABLE … AS rows in any input partition - #169
Closed
NoahKusaba wants to merge 1 commit into
Closed
NoahKusaba wants to merge 1 commit into
NoahKusaba wants to merge 1 commit into
Conversation
This crate can't write `CREATE TABLE … AS` rows, so `register_table` refuses input that has any. It checked only partition 0, but DataFusion passes the input with the query's partitioning. With rows only in later partitions, the statement succeeded and created an empty table.
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.
Which issue does this PR close?
Closes #168.
Rationale for this change
This crate can't write
CREATE TABLE … ASrows, soregister_tablerefuses input that has any. The check read only partition 0, but DataFusion passes the input with the query's partitioning. A query whose rows were all in later partitions created an empty table and reported success.What changes are included in this PR?
ensure_table_is_emptyreads every partition of the input in turn and stops at the first row. As before, it asks each partition for at most one row.Not changed:
CREATE TABLE … ASstill can't write rows, and the error message is the same.CREATE OR REPLACE TABLE t AS <query with rows>on an existingtstill deletest. DataFusion callsderegister_table, which drops the table, beforeregister_tablerefuses the rows, and nothing tells this crate that a replace is under way. Fixing that needs DataFusion to hand table creation to the catalog (Support async creation of schemas and tables in external catalog services datafusion#19634; Support delegation of schema and table creation to remote catalogs and schemas datafusion#26992 describes this crate's case).Are these changes tested?
Yes,
create_table_as_checks_every_input_partitionintests/catalog_provider.rs, through SQL:CREATE TABLE … ASfrom a source whose only row is in the middle of three partitions, after an empty batch, is refused.The test fails on
main. It also fails for a check that reads only the last partition, only the first batch of each partition, or that refuses any input with several partitions.Are there any user-facing changes?
Yes:
CREATE TABLE … ASnow fails for a query with rows outside its first partition, instead of creating an empty table.