Tags: cwida/lpts
Tags
Add data-dependent optimizer guard for LPTS LPTS previously serialized DuckDB's fully optimized logical plan, which meant data-dependent optimizer facts could be baked into generated SQL. For example, statistics propagation can turn a predicate into an empty-result plan based on the current table contents, which is not stable if the data later changes. Add lpts_enable_data_dependent_optimizers, defaulting to false. In conservative mode LPTS now runs a local optimizer pass sequence that skips optimizer passes whose decisions depend on current data, table statistics, cardinality estimates, row-group metadata, runtime dynamic filters, extension hooks, or common-subplan selectivity. Opting in keeps DuckDB's normal Optimizer::Optimize path. The conservative path does not mutate DuckDB's global disabled_optimizers setting. It respects any user-disabled optimizers through the normal Optimizer::OptimizerDisabled check, but skips the LPTS data-dependent set locally so concurrent connections cannot observe temporary optimizer setting changes and concurrent SET disabled_optimizers calls cannot be overwritten. Add a dedicated data_dependent_optimizers SQLLogicTest covering the default behavior, opt-in behavior, user-disabled optimizer preservation, planner-error restoration, data-independent empty results, stable join shape, and TopN opt-in. Update print_ast expectations to explicitly opt into statistics-dependent empty-result plans, and document the setting in the README. Verified with GEN=ninja make, make format-fix, focused optimizer tests, the full SQLLogicTest suite, and SQLStorm TPC-H sf=0.001 with zero incorrect, zero LPTS errors, and zero not-implemented results.