Skip to content

feat: run SQL statements inside an MCQA (SQLRT) session - #6

Merged
dingxin-tech merged 1 commit into
dingxin-tech:mainfrom
TonyStack2026:tony/em-mcqa-session
Sep 22, 2026
Merged

dingxin-tech merged 1 commit into
dingxin-tech:mainfrom
TonyStack2026:tony/em-mcqa-session

Conversation

@TonyStack2026

Copy link
Copy Markdown
Contributor

Why

M-B of the interface gap matrix: SQLExecutor(INTERACTIVE) and the JDBC MaxQA path could not be exercised locally at all — a SQLRT task instance was refused as "one SQL task required", and the instance information KV (?info) had no handler.

What

  • Instance/Job/Tasks/SQLRT creates a session instance that stays Running until the client stops it (PUT with Instance/Status=Terminated) or it idles past --session-ttl. Idle, not age: an interactive session is expected to outlive one statement.
  • GET/PUT .../instances/{id}?info&taskname= implements the sub-query channel: query / cancel writes, status / progress / result / result_<id> reads, answered with the object status codes com.aliyun.odps.Session polls on (2/4/5/6) so its loops terminate. Unknown keys, unknown instances and stopped sessions get structured answers, never an empty 200.
  • Statements execute with the server lock released, so a client polling during a long query sees running — the same shape as the service.
  • Sub-query answers are CSV whose first line is the column-name header, because CSVRecordParser#parse builds its schema from that line. The offline one-shot result format is untouched.
  • /capabilities declares mcqa, and the remaining gaps are named individually instead of riding along on a blanket mcqa entry.

Deliberate boundaries (stated, not silently missing)

Named-session attach (equal names create separate sessions — pinned by TestMCQASessionNamesDoNotAttach), MaxQA v2 under the /mcqa prefix, instance-tunnel download of sub-query results, per-statement statistics, and isolation of session-scoped SQL state.

Evidence

  • go test -race ./internal/... and go vet: green (9 new session cases, including ?info on a one-shot instance and idle expiry).
  • New tests/java/src/test/java/McqaSessionTest.java drives the real SDK (SQLExecutor, useInstanceTunnel(false)): 4/4 locally; UdfMetadataTest 4/4 and EmulatorTest 26/26 unchanged; tests/python/run.py 30/0 on a freshly started server built from this commit.
  • The Java suite caught two things the Go tests did not: an information body rooted at Instance (the SDK model carries @Root(name = "Instance"), not InstanceTaskInfo), and a Server.mu re-entrance in the instance sweep that deadlocked the whole emulator — /readyz included — as soon as a session was alive.

Notes for review

@dingxin-tech

Copy link
Copy Markdown
Owner

This branch has conflicts that must be resolved

M-B of the interface gap matrix: JDBC MaxQA and `SQLExecutor(INTERACTIVE)`
could not be exercised locally at all, because a `SQLRT` instance was refused
as "one SQL task required" and the instance information KV had no handler.

- `Instance/Job/Tasks/SQLRT` creates a session instance that stays `Running`
  until the client PUTs `Instance/Status=Terminated` or it idles past
  `--session-ttl` (idle, not age: an interactive session outlives one
  statement). Sessions are swept on idle time so they cannot wedge instance
  creation.
- `GET/PUT .../instances/{id}?info&taskname=` implements the sub-query channel
  the Java SDK actually uses: `query` and `cancel` writes, `status`,
  `progress`, `result` and `result_<id>` reads, answered with the SDK's own
  object status codes so its polling loops terminate. Statements execute with
  the server lock released, so a poll during a long query sees `running`.
- Sub-query answers are CSV with a column-name header line, which is what
  `CSVRecordParser#parse` builds the schema from; the one-shot offline result
  format is unchanged.
- Unknown instances, unknown information keys and stopped sessions return
  structured answers, never an empty 200.

Not simulated, and said so in docs and `/capabilities` rather than left silent:
named-session attach (equal names create separate sessions), MaxQA v2 under the
`/mcqa` prefix, instance-tunnel download of sub-query results, per-statement
statistics, and isolation of session-scoped SQL state.

Consumer evidence: `tests/java/src/test/java/McqaSessionTest.java` drives the
real SDK (4/4 against a locally built binary) and caught two things the Go
suite did not — a `Server.mu` re-entrance that deadlocked the emulator once a
session was alive, and information bodies rooted at `Instance`, not
`InstanceTaskInfo`. `go test -race ./internal/...` and `go vet` pass.
@dingxin-tech
dingxin-tech merged commit c6245c4 into dingxin-tech:main Sep 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants