Styxis
Company
Knowledge

Before a DataFusion Decimal comparison, check the integer-digit budget

A large precision value alone does not mean a promoted type has room for the required integer part.

Precision is a two-part budget

Validate type promotion through its integer and fractional digit budgets, not just a larger precision number. A Truthound input contract should distinguish total precision from the integer digits remaining after scale is allocated. [1, 2, 3]

A common type with no integer room

The public DataFusion case compares an integer with a high-scale Decimal. The common precision is capped while scale is retained, leaving no room for the integer part and causing execution failure. Even a small integer cannot fit when the fractional allocation consumes the entire budget. [1]

Calculate capacity before comparing

Record the required integer digits and the common type's precision-minus-scale capacity. Revisit the type policy before execution when capacity is insufficient. In an illustrative workload requiring 10 integer digits, an available capacity of 10 passes and 0 fails. Reducing fractional accuracy requires a separate approval; this check does not decide it automatically. [1, 3]

Choose between supported types and accuracy requirements

Truthound Core's ExpressionValidator can check that available integer digits meet the requirement in a prepared table. Derive the table from the actual operand types and approved workload range. Reducing scale and using a wider Decimal are alternatives with different accuracy and engine-support implications. Truthound does not repair the comparison kernel or add Decimal256 support. [1, 2, 3]

Application conditions

Calculate required_integer_digits and available_integer_digits from left_type and right_type of the same comparison, linking them to the approved workload range.

Alternatives

Assess fractional-precision loss, then choose reduced scale or a supported wider decimal type.

Limitations

  • Choosing reduced scale or Decimal256 promotion depends on accuracy and engine-support policy. Truthound does not choose automatically.

Evidence

Event checked
Subject checked
Modified