Skip to content

feat(meos): add TTEXT_UPPER/LOWER/INITCAP NES operators (W95)#115

Closed
estebanzimanyi wants to merge 44 commits into
MobilityDB:mainfrom
estebanzimanyi:feat/nebula-codegen-w95-ttext-upper-lower-initcap
Closed

feat(meos): add TTEXT_UPPER/LOWER/INITCAP NES operators (W95)#115
estebanzimanyi wants to merge 44 commits into
MobilityDB:mainfrom
estebanzimanyi:feat/nebula-codegen-w95-ttext-upper-lower-initcap

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Wire ttext_upper, ttext_lower, and ttext_initcap as per-event scalar NES operators. Each takes (value:VARCHAR, ts:UINT64) and returns VARCHAR. The physical functions pre-allocate a 4096-byte arena buffer, call the MEOS function inside nautilus::invoke writing into the buffer, and write the actual byte length back via VarVal::writeToMemory — establishing the VARCHAR-return scalar pattern for this harness.

…aho-mqtt-cpp

The Nix environment provides paho-mqtt-cpp as a shared-only library and does
not include libmeos.  Four changes make the build pass:

- flake.nix: add stock paho-mqtt-c + paho-mqtt-cpp to baseThirdPartyDeps;
  pass -DNES_ENABLE_MEOS=OFF in both defaultPackage and devShell cmakeFlags.

- nes-plugins/CMakeLists.txt: introduce NES_ENABLE_MQTT and NES_ENABLE_MEOS
  options that gate the respective plugin subdirectories via
  activate_optional_plugin().

- nes-plugins/Sources/MQTTSource, nes-plugins/Sinks/MQTTSink: select
  PahoMqttCpp::paho-mqttpp3-static when available, fall back to the shared
  PahoMqttCpp::paho-mqttpp3 target (Nix only ships the shared variant).

- nes-physical-operators: gate all MEOS-specific add_plugin calls and the
  nes-meos link behind if(NES_ENABLE_MEOS) in three CMakeLists files
  (top-level, Functions/Meos, Aggregation/Function/Meos).

- CMakeLists.txt (root): declare option(NES_ENABLE_MEOS) and
  add_compile_definitions(NES_ENABLE_MEOS) before the nes-* subdirectory
  loop so the preprocessor symbol is visible to all sibling components.

- nes-query-optimizer/LowerToPhysicalWindowedAggregation.cpp: guard the
  TemporalSequenceAggregationPhysicalFunction include and instantiation
  with #ifdef NES_ENABLE_MEOS so the translation unit compiles and links
  when MEOS is disabled.
Add TFLOAT_SIN, TFLOAT_COS, TFLOAT_TAN as per-event scalar operators
following the extract-marshaler pattern from W25. Each takes (value:FLOAT64,
ts:UINT64), constructs a MEOS single-instant temporal via tfloat_in, applies
the trig C function, and extracts the FLOAT64 result via tfloat_start_value.

Logical and physical function pairs registered as NES plugins; SQL parser
extended with TFLOAT_SIN/COS/TAN tokens in the functionName rule and 2-arg
case blocks.
Add TFLOAT_CEIL, TFLOAT_FLOOR, TFLOAT_RADIANS, TFLOAT_DEGREES as per-event
scalar operators following the extract-marshaler pattern from W44. Each takes
(value:FLOAT64, ts:UINT64), constructs a MEOS single-instant temporal via
tfloat_in, applies the scalar C function, and extracts the FLOAT64 result via
tfloat_start_value. TFLOAT_DEGREES hardcodes normalize=false.

Logical and physical function pairs registered as NES plugins; SQL parser
extended with TFLOAT_CEIL/FLOOR/RADIANS/DEGREES tokens in the functionName
rule and 2-arg case blocks.
Add TFLOAT_SHIFT_VALUE and TFLOAT_SCALE_VALUE as per-event scalar operators
following the extract-marshaler pattern. Each takes (value:FLOAT64, ts:UINT64,
param:FLOAT64), constructs a MEOS single-instant temporal via tfloat_in, applies
the shift or scale, and extracts the FLOAT64 result via tfloat_start_value.

Logical and physical function pairs registered as NES plugins; SQL parser
extended with TFLOAT_SHIFT_VALUE/SCALE_VALUE tokens in the functionName rule
and 3-arg case blocks.
…s (W47)

