---
name: DerivedColumn
lang: cpp
domain: core
version: "1.0.0"
algebraic: product
definition: |
  struct DerivedColumn {
      int         source_col;
      ColumnType  type;
      std::string name;
      std::string formula;
      int         lua_id;
      std::string compile_error;
  };
description: "Col custom dentro de un Stage. Modo 1: retipo (source_col >= 0, formula vacia). Modo 2: formula Lua (source_col == -1, eval por lua_engine sandbox)."
tags: [tql, derived, formula, lua, product-type]
uses_types: [ColumnType_cpp_core]
file_path: "cpp/functions/core/data_table_types.h"
---

## Notas

`formula` evaluada por row via `lua_engine` con `[col]` refs disponibles. Para SQL transpile (fase 11), formula debe estar dentro del Lua subset; sino `tql_to_sql` emite warning + skip col.

`lua_id` cachea la formula compilada en lua_engine entre eval calls.
