Latest Results
feat(ffi): add literal expression support (#7675)
## Summary
Add support for literal expressions in `vortex-ffi`
Motivation example:
Сallers need constants in expression trees to create scan predicates
that can be pushed down, for example:
```sql
age >= 67
price >= decimal(1512.0)
```
Introduce `vx_scalar` as an opaque ffi handle that exposes a typed
Vortex scalar (`DType` + `optional ScalarValue`) and
`vx_expression_literal` that allows to create literal expression nodes
from scalar handle
## API Changes
### Scalar:
`vx_scalar_new_*` creates a Rust `Scalar` and returns it as an owned
opaque boxed handle (`vx_scalar *`). APIs that take `const vx_scalar *`
borrow the handle; `vx_expression_literal` clones the underlying scalar
into the expression, so the caller can free the original handle after
construction
```c
vx_scalar *vx_scalar_new_u8(uint8_t value, bool is_nullable);
vx_scalar *vx_scalar_new_utf8(const char *ptr, size_t len, bool is_nullable, vx_error **err);
vx_scalar *vx_scalar_new_null(const vx_dtype *dtype, vx_error **err);
const vx_dtype *vx_scalar_dtype(const vx_scalar *scalar);
bool vx_scalar_is_null(const vx_scalar *scalar);
vx_scalar *vx_scalar_clone(const vx_scalar *scalar);
void vx_scalar_free(vx_scalar *scalar);
```
### Literal expression:
`vx_expression_literal` clones the scalar into the expression, so the
original scalar can be freed immediately after expression creation:
```c
vx_expression *root = vx_expression_root();
vx_expression *age = vx_expression_get_item("age", root);
vx_scalar *threshold_scalar = vx_scalar_new_u8(67, false);
vx_expression *threshold = vx_expression_literal(threshold_scalar, &error);
vx_scalar_free(threshold_scalar);
vx_expression *filter = vx_expression_binary(VX_OPERATOR_GTE, age, threshold);
vx_scan_options options = {};
options.filter = filter;
```
## Testing
Verifying new behavior and functionality works correctly
AI disclosure: Claude was used to add tests
<!--
Please describe how this change was tested. Here are some common
categories for
testing in Vortex:
1. Verifying existing behavior is maintained.
2. Verifying new behavior and functionality works correctly.
4. Serialization compatibility (backwards and forwards) should be
maintained or
explicitly broken.
-->
---------
Signed-off-by: Dergousov Maksim <dergousovmaxim99@gmail.com> Latest Branches
-35%
-42%
-32%
m7kss1:ffi/literal-expressions © 2026 CodSpeed Technology