Adds per-event NES operators backed by `tnumber_abs` (2-arg: value, ts)
and `tfloat_shift_scale_value` (4-arg: value, ts, shift, width). Each
operator constructs a single-instant tfloat, applies the MEOS function,
and returns the resulting double. Logical/physical function pairs, plugin
registrations, grammar tokens, and parser case blocks are included.
Adds per-event NES operators backed by `add_tfloat_float`,
`sub_tfloat_float`, `mul_tfloat_float`, and `div_tfloat_float`
(3-arg each: value, ts, scalar). Each operator constructs a
single-instant tfloat, applies the MEOS arithmetic function against
a constant scalar, and returns the resulting double. Logical/physical
function pairs, plugin registrations, grammar tokens, and parser
case blocks are included.
Adds per-event NES operators backed by `add_tnumber_tnumber`,
`sub_tnumber_tnumber`, `mul_tnumber_tnumber`, and `div_tnumber_tnumber`
(3-arg each: value1, value2, shared-ts). Each operator constructs two
co-instant tfloats, applies the MEOS element-wise arithmetic function,
and returns the resulting double. Logical/physical function pairs,
plugin registrations, grammar tokens, and parser case blocks are
included.
…MBER_TNUMBER NES operators (W50)

Adds per-event NES operators backed by temporal_round (3-arg: value, ts,
maxdd), tdistance_tfloat_float (3-arg: value, ts, d), and
tdistance_tnumber_tnumber (3-arg: value1, value2, ts). Each operator
constructs one or two co-instant tfloats, applies the MEOS function, and
returns the resulting double. Logical/physical function pairs, plugin
registrations, grammar tokens, and parser case blocks are included.
Adds per-event NES operators backed by add_tint_int, sub_tint_int,
mul_tint_int, and div_tint_int (3-arg each: value, ts, scalar_int).
Each operator constructs a single-instant tint, applies the MEOS
integer arithmetic function, and returns the resulting integer as
FLOAT64. Logical/physical function pairs, plugin registrations,
grammar tokens, and parser case blocks are included.
…E, TINT_SHIFT_SCALE_VALUE NES operators (W52)
…, TBIGINT_TO_TFLOAT, TINT_TO_TBIGINT, TFLOAT_TO_TBIGINT (W54)
…W57)

Adds per-event scalar NES operators for reversed-order float arithmetic on
tfloat temporals: ADD_FLOAT_TFLOAT, SUB_FLOAT_TFLOAT, MUL_FLOAT_TFLOAT,
DIV_FLOAT_TFLOAT. Each operator takes (scalar:float, value:float, ts:uint64)
and delegates to the corresponding MEOS add_float_tfloat / sub_float_tfloat /
mul_float_tfloat / div_float_tfloat kernel.
Adds per-event scalar NES operators for reversed-order integer arithmetic on
tint temporals: ADD_INT_TINT, SUB_INT_TINT, MUL_INT_TINT, DIV_INT_TINT. Each
operator takes (scalar:int, value:int, ts:uint64) and delegates to the
corresponding MEOS add_int_tint / sub_int_tint / mul_int_tint / div_int_tint
kernel.
… (W59)

Adds per-event scalar NES operators for reversed-order bigint arithmetic on
tbigint temporals: ADD_BIGINT_TBIGINT, SUB_BIGINT_TBIGINT, MUL_BIGINT_TBIGINT,
DIV_BIGINT_TBIGINT. Each operator takes (scalar:bigint, value:bigint, ts:uint64)
and delegates to the corresponding MEOS add_bigint_tbigint / sub_bigint_tbigint /
mul_bigint_tbigint / div_bigint_tbigint kernel.
Adds per-event scalar NES operators for exponential and logarithmic functions
on tfloat temporals: TFLOAT_EXP, TFLOAT_LN, TFLOAT_LOG10. Each operator takes
(value:float, ts:uint64) and delegates to the corresponding MEOS tfloat_exp /
tfloat_ln / tfloat_log10 kernel.
Adds six per-event ever-comparison scalar operators for tfloat against a
float threshold: EVER_EQ_TFLOAT_FLOAT, EVER_GE_TFLOAT_FLOAT,
EVER_GT_TFLOAT_FLOAT, EVER_LE_TFLOAT_FLOAT, EVER_LT_TFLOAT_FLOAT,
EVER_NE_TFLOAT_FLOAT. Each operator constructs a single-instant tfloat
from (value, ts), calls the corresponding MEOS ever_*_tfloat_float
kernel returning int, and emits the result as double. Logical and
physical function pairs, CMakeLists plugin registrations, AntlrSQL
grammar tokens, and AntlrSQLQueryPlanCreator case blocks are included.
…W62)

