Repository navigation
Description
Bug Report
Description
LOAD DATA INFILE ... format='parquet' handles Parquet DECIMAL values incorrectly when loading into a MatrixOne DECIMAL column with a smaller scale.
When the source Parquet column is decimal128(10,3) and the target MatrixOne column is decimal(10,2), the value is scaled incorrectly by one decimal digit instead of being rounded/truncated to the target scale.
For example:
- Parquet value
1.235becomes12.35in MOdecimal(10,2). - Parquet value
-1.235becomes-12.35. - Parquet value
12.345becomes123.45.
The same Parquet file loads correctly into MO decimal(10,3) and into varchar, so the source file itself is valid. The problem appears when converting a Parquet decimal to a target MO decimal with smaller scale.
Version
Reproduced on:
select git_version();
-- 2a008285eSteps to Reproduce
Generate a Parquet file with a decimal128(10,3) column:
from decimal import Decimal
import pyarrow as pa
import pyarrow.parquet as pq
path = '/tmp/decimal_scale.parquet'
vals = [Decimal('1.235'), Decimal('-1.235'), Decimal('12.345'), Decimal('0.001')]
pq.write_table(
pa.Table.from_arrays(
[pa.array(vals, pa.decimal128(10, 3))],
names=['dec_col'],
),
path,
)Run SQL:
drop database if exists parquet_decimal_scale_check;
create database parquet_decimal_scale_check;
use parquet_decimal_scale_check;
create table t_dec3(dec_col decimal(10,3));
load data infile {'filepath'='/tmp/decimal_scale.parquet', 'format'='parquet'} into table t_dec3;
select * from t_dec3 order by dec_col;
create table t_dec2(dec_col decimal(10,2));
load data infile {'filepath'='/tmp/decimal_scale.parquet', 'format'='parquet'} into table t_dec2;
select * from t_dec2 order by dec_col;
create table t_v(dec_col varchar(32));
load data infile {'filepath'='/tmp/decimal_scale.parquet', 'format'='parquet'} into table t_v;
select * from t_v order by dec_col;Actual Behavior
Loading into the same scale is correct:
t_dec3:
-1.235
0.001
1.235
12.345
Loading into varchar also preserves the source values:
t_v:
-1.235
0.001
1.235
12.345
But loading into decimal(10,2) shifts the decimal point:
t_dec2:
-12.35
0.01
12.35
123.45
Expected Behavior
Loading Parquet decimal128(10,3) into MO decimal(10,2) should round or truncate to the target scale, but should not shift the decimal point.
Expected values should be similar to:
-1.24 / -1.23
0.00 / 0.00
1.24 / 1.23
12.35 / 12.34
The exact rounding/truncation policy can follow MatrixOne's existing decimal cast behavior, but the magnitude should remain correct.
Additional Notes
This was found while validating the Parquet LOAD DATA INFILE feature. Other Parquet type mappings tested successfully, including signed/unsigned integers, float/double, matching-scale decimals, date/datetime/time, varchar/text, varbinary, JSON, bool, NULL, and several unhappy paths.
Activity
fix(external): rescale parquet decimals on load (#26212)
Ariznawlll commentedon Jul 28, 2026
已在最新
main分支完成验证,当前问题已修复。测试版本:
mainc8e443bf8610b2af4333ad943ba2075485b16cf881890b81a(fix(external): rescale parquet decimals on load)测试数据:
decimal128(10,3);1.235、-1.235、12.345、0.001、9999999.995、NULL。测试步骤:
DECIMAL(10,2),验证缩小 scale 时的转换结果。DECIMAL(10,3),验证相同 scale 保留原值。DECIMAL(11,4),验证扩大 scale 时正确补零。VARCHAR(32)作为对照,确认源 Parquet 值正确。关键结果:
加载到相同 scale、扩大 scale 和 VARCHAR 的对照结果也全部正确。未再出现
1.235 -> 12.35这种小数点整体右移的问题。已加入 motr 黑盒回归:
5ad59fd1d9786af1fb1c947046d1e6595465bebd14_issue_regression.issue_25473_parquet_decimal_scale该 case 内嵌固定 Parquet fixture,通过 MatrixOne stage 上传后执行真实
LOAD DATA ... format='parquet',不依赖 runner 额外安装 pyarrow。motr 在最新 main 上串行 3 轮和并行 3 轮均通过。fix(external): rescale parquet decimals on load (matrixorigin#26212)
fix(external): rescale parquet decimals on load (matrixorigin#26212)
fix(external): rescale parquet decimals on load (matrixorigin#26212)