Skip to content

[Bug]: CSV and JSONLINE external paths cannot read or load DECIMAL256 columns #28590

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues, including open and closed issues.

Branch Name

main

Commit ID

fc621e3

Other Environment Information

  • MatrixOne: locally built from the commit above (8.0.30-MatrixOne-v1.3.0)
  • Verification date: 2026-09-10

Actual Behavior

CSV LOAD DATA cannot write any value into a DECIMAL256 target column (DECIMAL precision 39 through 76). It returns an internal error before writing the row:

ERROR 20101 (HY000): internal error: the value type DECIMAL256 is not support now

The failure starts exactly at the Decimal128/Decimal256 boundary:

  • The same LOAD DATA INLINE statement succeeds for DECIMAL(18,0) and DECIMAL(38,0) and preserves the maximum values exactly.
  • DECIMAL(39,0) fails even for a valid 39-digit value.
  • A normal INSERT into the same DECIMAL(39,0) table succeeds and preserves the same value exactly.
  • The wider DECIMAL(40,0) and scaled DECIMAL(50,10) targets fail through the same CSV load path.

No partial row is written when the error occurs.

Expected Behavior

CSV LOAD DATA should parse and append valid Decimal256 values using the target column's precision and scale, in the same way it already handles Decimal64 and Decimal128.

MatrixOne documents precision 39 through 76 as supported Decimal256 values, and the documented LOAD DATA syntax does not exclude this supported DECIMAL range.

Steps to Reproduce

DROP DATABASE IF EXISTS decimal256_load;
CREATE DATABASE decimal256_load;
USE decimal256_load;

-- Decimal128 boundary control succeeds.
CREATE TABLE d128(id INT PRIMARY KEY, d DECIMAL(38,0));
LOAD DATA INLINE FORMAT='csv',
DATA='1,99999999999999999999999999999999999999\n'
INTO TABLE d128 FIELDS TERMINATED BY ',';
SELECT * FROM d128;

-- Normal Decimal256 write succeeds.
CREATE TABLE d256(id INT PRIMARY KEY, d DECIMAL(39,0));
INSERT INTO d256 VALUES
  (1,999999999999999999999999999999999999999);

-- The same valid value through LOAD DATA fails.
LOAD DATA INLINE FORMAT='csv',
DATA='2,999999999999999999999999999999999999999\n'
INTO TABLE d256 FIELDS TERMINATED BY ',';
SELECT * FROM d256 ORDER BY id;

-- Scaled and wider Decimal256 targets fail through the same path.
CREATE TABLE wide(
  id INT PRIMARY KEY,
  d DECIMAL(40,0),
  s DECIMAL(50,10)
);
LOAD DATA INLINE FORMAT='csv',
DATA='1,9999999999999999999999999999999999999999,1234567890123456789012345678901234567890.1234567890\n'
INTO TABLE wide FIELDS TERMINATED BY ',';

Additional information

The CSV conversion switch in pkg/sql/colexec/external/external.go has explicit parsing and append cases for types.T_decimal64 and types.T_decimal128, but no types.T_decimal256 case. Decimal256 therefore reaches the default branch that emits the internal "not support now" error. The Parquet external path already has dedicated Decimal256 conversion support, which further isolates the missing implementation to CSV field conversion.

The Decimal64, Decimal128, Decimal256 boundary, normal-INSERT control, wider precision, and scaled Decimal256 cases were reproduced three times on the same latest-main build. Existing decimal LOAD DATA issues concern different Parquet conversion and precision-validation paths; no open or closed issue covering CSV Decimal256 loading was found.

