gtopt/arrow_input_guards.hpp file

Fail-hard guards for Arrow tables loaded from Parquet / CSV.

gtopt's LP build cannot tolerate NaN in input field values — a NaN coefficient propagates into the matrix and every solver (CPLEX, HiGHS, CLP, CBC) either refuses to start or returns garbage. ±Infinity is acceptable (the LP layer's is_infinity() guard clamps anything ≥ solver_infinity to the backend's own sentinel, so the row/column bound becomes "unbounded"), but NaN has no meaningful LP interpretation.

It also cannot tolerate non-numeric columns from CSV input — Arrow's default type inference silently falls back to a string column when a value fails to parse as a number (e.g. "1,foo,3"), masking the data error. gtopt rejects any non-integer / non-floating CSV column.

This header exposes:

  • :func:gtopt::reject_nan_in_float_columns — called by the parquet readers in array_index_traits.cpp and sddp_cut_parquet.cpp immediately after Arrow materialises the table.
  • :func:gtopt::reject_non_numeric_columns — called by the CSV reader in array_index_traits.cpp after Arrow's type-inference pass. Integer columns are accepted (they implicitly convert to float downstream), as are Float32 / Float64 columns. Any other column type triggers a hard fail with file / column context.

Both throw std::runtime_error on the first violation so the user gets a precise diagnosis instead of an opaque solver failure later.

Namespaces

namespace gtopt