Adds six per-event always-comparison scalar operators for tfloat against
a float threshold: ALWAYS_EQ_TFLOAT_FLOAT, ALWAYS_GE_TFLOAT_FLOAT,
ALWAYS_GT_TFLOAT_FLOAT, ALWAYS_LE_TFLOAT_FLOAT, ALWAYS_LT_TFLOAT_FLOAT,
ALWAYS_NE_TFLOAT_FLOAT. Each operator constructs a single-instant tfloat
from (value, ts), calls the corresponding MEOS always_*_tfloat_float
kernel returning int, and emits the result as double. Logical and
physical function pairs, CMakeLists plugin registrations, AntlrSQL
grammar tokens, and AntlrSQLQueryPlanCreator case blocks are included.
Adds six per-event ever-comparison scalar operators for tint against an
int threshold: EVER_EQ_TINT_INT, EVER_GE_TINT_INT, EVER_GT_TINT_INT,
EVER_LE_TINT_INT, EVER_LT_TINT_INT, EVER_NE_TINT_INT. Each operator
constructs a single-instant tint from (value, ts), calls the
corresponding MEOS ever_*_tint_int kernel returning int, and emits the
result as double. Logical and physical function pairs, CMakeLists plugin
registrations, AntlrSQL grammar tokens, and AntlrSQLQueryPlanCreator
case blocks are included.
Adds six per-event always-comparison scalar operators for tint against an
int threshold: ALWAYS_EQ_TINT_INT, ALWAYS_GE_TINT_INT,
ALWAYS_GT_TINT_INT, ALWAYS_LE_TINT_INT, ALWAYS_LT_TINT_INT,
ALWAYS_NE_TINT_INT. Each operator constructs a single-instant tint from
(value, ts), calls the corresponding MEOS always_*_tint_int kernel
returning int, and emits the result as double. Logical and physical
function pairs, CMakeLists plugin registrations, AntlrSQL grammar
tokens, and AntlrSQLQueryPlanCreator case blocks are included.
…W65)

Adds six per-event ever-comparison scalar operators for tbigint against a
bigint threshold: EVER_EQ_TBIGINT_BIGINT, EVER_GE_TBIGINT_BIGINT,
EVER_GT_TBIGINT_BIGINT, EVER_LE_TBIGINT_BIGINT, EVER_LT_TBIGINT_BIGINT,
EVER_NE_TBIGINT_BIGINT. Each operator constructs a single-instant tbigint
from (value, ts), calls the corresponding MEOS ever_*_tbigint_bigint
kernel returning int, and emits the result as double. Logical and
physical function pairs, CMakeLists plugin registrations, AntlrSQL
grammar tokens, and AntlrSQLQueryPlanCreator case blocks are included.
… (W66)

Adds six per-event always-comparison scalar operators for tbigint against
a bigint threshold: ALWAYS_EQ_TBIGINT_BIGINT, ALWAYS_GE_TBIGINT_BIGINT,
ALWAYS_GT_TBIGINT_BIGINT, ALWAYS_LE_TBIGINT_BIGINT,
ALWAYS_LT_TBIGINT_BIGINT, ALWAYS_NE_TBIGINT_BIGINT. Each operator
constructs a single-instant tbigint from (value, ts), calls the
corresponding MEOS always_*_tbigint_bigint kernel returning int, and
emits the result as double. Logical and physical function pairs,
CMakeLists plugin registrations, AntlrSQL grammar tokens, and
AntlrSQLQueryPlanCreator case blocks are included.
…rators (W73-W78)

Adds 36 per-event NES operators for the reversed-argument scalar comparisons:
EVER_{EQ,GE,GT,LE,LT,NE}_{FLOAT_TFLOAT,INT_TINT,BIGINT_TBIGINT} (W73/W75/W77) and
ALWAYS_{EQ,GE,GT,LE,LT,NE}_{FLOAT_TFLOAT,INT_TINT,BIGINT_TBIGINT} (W74/W76/W78).
Each 3-arg operator takes (scalar, temporal_value, ts:UINT64), builds a single-instant
temporal from args 1-2, and calls the MEOS reversed-form function (e.g.
ever_eq_float_tfloat(double, Temporal*)) with the scalar as the first argument.
Wired across all five locations: logical/physical CMakeLists, AntlrSQL.g4 functionName
rule and lexer section, and AntlrSQLQueryPlanCreator.cpp includes and case blocks.
…rs (W79-W82)

Adds 8 per-event NES operators for tbool comparisons: EVER_EQ/NE_TBOOL_BOOL,
ALWAYS_EQ/NE_TBOOL_BOOL (temporal-first form) and EVER_EQ/NE_BOOL_TBOOL,
ALWAYS_EQ/NE_BOOL_TBOOL (reversed scalar-first form). tbool supports only EQ and NE
(no ordered comparisons). Each 3-arg operator takes (value:FLOAT64, threshold:FLOAT64,
ts:UINT64); the temporal arg maps non-zero double to 't', zero to 'f' and is parsed with
tbool_in(). The reversed form passes the scalar bool as the first argument to
ever_eq_bool_tbool / always_eq_bool_tbool. Wired across all five locations.
… TOR_{BOOL_TBOOL,TBOOL_BOOL,TBOOL_TBOOL} NES operators (W85)
…INT_TINT,TINT_INT,TEMPORAL_TEMPORAL} NES operators (W86)
…INT_TINT,TINT_INT,TEMPORAL_TEMPORAL} NES operators (W87)
Adds a per-event NES scalar operator TBOOL_TO_TINT backed by the MEOS
tbool_to_tint kernel. The 2-arg operator takes (value:FLOAT64, ts:UINT64),
builds a single-instant tbool via tbool_in, delegates to tbool_to_tint,
and extracts the tint result via tint_start_value returning FLOAT64.
Wired across logical/physical CMakeLists, AntlrSQL.g4 functionName rule
and lexer section, and AntlrSQLQueryPlanCreator.cpp.
Adds 28 per-event NES scalar operators covering ever/always/teq/tne comparisons
between a single-instant ttext and a text literal, in both argument orders:
EVER_{EQ,NE,GE,GT,LE,LT}_{TTEXT_TEXT,TEXT_TTEXT},
ALWAYS_{EQ,NE,GE,GT,LE,LT}_{TTEXT_TEXT,TEXT_TTEXT},
TEQ/TNE_{TTEXT_TEXT,TEXT_TTEXT}.

Each operator takes (textValue:VARCHAR, textRef:VARCHAR, ts:UINT64), builds a
single-instant ttext via ttext_in and converts the reference string to a text
datum via cstring_to_text, then delegates to the corresponding MEOS
ever_*/always_*/teq_*/tne_* kernel. ever/always variants return FLOAT64 1.0/0.0
directly; teq/tne extract the tbool result via tbool_start_value. Wired across
logical/physical CMakeLists, AntlrSQL.g4 functionName rule and lexer section,
and AntlrSQLQueryPlanCreator.cpp.
… (W94)

Adds 8 per-event NES scalar operators for ordered comparison between a
single-instant ttext and a text literal, in both argument orders:
TGE_TTEXT_TEXT, TGE_TEXT_TTEXT, TGT_TTEXT_TEXT, TGT_TEXT_TTEXT,
TLE_TTEXT_TEXT, TLE_TEXT_TTEXT, TLT_TTEXT_TEXT, TLT_TEXT_TTEXT.

Each operator takes (textValue:VARCHAR, textRef:VARCHAR, ts:UINT64),
builds a single-instant ttext via ttext_in, converts the reference
string via cstring_to_text, delegates to the corresponding MEOS
tge_*/tgt_*/tle_*/tlt_* kernel (returning a single-instant tbool),
extracts the boolean result via tbool_start_value, and returns
FLOAT64 1.0/0.0. Wired across logical/physical CMakeLists,
AntlrSQL.g4 functionName rule and lexer section, and
AntlrSQLQueryPlanCreator.cpp.
Wire ttext_upper, ttext_lower, and ttext_initcap as per-event scalar
NES operators. Each takes (value:VARCHAR, ts:UINT64) and returns VARCHAR.
The physical functions pre-allocate a 4096-byte arena buffer, call the
MEOS function inside nautilus::invoke writing into the buffer, and write
the actual byte length back via VarVal::writeToMemory — the first
VARCHAR-return scalar pattern in this harness.
@estebanzimanyi estebanzimanyi force-pushed the feat/nebula-codegen-w95-ttext-upper-lower-initcap branch from 3152178 to d1dd9b8 Compare June 23, 2026 06:57
@estebanzimanyi

Copy link
Copy Markdown
Member Author

Superseded by the generator-derived canonical surface: the Nix build fix (#171), the per-event operator generator (#185), and the 615-op generated surface — every operator this PR adds is regenerated from the MobilityDB master IDL and compile-verified there (generator==committed enforced by a drift-guard CI). Folding this wave into that deliverable; reopen if a specific operator needs attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant