This repository was archived by the owner on Jan 28, 2021. It is now read-only.
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
Incorrect projected fields #619
Closed
Description
This query:
SELECT uast_extract(
uast(blob_content, 'csharp', "(//csharp:BinaryExpression_AddExpression/Left/uast:String | //csharp:InterpolatedStringExpression//csharp:InterpolatedStringTextToken[1])[starts-with(normalize-space(@Value), 'SELECT') or starts-with(normalize-space(@Value), 'select') or starts-with(normalize-space(@Value), 'UPDATE') or starts-with(normalize-space(@Value), 'update') or starts-with(normalize-space(@Value), 'DELETE') or starts-with(normalize-space(@Value), 'delete') or starts-with(normalize-space(@Value), 'INSERT') or starts-with(normalize-space(@Value), 'insert') or starts-with(normalize-space(@Value), 'CREATE') or starts-with(normalize-space(@Value), 'create') or starts-with(normalize-space(@Value), 'ALTER') or starts-with(normalize-space(@Value), 'alter') or starts-with(normalize-space(@Value), 'DROP') or starts-with(normalize-space(@Value), 'drop')]"),
'@pos') AS positions,
repository_id,
file_path
FROM (
SELECT f.repository_id,
f.file_path,
b.blob_content
FROM (
SELECT *
FROM refs r
NATURAL JOIN commit_blobs cb
NATURAL JOIN blobs
WHERE r.ref_name = 'HEAD'
AND NOT IS_BINARY(blob_content)
) b
INNER JOIN (
SELECT repository_id, file_path, blob_hash
FROM refs r
NATURAL JOIN commit_files cf
WHERE r.ref_name = 'HEAD'
) f
ON b.blob_hash = f.blob_hash
AND b.repository_id = f.repository_id
WHERE language(f.file_path, b.blob_content) = 'C#'
) t
WHERE positions IS NOT NULL
Produces this plan:
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| plan |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Project(positions) |
| └─ Filter(NOT(positions IS NULL)) |
| └─ Project(t.blob_content, uast_extract(uast(t.blob_content, "csharp", "(//csharp:BinaryExpression_AddExpression/Left/uast:String | //csharp:InterpolatedStringExpression//csharp:InterpolatedStringTextToken[1])[starts-with(normalize-space(@Value), 'SELECT') or starts-with(normalize-space(@Value), 'select') or starts-with(normalize-space(@Value), 'UPDATE') or starts-with(normalize-space(@Value), 'update') or starts-with(normalize-space(@Value), 'DELETE') or starts-with(normalize-space(@Value), 'delete') or starts-with(normalize-space(@Value), 'INSERT') or starts-with(normalize-space(@Value), 'insert') or starts-with(normalize-space(@Value), 'CREATE') or starts-with(normalize-space(@Value), 'create') or starts-with(normalize-space(@Value), 'ALTER') or starts-with(normalize-space(@Value), 'alter') or starts-with(normalize-space(@Value), 'DROP') or starts-with(normalize-space(@Value), 'drop')]"), "@pos") as positions) |
| └─ SubqueryAlias(t) |
| └─ Project(f.repository_id, f.file_path, b.blob_content) |
| └─ Filter(language(f.file_path, b.blob_content) = "C#") |
| └─ InnerJoin(b.blob_hash = f.blob_hash AND b.repository_id = f.repository_id) |
| ├─ SubqueryAlias(b) |
| │ └─ Exchange(parallelism=32) |
| │ └─ Project(refs.repository_id, commit_blobs.blob_hash, blobs.blob_content) |
| │ └─ Filter(refs.repository_id = blobs.repository_id) |
| │ └─ SquashedTable(refs, commit_blobs, blobs) |
| │ ├─ Columns |
| │ │ ├─ Column(repository_id, TEXT, nullable=false) |
| │ │ ├─ Column(ref_name, TEXT, nullable=false) |
| │ │ ├─ Column(commit_hash, TEXT, nullable=false) |
| │ │ ├─ Column(repository_id, TEXT, nullable=false) |
| │ │ ├─ Column(commit_hash, TEXT, nullable=false) |
| │ │ ├─ Column(blob_hash, TEXT, nullable=false) |
| │ │ ├─ Column(repository_id, TEXT, nullable=false) |
| │ │ ├─ Column(blob_hash, TEXT, nullable=false) |
| │ │ ├─ Column(blob_size, INT64, nullable=false) |
| │ │ └─ Column(blob_content, BLOB, nullable=false) |
| │ └─ Filters |
| │ ├─ commit_blobs.blob_hash = blobs.blob_hash |
| │ ├─ refs.repository_id = commit_blobs.repository_id |
| │ ├─ refs.commit_hash = commit_blobs.commit_hash |
| │ ├─ refs.ref_name = "HEAD" |
| │ └─ NOT(IS_BINARY(blobs.blob_content)) |
| └─ SubqueryAlias(f) |
| └─ Exchange(parallelism=32) |
| └─ Project(refs.repository_id, commit_files.file_path, commit_files.blob_hash) |
| └─ Project(refs.repository_id, commit_files.file_path, commit_files.blob_hash) |
| └─ SquashedTable(refs, commit_files) |
| ├─ Columns |
| │ ├─ Column(repository_id, TEXT, nullable=false) |
| │ ├─ Column(ref_name, TEXT, nullable=false) |
| │ ├─ Column(commit_hash, TEXT, nullable=false) |
| │ ├─ Column(repository_id, TEXT, nullable=false) |
| │ ├─ Column(commit_hash, TEXT, nullable=false) |
| │ ├─ Column(file_path, TEXT, nullable=false) |
| │ ├─ Column(blob_hash, TEXT, nullable=false) |
| │ └─ Column(tree_hash, TEXT, nullable=false) |
| └─ Filters |
| ├─ refs.repository_id = commit_files.repository_id |
| ├─ refs.commit_hash = commit_files.commit_hash |
| └─ refs.ref_name = "HEAD" |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
The projected columns are not correct.