Skip to content

[C++][FlightRPC][ODBC] Support Decimal 32/64/256 result columns in data fetching #55888

Backlog

Description

@alinaliBQ

Describe the enhancement requested

The ODBC driver only supports Decimal128 result columns end to end. The data types decimal32, decimal64 and decimal256 are not supported for data fetching.

Note: GH-55748 (#55819) made the metadata calls (GetPrecision, GetOctetLength, GetDecimalTypePrecision, GetDecimalTypeScale) work for any decimal width by using is_decimal and DecimalType. Currently the data path is still Decimal128-only, so such a column reports its precision but cannot be fetched.

Where to implement

  • The exception is decimal256, as values above 38 digits can't be returned as SQL_C_NUMERIC, it likely needs to be implemented as string (SQL_WVARCHAR).

All under cpp/src/arrow/flight/sql/odbc/odbc_impl/:

  • util.cc: the Type::DECIMAL128 cases that map Arrow types to SqlDataType_DECIMAL and to CDataType_NUMERIC, the conversion-support check, and the default cast target (decimal128(38, 0)) only know about Decimal128. (Note that CDataType_NUMERIC maps back to Type::DECIMAL128 as the target type, which is correct and should stay.)
  • flight_sql_result_set_accessors.cc and accessors/decimal_array_accessor.{h,cc}: DecimalArrayFlightSqlAccessor is only instantiated for Decimal128Array and casts the type to Decimal128Type*. It needs to read 4, 8, or 16 byte values and fill SQL_NUMERIC_STRUCT.
  • util.cc decimal-to-string conversion (the original_type_id == Type::DECIMAL128 branch) uses scalar->ToString() and probably works for all widths, but only checks for Decimal128.

Tests

The mock (SQLite) server cannot return decimals, so suggest to write tests against the remote Dremio OSS docker instance (which is set up in ODBC Linux CI workflow).

Component(s)

FlightRPC, C++

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions