Repository navigation
fix(fts): skip rows COPY rejects with ignore_errors #123
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| -DATASET CSV empty-db | ||
|
|
||
| -- | ||
|
|
||
| # COPY with ignore_errors removes a rejected row before the FTS index has seen it. | ||
| -CASE CopySkipsDuplicateWithText | ||
| -SKIP_IN_MEM | ||
| -LOAD_DYNAMIC_EXTENSION fts | ||
| -STATEMENT CREATE NODE TABLE Doc(id INT64 PRIMARY KEY, body STRING); | ||
| ---- ok | ||
| -STATEMENT CREATE (:Doc {id: 1, body: 'apple'}); | ||
| ---- ok | ||
| -STATEMENT CALL CREATE_FTS_INDEX('Doc', 'idx', ['body']); | ||
| ---- ok | ||
| -STATEMENT COPY (UNWIND [1, 2] AS i RETURN i, CASE i WHEN 1 THEN 'banana' ELSE 'cherry' END) TO '${LBUG_EXPORT_DB_DIRECTORY}_dup.csv' (header=false); | ||
| ---- ok | ||
| -STATEMENT COPY Doc FROM '${LBUG_EXPORT_DB_DIRECTORY}_dup.csv' (header=false, ignore_errors=true); | ||
| ---- ok | ||
| -STATEMENT MATCH (d:Doc) RETURN d.id, d.body ORDER BY d.id; | ||
| ---- 2 | ||
| 1|apple | ||
| 2|cherry | ||
| -STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'cherry') RETURN node.id; | ||
| ---- 1 | ||
| 2 | ||
| -STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'banana') RETURN node.id; | ||
| ---- 0 | ||
| -STATEMENT MATCH (d:Doc {id: 2}) DELETE d; | ||
| ---- ok | ||
| -STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'cherry') RETURN node.id; | ||
| ---- 0 | ||
|
|
||
| # A rejected row without indexable text must not be indexed with the previous row's text. | ||
| -CASE CopySkipsDuplicateWithoutText | ||
| -SKIP_IN_MEM | ||
| -LOAD_DYNAMIC_EXTENSION fts | ||
| -STATEMENT CREATE NODE TABLE Doc(id INT64 PRIMARY KEY, body STRING); | ||
| ---- ok | ||
| -STATEMENT CREATE (:Doc {id: 1, body: 'apple'}); | ||
| ---- ok | ||
| -STATEMENT CALL CREATE_FTS_INDEX('Doc', 'idx', ['body']); | ||
| ---- ok | ||
| -STATEMENT COPY (UNWIND [2, 1, 3] AS i RETURN i, CASE i WHEN 2 THEN 'banana cherry' WHEN 1 THEN '' ELSE 'date' END) TO '${LBUG_EXPORT_DB_DIRECTORY}_dup_empty.csv' (header=false); | ||
| ---- ok | ||
| -STATEMENT COPY Doc FROM '${LBUG_EXPORT_DB_DIRECTORY}_dup_empty.csv' (header=false, ignore_errors=true); | ||
| ---- ok | ||
| -STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'banana') RETURN node.id, score; | ||
| ---- 1 | ||
| 2|0.353634 | ||
| -STATEMENT CALL DROP_FTS_INDEX('Doc', 'idx'); | ||
| ---- ok | ||
| -STATEMENT CALL CREATE_FTS_INDEX('Doc', 'idx', ['body']); | ||
| ---- ok | ||
| -STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'banana') RETURN node.id, score; | ||
| ---- 1 | ||
| 2|0.353634 | ||
|
|
||
| # The rejected row is the last one in the file; rows written after the COPY stay deletable. | ||
| -CASE CopyRejectsLastRow | ||
| -SKIP_IN_MEM | ||
| -LOAD_DYNAMIC_EXTENSION fts | ||
| -STATEMENT CREATE NODE TABLE Doc(id INT64 PRIMARY KEY, body STRING); | ||
| ---- ok | ||
| -STATEMENT CREATE (:Doc {id: 1, body: 'apple'}); | ||
| ---- ok | ||
| -STATEMENT CALL CREATE_FTS_INDEX('Doc', 'idx', ['body']); | ||
| ---- ok | ||
| -STATEMENT COPY (UNWIND [2, 1] AS i RETURN i, CASE i WHEN 2 THEN 'cherry' ELSE 'banana' END) TO '${LBUG_EXPORT_DB_DIRECTORY}_dup_last.csv' (header=false); | ||
| ---- ok | ||
| -STATEMENT COPY Doc FROM '${LBUG_EXPORT_DB_DIRECTORY}_dup_last.csv' (header=false, ignore_errors=true); | ||
| ---- ok | ||
| -STATEMENT CREATE (:Doc {id: 3, body: 'date'}); | ||
| ---- ok | ||
| -STATEMENT MATCH (d:Doc) WHERE d.id >= 2 DELETE d; | ||
| ---- ok | ||
| -STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'cherry') RETURN node.id; | ||
| ---- 0 | ||
| -STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'date') RETURN node.id; | ||
| ---- 0 | ||
| -STATEMENT CALL QUERY_FTS_INDEX('Doc', 'idx', 'apple') RETURN node.id; | ||
| ---- 1 | ||
| 1 | ||
Oops, something went wrong.
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.
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.
@zahariash the exact score match may be a bit brittle and require frequent updates due to code/data changes.
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.
Fixed in 38c08a2: the pinned score is gone. The test now builds one index before the COPY (maintained through it, so it would pick up the phantom document) and one after (which can't), and checks both score the document the same. Still fails with
2|Falsewithout the fix.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.
38c08a2 went onto the branch after the merge, so it never reached main. The same change is #126.