---
name: data_table_types
lang: cpp
domain: core
version: "1.1.0"
algebraic: product
definition: |
  namespace data_table {
    enum class ColumnType { Auto, String, Int, Float, Bool, Date, Json };
    enum class Op { Eq, Neq, Gt, Gte, Lt, Lte, Contains, NotContains, StartsWith, EndsWith };
    enum class AggFn { Count, Sum, Avg, Min, Max, Distinct, Stddev, Median, P25, P75, P90, P99, Percentile };
    enum class JoinStrategy { Left, Inner, Right, Full };
    enum class ViewMode { Table, Bar, Column, GroupedBar, StackedBar, Line, Area, ... };
    enum class ColorRuleKind { CellBg, CategoricalDot, NumericRange };  // v1.1.0
    struct Filter { int col; Op op; std::string value; };
    struct Aggregation { AggFn fn; std::string col; double arg; std::string alias; };
    struct SortClause { std::string col; bool desc; };
    struct DerivedColumn { int source_col; ColumnType type; std::string name, formula; int lua_id; std::string compile_error; };
    struct Stage { filters, derived, breakouts, aggregations, sorts; };
    struct StageOutput { cell_backing, cells, rows, cols, headers, types; };
    struct TableInput { name, headers, types, cells, rows, cols; };
    struct Join { alias, source, on, strategy, fields; };
    struct ColorStop { float position; std::string color; };  // movido arriba en v1.1.0
    struct DrillStep { int target_stage, filter_pos, prev_active_stage; Filter added; };  // movido arriba en v1.1.0
    struct ColorRule {                                                       // v1.1.0
      int col; std::string equals; unsigned int color;     // CellBg legacy
      ColorRuleKind kind;
      float dot_alpha, dot_radius_px;                       // CategoricalDot
      std::vector<std::pair<std::string,std::string>> dot_map;
      double range_min, range_max; float range_alpha;       // NumericRange
      std::vector<ColorStop> range_stops;
    };
    struct ViewConfig { x_col, y_cols, size_col, cat_col, primary_color, hist_bins, pie_radius, show_legend, ... };
    struct State {
      stages, active_stage, display, viz_config, extra_panels, joins, color_rules, col_visible, col_order, ...;
      // v1.1.0 — per-table UI state (antes en UiState singleton):
      bool stats_mode; std::vector<ColStats> stats_cache; /* stats_last_* */
      int sel_anchor_row/col, sel_end_row/col; bool sel_active, sel_dragging;
      int inspect_row; bool inspect_open;
      std::vector<DrillStep> drill_back, drill_forward;
    };
  }
description: "Tipos compartidos del stack TQL (Table Query Language). Enums y structs value-only sin dependencias de ImGui. Incluidos por lua_engine, compute_stage, compute_pipeline, join_tables y auto_detect_type. v1.1.0: ColorRuleKind + extended ColorRule (CategoricalDot, NumericRange); ColorStop + DrillStep movidos arriba para que State los contenga por valor; State absorbe stats/sel/inspect/drill que antes vivian en singleton interno (per-table state isolation, fix multi-table)."
tags: [tables, tql, types]
uses_types: []
file_path: "cpp/functions/core/data_table_types.h"
---

## Notas

Header-only. Todos los tipos son value types (no punteros opacos). `Stage` y `StageOutput` son la unidad de composicion del pipeline TQL — un stage filtra, agrupa y ordena; un StageOutput es el input del stage siguiente. `DerivedColumn.lua_id` es una referencia al registry interno de `lua_engine`; -1 significa no compilado. `State` es el estado completo del widget de tabla incluyendo stages, viz config, joins y display mode.
