SQL processor: quoted table names and missing topics return zero rows with success

Open
#490 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, kafka, sql

Research direction

Start at the SQL processor’s parsing and execution path for table names, then trace how metadata discovery resolves topics and how missing topics are handled. Reproduce with the quoted and unquoted count(*) queries against existing and nonexistent topics using KAFSQL_METADATA_DISCOVERY=s3. Done when quoted existing topics return their counts and nonexistent topics return an error.

Written by the indexing model from the issue text.

Description

What happens

The SQL processor accepts a query, returns success, and yields zero rows when the table name is quoted, even if the topic has data. A topic that does not exist is handled the same way: success and zero rows, with no error.

Unquoted names of existing topics return the real count. The parser has not changed since v2.1.0 (confirmed on the #486 image and on main at fc9ed22). Clients that quote identifiers, which is required for a topic name that contains a hyphen, therefore get an empty result with no error.

Steps to reproduce

  1. Produce records to a topic, for example c-zstd with 2000 records, and to a topic whose name needs no quotes, for example kill1 with 3000 records.
  2. Start the SQL processor with KAFSQL_METADATA_DISCOVERY=s3 against that bucket.
  3. Run these queries:
SELECT count(*) FROM c-zstd LAST 24h;
SELECT count(*) FROM "c-zstd" LAST 24h;
SELECT count(*) FROM kill1 LAST 24h;
SELECT count(*) FROM "kill1" LAST 24h;
SELECT count(*) FROM nosuchtopic LAST 24h;

Actual

c-zstd:           2000
"c-zstd":         0 rows, status=success, segments=0, bytes=0
kill1:            3000
"kill1":          0 rows, status=success, segments=0, bytes=0
nosuchtopic:      0 rows, status=success, segments=0, bytes=0

Executor log:

query_complete type=select status=success duration_ms=1781 rows=1 segments=70 bytes=205258 query="SELECT count(*) FROM kill1 LAST 24h;"
query_complete type=select status=success duration_ms=172 rows=0 segments=0 bytes=0 query="SELECT count(*) FROM \"c-zstd\" LAST 24h;"
query_complete type=select status=success duration_ms=161 rows=0 segments=0 bytes=0 query="SELECT count(*) FROM \"kill1\" LAST 24h;"
query_complete type=select status=success duration_ms=171 rows=0 segments=0 bytes=0 query="SELECT count(*) FROM nosuchtopic LAST 24h;"

The quoted queries never scanned any segment. The same zero-row success for a quoted name happened on the #486 image as well.

Expected

  • SELECT count(*) FROM "c-zstd" LAST 24h and SELECT count(*) FROM "kill1" LAST 24h return 2000 and 3000.
  • A query against a topic that does not exist fails with an error, rather than succeeding with zero rows.

Version

main at fc9ed229387ae7172a4e22711da27be82636037b (v2.2.0). Also present on f7137999a082af8b23d6bab96433c967eba1bc0e (#486).

Dominant language
Go
Stars
59
Forks
16
Avg merge
5h 46m
Merged PRs (30d)
121

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from KafScale/platform

All issues in KafScale/platform

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.