Repository navigation
Description
Description
JSONLine external tables with object-shaped records cannot read projected columns from the third declared column onward. The first two columns can be queried normally, but reading the third or later column, or using COUNT(*), returns an internal index out of range error.
The same behavior occurs for a writable external table after inserting rows and for a read-only external table created over the emitted files.
Version
Reproduced three times on origin/main at cd8e175349932ccf4be8d388080a0c3310e538ac.
Steps to reproduce
Use a local stage directory and create a writable JSONLine external table:
CREATE STAGE jsonline_audit_stage URL = 'file:///tmp/jsonline-audit';
CREATE EXTERNAL TABLE ext_rows (
a INT,
b VARCHAR(20),
c TEXT,
d DECIMAL(10,2),
e JSON,
f BOOL
)
INFILE {
'filepath' = 'stage://jsonline_audit_stage/rows_*.jsonl',
'format' = 'jsonline',
'jsondata' = 'object',
'write_file_pattern' = 'stage://jsonline_audit_stage/rows_%U.jsonl'
};
INSERT INTO ext_rows VALUES
(1, 'one', 'alpha', 1.25, '{"n":1}', true),
(2, 'two', 'beta', 2.50, '{"n":2}', false);
-- Both queries complete normally.
SELECT a, b FROM ext_rows ORDER BY a;
-- Each of the following fails.
SELECT c FROM ext_rows ORDER BY a;
SELECT d FROM ext_rows ORDER BY a;
SELECT e FROM ext_rows ORDER BY a;
SELECT f FROM ext_rows ORDER BY a;
SELECT COUNT(*) FROM ext_rows;To check the read-only form, recreate ext_rows without write_file_pattern, pointing its filepath at the same rows_*.jsonl files. The projected-column and aggregate queries fail in the same way.
Actual behavior
SELECT a, b returns the two expected rows. Queries that access c or a later column, and COUNT(*), return error 20101 with an internal index out of range stack rooted in pkg/sql/colexec/external.getFieldFromLine.
Expected behavior
All declared JSONLine columns should be independently selectable, and aggregates should complete normally for both writable and read-only external tables.
Impact
Queries over a valid JSONLine external table can become unavailable solely because the selected projection changes. This affects existing files as well as files emitted through the writable external-table path.
Activity
fix(external): preserve JSONLine projection field positions (#26276)
Ariznawlll commentedon Jul 30, 2026
测试版本
main(截至 2026-07-30 16:30,Asia/Shanghai)41332062a6740978f269088a92ee362a888c7bd7etc/launch-with-proxy/launch.toml(2 CN + 1 TN + Proxy),SQL 入口127.0.0.1:6001原问题验证
创建 6 列 JSONLine object 外表,写入普通值与 NULL 行;第三列以后
c/d/e/f的投影、稀疏重排投影以及COUNT(*)均返回正确结果。将同一批文件改为只读外表后重复验证,完整黑盒 3/3 通过。Happy Path 覆盖
a,b和第三列以后的c,d,f均可独立读取。select f,c,a,e ... order by a desc的稀疏、逆序投影保持物理列映射正确。COUNT(*)=3均正确。Unhappy Path 覆盖
白盒验证
TestJSONLineObjectProjection*连续 3 轮通过;external 定向-race通过。回归测试
修复提交
6ffb9b524已扩展test/distributed/cases/stage/writable_external_table.sql,并加入reader_csv_projection_test.go。测试证据
完整 3 轮 SQL 结果、测试脚本、Proxy 黑盒日志、定向 UT 与
-race输出:https://gist.github.com/Ariznawlll/b8f1a22642a58fd5264482687534728b测试结论
测试通过。
fix(external): preserve JSONLine projection field positions (matrixor…
fix(external): preserve JSONLine projection field positions (matrixor…
fix(external): preserve JSONLine projection field positions (matrixor…