Skip to content

Conversation

@YoEight
Copy link
Owner

@YoEight YoEight commented Jan 4, 2026

Summary

Implements field AS TYPE syntax for explicit type conversion in EventQL queries. Supports built-in types (String, Int, Float64, Boolean, Date, Time, DateTime) and custom user-defined types.

Changes

Language Features

  • New AS operator with highest precedence
  • Case-insensitive type name matching
  • Parser validates RHS must be a type identifier

Type System

  • New type variants:
    • Type::Date - date values (e.g., 2026-01-03)
    • Type::Time - time values (e.g., 13:45:39)
    • Type::DateTime - datetime values (e.g., 2026-01-01T13:45:39Z)
    • Type::Custom(String) - user-defined types

API Changes

  • AnalysisOptions::add_custom_type() - builder method for custom types

Error Handling

  • ParserError::ExpectedType - when AS operator RHS is not a type
  • AnalysisError::UnsupportedCustomType - when custom type not registered

Usage

// Built-in types
let query = parse_query(
    "FROM e IN events PROJECT INTO { date: e.data.date as DATETIME }"
).unwrap();

// Custom types
let options = AnalysisOptions::default()
    .add_custom_type("CustomTimestamp");

let query = parse_query(
    "FROM e IN events PROJECT INTO { ts: e.data.ts as CustomTimestamp }"
).unwrap();
query.run_static_analysis(&options).unwrap();

@YoEight YoEight merged commit 0bc4ff2 into master Jan 4, 2026
4 checks passed
@YoEight YoEight deleted the type-conversion branch January 4, 2026 03:37
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.

2 participants