Activity

  1. added this to the MO-202609 milestone on Sep 10, 2026
  2. added
    kind/bug
    on Sep 10, 2026
  3. added theissue type on Sep 10, 2026
  4. changed the title [-][Bug]: CSV LOAD DATA cannot write DECIMAL256 columns[/-] [+][Bug]: CSV external paths cannot read or load DECIMAL256 columns[/+] on Sep 10, 2026
  5. Ariznawlll commented on Sep 10, 2026

    @Ariznawlll
    CollaboratorAuthor

    继续沿同一 CSV external 算子验证后,影响范围不只 LOAD DATA:只读 external table 也无法解析 Decimal256,因而 SELECT 和 INSERT ... SELECT 都返回同一个内部错误。

    -- decimal256.csv:
    -- 1,999999999999999999999999999999999999999,1234567890123456789012345678901234567890.1234567890
    -- 2,-1,-0.0000000001
    
    CREATE EXTERNAL TABLE e256(
      id INT,
      d DECIMAL(39,0),
      s DECIMAL(50,10)
    ) INFILE{'filepath'='/path/decimal256.csv'}
    FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
    
    SELECT id, CAST(d AS CHAR), CAST(s AS CHAR) FROM e256 ORDER BY id;
    
    CREATE TABLE dst(
      id INT,
      d DECIMAL(39,0),
      s DECIMAL(50,10)
    );
    INSERT INTO dst SELECT * FROM e256;

    两条执行路径均返回:

    internal error: the value type DECIMAL256 is not support now
    

    使用独立、合法的 Decimal128 CSV 文件和 DECIMAL(38,0) / DECIMAL(38,10) 外表时,连续三次扫描均精确返回,INSERT ... SELECT 也保持原值。因此问题范围是 CSV external field conversion 缺少 Decimal256,而不是 LOAD DATA 语句层或输入文件访问问题。

  6. Ariznawlll commented on Sep 10, 2026

    @Ariznawlll
    CollaboratorAuthor

    格式对照进一步限定了问题边界:Parquet external 路径已实现 Decimal256。

    使用 Arrow decimal256(50,10) 文件,包含 40 位整数部分、负值和 NULL,执行:

    CREATE EXTERNAL TABLE ext(
      id INT,
      d DECIMAL(50,10)
    ) INFILE{'filepath'='/path/decimal256.parquet','format'='parquet'};
    
    SELECT id,CAST(d AS CHAR) FROM ext ORDER BY id;
    
    CREATE TABLE dst(id INT,d DECIMAL(50,10));
    LOAD DATA INFILE {'filepath'='/path/decimal256.parquet','format'='parquet'}
    INTO TABLE dst;
    SELECT id,CAST(d AS CHAR) FROM dst ORDER BY id;

    外表扫描和 Parquet LOAD DATA 连续三次均精确返回:

    1  1234567890123456789012345678901234567890.1234567890
    2  -1.0000000000
    3  NULL
    

    因此不应把问题归为 Decimal256 在 external 算子中的统一不支持;缺口具体位于 CSV field conversion switch。Parquet 已有专门的 Decimal256 parse/decode 分支。

  7. changed the title [-][Bug]: CSV external paths cannot read or load DECIMAL256 columns[/-] [+][Bug]: CSV and JSONLINE external paths cannot read or load DECIMAL256 columns[/+] on Sep 10, 2026
  8. Ariznawlll commented on Sep 10, 2026

    @Ariznawlll
    CollaboratorAuthor

    JSONLINE 也经过同一缺失的 Decimal256 field conversion 分支,因此影响范围需要从 CSV 扩展为 CSV + JSONLINE。

    CREATE TABLE d128(id INT,d DECIMAL(38,10));
    CREATE TABLE d256(id INT,d DECIMAL(50,10));
    
    -- 数字和字符串表示在 Decimal128 上均精确写入。
    LOAD DATA INLINE FORMAT='jsonline',
    DATA='{"id":1,"d":1234567890123456789012345678.1234567890}\n',
    JSONTYPE='object' INTO TABLE d128;
    
    LOAD DATA INLINE FORMAT='jsonline',
    DATA='{"id":2,"d":"1234567890123456789012345678.1234567890"}\n',
    JSONTYPE='object' INTO TABLE d128;
    
    -- Decimal256 的数字和字符串表示均到达相同内部错误。
    LOAD DATA INLINE FORMAT='jsonline',
    DATA='{"id":1,"d":1234567890123456789012345678901234567890.1234567890}\n',
    JSONTYPE='object' INTO TABLE d256;
    
    LOAD DATA INLINE FORMAT='jsonline',
    DATA='{"id":2,"d":"1234567890123456789012345678901234567890.1234567890"}\n',
    JSONTYPE='object' INTO TABLE d256;

    后两条连续三轮均返回:

    internal error: the value type DECIMAL256 is not support now
    

    Decimal128 对照中的 JSON number 和 JSON string 均保留 10 位 scale 的精确值;Decimal256 两种输入在写入前被拒绝,没有观察到先转浮点导致的另一类精度损失。代码层 CsvReader 共享 CSV/JSONLINE 行读取,再进入 external.go 的类型转换 switch,因此与原报告是同一个缺口。

  9. added
    severity/s1
    and removed on Sep 10, 2026
  10. iamlinjunhong commented on Sep 10, 2026

    @iamlinjunhong
    Contributor

    @VioletQwQ-0 已经在修了

  11. VioletQwQ-0 commented on Sep 16, 2026

    @VioletQwQ-0
    Collaborator

    @Ariznawlll 请验收本 issue,现正式转测,保持 OPEN 等待 QA 结论。

    修复 PR:#28612
    PR head:0d316a114d87de3108151ea5a04988dd0b075362
    main 合入 commit:60248a08953f7d55b80c4980284c3fd89cfd9aef

    开发验证:该 head 的 CI Required、Compose/Proxy BVT 均成功,合入后的 TKE BVT 成功。CI:https://github.com/matrixorigin/matrixone/actions/runs/34833344163 。最终 review 记录 decimal256_external_load.sql 25/25 通过。PR 正文中的旧 head/pending 快照不代表上述最新结果;这些自动化结果不等于正式 QA PASS。

    请在包含上述合入 commit 的版本验证 CSV、JSONLINE object/array 的 external SELECT、INSERT SELECT、LOAD DATA;覆盖精度 38/39 边界、40/50/76、正负数、scale/舍入、NULL/空值、JSON number/string 精度保持,以及非法输入/溢出后的无部分写入和后续有效执行。以 Parquet/普通 INSERT 为对照,保留精确数值断言。

    请记录实际测试 build/commit、环境拓扑与输入方式、各场景结果,并明确回复 PASS/FAIL;如失败附最小 SQL 和实际/期望结果。当前 QA 环境与部署版本待测试人记录,本次交接不声明部署验收完成。

  12. Ariznawlll commented on Sep 16, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:9572bd3311abb16d1df939956408a727bcf83eba
    • 部署方式:TKE,Proxy + 3 CN + 1 TN
    • 测试日期:2026-09-16

    原问题验证

    以 39 位整数写入 DECIMAL(39,0):CSV LOAD DATA INLINE 与 JSONLINE LOAD DATA INLINE ... jsontype='object' 各执行 3 次,均写入 1 行;查询结果与输入逐位一致,字符长度均为 39。DECIMAL(40,0) 与 DECIMAL(50,10) 的 CSV 宽精度/带 scale 控制也成功。

    Happy Path 覆盖

    1. DECIMAL(38,0) CSV 边界控制成功。
    2. DECIMAL(39,0) CSV、JSONLINE 及宽精度 CSV 路径均返回精确值。

    Unhappy Path 覆盖

    1. 未使用非法精度或溢出输入;本 issue 的验收点是受支持 DECIMAL256 的解析和写入保真,已验证无截断、无漏写。

    白盒验证

    不适用。本次为部署后的 MySQL 协议黑盒 SQL 验收;未以 UT 替代功能验证。

    回归测试

    已加入 motr PR #181:suites/14_issue_regression/t/issue_28590_decimal256_load.test,覆盖 CSV、JSONLINE、Decimal128 边界和 Decimal256 宽精度结果。

    测试证据

    motr PR #181 中的 SQL/result 为已执行输入与结果断言;环境实测三轮均返回 1 / 精确值 / 39。

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugphase/testingseverity/s1

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions