Wvlet Syntax Highlighting - CDN Test

This page tests the Wvlet language syntax highlighting using the CDN-hosted package from npm.

Package: @wvlet/highlightjs-wvlet | CDN: Browse Files | GitHub: Source Code

ℹ️ Note: The Wvlet language is automatically registered when the script loads. Both class="language-wvlet" and class="language-wv" work.

Basic Model Definition

-- Basic model definition
model User = {
  from 'users.json'
  select name, age, email
  where age > 18
}

-- Using the model
from User
where name like 'John%'
order by age desc
limit 10

Advanced Query with Functions

model Sales(year: Int) = {
  from 's3://bucket/sales/year=${year}/*.parquet'
  select 
    product_id,
    sum(quantity) as total_quantity,
    avg(price) as avg_price,
    count(*) as transaction_count
  group by product_id
  having total_quantity > 100
}

-- Join with another model
from Sales(2024) s
join Product p on s.product_id = p.id
select 
  p.name,
  s.total_quantity,
  s.avg_price * s.total_quantity as revenue
order by revenue desc

String Interpolation and Operators

model Report = {
  from Orders
  select 
    customer_id,
    "${order_date}" as date,
    price * quantity as total,
    case 
      when total >= 1000 then 'Premium'
      when total >= 500 then 'Standard'
      else 'Basic'
    end as tier
  where status != 'cancelled' and price > 0
}

Test Assertions

-- Test data quality
test "User data validation" should {
  from User
  test _.size should be > 0
  test _.columns should contain 'email'
  test _.where(age < 0).size should be 0
}

Using 'wv' Alias (Alternative)

-- This uses class="language-wv" for backward compatibility
model OrderSummary = {
  from Orders
  group by customer_id, date_trunc('month', order_date) as month
  agg
    total_orders = count(*),
    total_revenue = sum(amount),
    avg_order_value = avg(amount)
}