Musoq.Parser
17.0.12-alpha.1
See the version list below for details.
dotnet add package Musoq.Parser --version 17.0.12-alpha.1
NuGet\Install-Package Musoq.Parser -Version 17.0.12-alpha.1
<PackageReference Include="Musoq.Parser" Version="17.0.12-alpha.1" />
<PackageVersion Include="Musoq.Parser" Version="17.0.12-alpha.1" />
<PackageReference Include="Musoq.Parser" />
paket add Musoq.Parser --version 17.0.12-alpha.1
#r "nuget: Musoq.Parser, 17.0.12-alpha.1"
#:package Musoq.Parser@17.0.12-alpha.1
#addin nuget:?package=Musoq.Parser&version=17.0.12-alpha.1&prerelease
#tool nuget:?package=Musoq.Parser&version=17.0.12-alpha.1&prerelease
Musoq
Musoq — an investigation runtime that uses SQL.
Compose data, relate records, and describe text and binary formats in the same query language. Musoq performs the data operations and returns structured results that people and agents can inspect.
The fifteen examples below show the language's building blocks with complete queries and inline inputs. Their runnable files and expected results include provenance and prerequisites.
Compose data · Relate records · Aggregate and select · Recurse · Input formats · Source contracts
Define and compose data
Inline VALUES and expressions
Create a small relation, compute a projection, and filter its rows.
select s.Name as Name, s.Price * s.Quantity as Total
from values {
(Name: 'A', Price: 12, Quantity: 2),
(Name: 'B', Price: 8, Quantity: 1)
} s
where s.Price >= 10
order by Name
Result: A has Total = 24.
Parameters and local variables
Declare typed runtime parameters and reusable local values, then reference them with $.
param(minScore: int = 20)
let category: string = 'Books'
select s.Name as Name
from values {
(Category: 'Books', Name: 'A', Score: 30),
(Category: 'Books', Name: 'B', Score: 10)
} s
where s.Category = $category and s.Score >= $minScore
order by Name
Result with defaults: A. Parameter overrides are documented in the example companion.
CTE composition
Name an intermediate result and query it in another stage.
with totals as (
select s.Name as Name, Sum(s.Amount) as Total
from values {
(Name: 'A', Amount: 10),
(Name: 'A', Amount: 15),
(Name: 'B', Amount: 5)
} s
group by s.Name
)
select Name, Total
from totals
where Total >= 20
order by Name
Result: A has Total = 25.
Relate and expand records
LEFT JOIN
Keep left-side records even when the right side has no match.
select a.Name as Name, b.Score as Score
from values { (Id: 1, Name: 'A'), (Id: 2, Name: 'B') } a
left join values { (Id: 1, Score: 30) } b on a.Id = b.Id
order by Name
| Name | Score |
|---|---|
| A | 30 |
| B | NULL |
ANTI JOIN
Select left-side records for which no right-side match exists.
select a.Name as Name
from values { (Id: 1, Name: 'A'), (Id: 2, Name: 'B') } a
anti join values { (Id: 1) } b on a.Id = b.Id
order by Name
Result: B.
ASOF matching
Select the nearest preceding timestamp within an equality partition.
with errors as (
select e.Service as Service, e.At::datetime as ErrorTime
from values {
(Service: 'checkout', At: '2026-10-11T10:05:00'),
(Service: 'checkout', At: '2026-10-11T10:20:00')
} e
), deployments as (
select
d.Service as Service,
d.At::datetime as DeployedAt,
d.Version as Version
from values {
(Service: 'checkout', At: '2026-10-11T10:00:00', Version: 'v1'),
(Service: 'checkout', At: '2026-10-11T10:15:00', Version: 'v2')
} d
)
select e.ErrorTime as ErrorTime, d.Version as Version
from errors e
asof join deployments d
on e.Service = d.Service and e.ErrorTime >= d.DeployedAt
order by e.ErrorTime
| ErrorTime | Version |
|---|---|
| 2026-10-11T10:05:00 | v1 |
| 2026-10-11T10:20:00 | v2 |
CROSS APPLY over collections
Expand a collection into rows alongside its parent record.
with source as (
select s.Name as Name, array { 1, 2 } as Items
from values { (Name: 'A') } s
)
select s.Name as Name, item.Value as Value
from source s
cross apply s.Items item
order by Value
Result: (A, 1) and (A, 2).
Aggregate and select results
Conditional aggregates
Use FILTER to restrict one aggregate while another counts the whole group.
select
s.Component as Component,
Count(*) as Total,
Count(*) filter (where s.Level = 'ERROR') as Errors
from values {
(Component: 'api', Level: 'INFO'),
(Component: 'api', Level: 'ERROR'),
(Component: 'worker', Level: 'INFO')
} s
group by s.Component
order by Component
| Component | Total | Errors |
|---|---|---|
| api | 2 | 1 |
| worker | 1 | 0 |
Window ranking and QUALIFY
Rank within a partition, then filter window results in the same query block.
select
s.Category as Category,
s.Name as Name,
s.Score as Score,
RowNumber() over (
partition by s.Category
order by s.Score desc, s.Name
) as Position
from values {
(Category: 'Books', Name: 'A', Score: 30),
(Category: 'Books', Name: 'B', Score: 10),
(Category: 'Games', Name: 'C', Score: 20),
(Category: 'Games', Name: 'D', Score: 15)
} s
qualify Position = 1
order by Category
| Category | Name | Score | Position |
|---|---|---|---|
| Books | A | 30 | 1 |
| Games | C | 20 | 1 |
UNION ALL
Combine relations while retaining duplicate rows.
with combined as (
select a.Value as Value
from values { (Value: 1), (Value: 2) } a
union all
select b.Value as Value
from values { (Value: 2), (Value: 3) } b
)
select Value
from combined
order by Value
Result: 1, 2, 2, 3.
Recurse
Recursive CTEs and keyed UNION
Carry state across recursive generations, using selected columns as identity.
with recursive edges as (
select e.Service as Service, e.Dependency as Dependency
from values {
(Service: 'checkout', Dependency: 'payments'),
(Service: 'payments', Dependency: 'ledger'),
(Service: 'ledger', Dependency: 'checkout')
} e
), dependencies (Service, Depth) as (
select 'checkout', 0 from values { (Seed: 1) } seed
union (Service)
select e.Dependency, d.Depth + 1
from dependencies d
inner join edges e on d.Service = e.Service
)
select Service, Depth
from dependencies
order by Depth
| Service | Depth |
|---|---|
| checkout | 0 |
| payments | 1 |
| ledger | 2 |
Depth 0 is the starting service. The edge back to checkout adds no new identity, so the cycle terminates.
Declare input formats
Inline text formats
Describe the input format beside the query; its fields become available to the rest of the SQL.
text Entry {
Level: token,
_: whitespace,
Message: rest
};
select e.Level as Level, e.Message as Message
from values {
(Line: 'INFO ready'),
(Line: 'ERROR retry failed')
} s
cross apply Parse<Entry>(s.Line) e
order by Level
| Level | Message |
|---|---|
| ERROR | retry failed |
| INFO | ready |
Tolerant text handling
Combine TryParse with OUTER APPLY to keep rejected records in the result.
text Entry {
Prefix: literal 'OK:',
Message: rest
};
select s.Id as Id, p.Message as Message
from values {
(Id: 1, Line: 'OK:ready'),
(Id: 2, Line: 'bad')
} s
outer apply TryParse<Entry>(s.Line) p
order by s.Id
Result: (1, ready) and (2, NULL).
Inline binary formats
Declare field widths and a length-dependent payload, then select the interpreted fields.
binary Header {
Kind: byte,
Size: short le,
Payload: byte[Size]
};
with input as (
select FromHexToBytes('010300AABBCC') as Data
from system.dual()
)
select
h.Kind as Kind,
h.Size as Size,
Length(h.Payload) as PayloadBytes
from input i
cross apply Interpret<Header>(i.Data) h
Result: Kind = 1, Size = 3, PayloadBytes = 3. Requires the System provider.
Tagged payloads and the default-branch fixture provide an additional format variation.
Bind source contracts
TABLE and COUPLE
Bind a declared row contract to a source method under a query-local alias.
table Seed {
Dummy: string
};
couple system.dual with table Seed as Seeds;
select s.Dummy as Dummy
from Seeds() s
Result: Dummy = X. Requires the System provider; Dummy: string is the observed system.dual() source contract.
Advanced: how a query executes
flowchart LR
SQL[SQL] --> Planning[Binding and planning]
Planning --> Operations[Executable operations]
Operations --> Execution[Execution over sources]
Execution --> Results[Structured results]
Binding resolves fields, types, and functions. Planning selects how relationships and data operations execute. Executable operations then run over source records and produce structured results. Providers supply records and metadata; the runtime combines and shapes them.
See the architecture reference for the current planning and execution pipeline.
Language references and further documentation
- Core SQL language: syntax, relational behavior, functions, and diagnostics.
- Text and binary interpretation: format declarations and interpretation functions.
- TABLE and COUPLE: source contracts and query-local bindings.
- Runnable syntax examples: prerequisites, provenance, execution commands, and expected results.
- Engine development guide: implementation and contribution guidance.
Diagnostic-aware compilation reports intent mistakes, including null-sensitive predicates such as where Name not in ('Alice', NULL) and impossible implicit conversions (MQ5025). See the diagnostic contract and catalog.
License
Musoq is licensed under the MIT License, permitting commercial and non-commercial use.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (10)
Showing the top 5 NuGet packages that depend on Musoq.Parser:
| Package | Downloads |
|---|---|
|
Musoq.Schema
Package Description |
|
|
Musoq.Evaluator
Package Description |
|
|
Musoq.Converter
Package Description |
|
|
Musoq.DataSources.JsonHelpers
Package Description |
|
|
Musoq.DataSources.Sqlite
Lets you connect to SQLite databases and run SQL-style queries from Musoq, ideal for lightweight local data exploration. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 17.0.19 | 0 | 11/15/2026 |
| 17.0.18 | 186 | 11/12/2026 |
| 17.0.17 | 89 | 11/12/2026 |
| 17.0.16-beta.1 | 202 | 11/8/2026 |
| 17.0.16-alpha.1 | 412 | 11/3/2026 |
| 17.0.15-alpha.1 | 207 | 10/31/2026 |
| 17.0.14-alpha.2 | 221 | 10/24/2026 |
| 17.0.14-alpha.1 | 89 | 10/24/2026 |
| 17.0.13-alpha.1 | 228 | 10/17/2026 |
| 17.0.12-alpha.1 | 210 | 10/11/2026 |
| 17.0.11-alpha.1 | 191 | 9/17/2026 |
| 17.0.10-alpha.1 | 123 | 9/6/2026 |
| 17.0.9-alpha.1 | 223 | 9/2/2026 |
| 17.0.8-alpha.1 | 279 | 8/22/2026 |
| 17.0.7-alpha.1 | 136 | 8/18/2026 |
| 17.0.6-alpha.1 | 124 | 8/17/2026 |
| 17.0.5-alpha.1 | 240 | 8/8/2026 |
| 17.0.4-alpha.3 | 256 | 8/1/2026 |
| 17.0.4-alpha.2 | 106 | 8/1/2026 |
| 17.0.4-alpha.1 | 110 | 7/31/2026 |