Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ All notable changes to this project are documented here. The format follows

### Added

- The `rename` command, translated to one ES\|QL `RENAME` command carrying
every pair. Wildcard patterns (`EU* AS EMEA*`, `properties.* AS *`) parse but
are refused with `rename-wildcard`, because ES\|QL `RENAME` has no wildcard
form; renaming one field twice (`rename-duplicate`) and pairs that would
interact (`rename-conflict`: a target that is another pair's source, or one
target shared by two pairs) are refused because ES\|QL applies the pairs in
sequence and silently keeps one column on a collision. A pair whose names are
equal is a no-op. Later stages resolve a renamed field to its new name, and a
reference to a name that was renamed away is refused with
`rename-source-dropped`. PromQL refuses the stage with
`promql-unsupported-stage`.
- Parsing for both dialects is generated from ANTLR grammars
(`pkg/parser/spl1/grammar/SPL1.g4`, `pkg/parser/spl2/grammar/SPL2.g4`). The
generated Go is committed, so builds and releases need neither Java nor the
Expand Down Expand Up @@ -51,6 +62,9 @@ All notable changes to this project are documented here. The format follows

### Fixed

- Field names that spell an ES\|QL keyword (`where`, `stats`, `rename`) are
backtick-quoted wherever they are emitted, so a query that uses one produces
a valid command instead of a bare keyword.
- ES|QL aggregations now use the valid `alias = COUNT(*)` form instead of the
invalid `COUNT(*) AS alias`.
- Quoted phrases in a search are lowered to search terms rather than string
Expand Down
1 change: 1 addition & 0 deletions CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ conformance/
│ ├── eval/ expression lowering
│ ├── rex/ extraction lowering
│ ├── shaping/ table, fields, sort, head
│ ├── rename/ renaming fields, and the refusals
│ ├── mapping/ custom field and index mappings
│ ├── promql/ PromQL-specific output and refusals
│ ├── spl2/ SPL2 subset (`spl_version: 2`)
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ openspl transpile --strict -f savedsearch.spl
| `sort` | ✅ | ⚠️ | `SORT`; PromQL → `sort`, `sort_desc`, `topk`, `bottomk` |
| `head` | ✅ | ⚠️ | `LIMIT`; PromQL only after a sort |
| `bin` | ⚠️ | ⛔ | Derived `BUCKET` column |
| `rename` | ✅ | ⛔ | `RENAME`; wildcards are refused, not approximated |

**Recognized but not implemented** — `join`, `lookup`, `transaction`, `eventstats`, `streamstats`, `dedup`, `top`, `rare`, `chart`, `append`, `multisearch`, subsearches, and more. These return `unsupported-command` with a precise position rather than a misleading parse.

Expand Down Expand Up @@ -213,22 +214,22 @@ override.

| Collection | Queries | → IR | SPL→IR | → ES\|QL | SPL→ES\|QL | IR→ES\|QL | → PromQL | SPL→PromQL | IR→PromQL |
|---|---|---|---|---|---|---|---|---|---|
| `spl1` | 549 | 69 | 12.6% | 59 | 10.7% | 85.5% | 6 | 1.1% | 8.7% |
| `spl1-detections` | 2,171 | 15 | 0.7% | 6 | 0.3% | 40.0% | 0 | 0.0% | 0.0% |
| `spl1` | 549 | 71 | 12.9% | 61 | 11.1% | 85.9% | 6 | 1.1% | 8.5% |
| `spl1-detections` | 2,171 | 24 | 1.1% | 11 | 0.5% | 45.8% | 0 | 0.0% | 0.0% |
| `spl2` | 92 | 0 | 0.0% | 0 | 0.0% | — | 0 | 0.0% | — |
| **Total** | **2,812** | **84** | **3.0%** | **65** | **2.3%** | **77.4%** | **6** | **0.2%** | **7.1%** |
| **Total** | **2,812** | **95** | **3.4%** | **72** | **2.6%** | **75.8%** | **6** | **0.2%** | **6.3%** |

84 of 2,812 queries (3.0%) parse to the IR, 65 (2.3%) compile end-to-end to
95 of 2,812 queries (3.4%) parse to the IR, 72 (2.6%) compile end-to-end to
ES\|QL, and 6 (0.2%) to PromQL. The low SPL1 detection figure is parser
coverage, not emitter coverage — `tstats` alone accounts for 1,022 of the
refusals. Where a query does parse, ES\|QL emits for 77.4% and PromQL for 7.1%.
refusals. Where a query does parse, ES\|QL emits for 75.8% and PromQL for 6.3%.

The 78 PromQL refusals are deliberate. The largest single cause is
The 89 PromQL refusals are deliberate. The largest single cause is
`promql-no-aggregation` (21): the pipeline does not end in an aggregation, so
it produces rows rather than a time series. Another 33 use a stage with no
PromQL form — `eval` 17, `table` 9, `rex` 5, `fields` 2 — and 16 combine or
name an aggregation PromQL cannot express. The remaining 8 are refused over
row filters, free-text terms, or ordering.
it produces rows rather than a time series. Another 44 use a stage with no
PromQL form — `eval` 18, `table` 10, `rex` 7, `rename` 6, `fields` 2, `bin` 1 —
and 16 combine or name an aggregation PromQL cannot express. The remaining 8
are refused over ordering, free-text terms, or row filters.

Regenerate with `make corpus-report`; it prints this table from the corpus.

Expand Down
19 changes: 19 additions & 0 deletions conformance/cases/rename/conflict.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"description": "a pair whose target is another pair's source would depend on application order, so it is refused rather than sequenced",
"targets": {
"esql": {
"error": {
"code": "rename-conflict",
"line": 1,
"col": 25
}
},
"promql": {
"error": {
"code": "promql-unsupported-stage",
"line": 1,
"col": 13
}
}
}
}
1 change: 1 addition & 0 deletions conformance/cases/rename/conflict.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename a as b, b as c
3 changes: 3 additions & 0 deletions conformance/cases/rename/downstream.esql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM web
| RENAME `host.name` AS dest
| STATS count = COUNT(*) BY dest
1 change: 1 addition & 0 deletions conformance/cases/rename/downstream.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename host as dest | stats count by dest
19 changes: 19 additions & 0 deletions conformance/cases/rename/duplicate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"description": "renaming one field twice is refused at the second source; Splunk rejects the same query",
"targets": {
"esql": {
"error": {
"code": "rename-duplicate",
"line": 1,
"col": 28
}
},
"promql": {
"error": {
"code": "promql-unsupported-stage",
"line": 1,
"col": 13
}
}
}
}
1 change: 1 addition & 0 deletions conformance/cases/rename/duplicate.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename a as b, a as c
3 changes: 3 additions & 0 deletions conformance/cases/rename/mapped-target.esql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM web
| RENAME dest AS host
| STATS count = COUNT(*) BY host
12 changes: 12 additions & 0 deletions conformance/cases/rename/mapped-target.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"description": "the target of a rename is the name the query chooses, so it is emitted as written and later stages resolve it to that same column rather than through the field mapping",
"targets": {
"promql": {
"error": {
"code": "promql-unsupported-stage",
"line": 1,
"col": 13
}
}
}
}
1 change: 1 addition & 0 deletions conformance/cases/rename/mapped-target.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename dest as host | stats count by host
2 changes: 2 additions & 0 deletions conformance/cases/rename/multiple.esql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM web
| RENAME `host.name` AS dest, `log.file.path` AS src_ip
12 changes: 12 additions & 0 deletions conformance/cases/rename/multiple.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"description": "every pair of one Splunk rename becomes one pair of a single ES|QL RENAME, so the pairs apply together",
"targets": {
"promql": {
"error": {
"code": "promql-unsupported-stage",
"line": 1,
"col": 13
}
}
}
}
1 change: 1 addition & 0 deletions conformance/cases/rename/multiple.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename host as dest, source as src_ip
1 change: 1 addition & 0 deletions conformance/cases/rename/noop.esql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM web
1 change: 1 addition & 0 deletions conformance/cases/rename/noop.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename a as a
2 changes: 2 additions & 0 deletions conformance/cases/rename/quoted.esql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM web
| RENAME `user agent` AS ua
1 change: 1 addition & 0 deletions conformance/cases/rename/quoted.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename "user agent" as ua
2 changes: 2 additions & 0 deletions conformance/cases/rename/simple.esql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM web
| RENAME `host.name` AS dest
12 changes: 12 additions & 0 deletions conformance/cases/rename/simple.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"description": "rename becomes one ES|QL RENAME command; PromQL has no row-shaping form for it",
"targets": {
"promql": {
"error": {
"code": "promql-unsupported-stage",
"line": 1,
"col": 13
}
}
}
}
1 change: 1 addition & 0 deletions conformance/cases/rename/simple.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename host as dest
19 changes: 19 additions & 0 deletions conformance/cases/rename/source-dropped.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"description": "after a rename the old name no longer exists, so a later stage that references it is refused at the reference instead of emitting a column ES|QL does not have",
"targets": {
"esql": {
"error": {
"code": "rename-source-dropped",
"line": 1,
"col": 50
}
},
"promql": {
"error": {
"code": "promql-unsupported-stage",
"line": 1,
"col": 13
}
}
}
}
1 change: 1 addition & 0 deletions conformance/cases/rename/source-dropped.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename host as dest | stats count by host
19 changes: 19 additions & 0 deletions conformance/cases/rename/target-reused.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"description": "two pairs cannot rename different fields to one name; Splunk rejects it, and ES|QL would keep only the rightmost column without saying so",
"targets": {
"esql": {
"error": {
"code": "rename-conflict",
"line": 1,
"col": 33
}
},
"promql": {
"error": {
"code": "promql-unsupported-stage",
"line": 1,
"col": 13
}
}
}
}
1 change: 1 addition & 0 deletions conformance/cases/rename/target-reused.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename a as b, c as b
19 changes: 19 additions & 0 deletions conformance/cases/rename/wildcard-target.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"description": "a bare wildcard target is valid Splunk (strip the matched prefix) but has no ES|QL form, so it is refused at the target",
"targets": {
"esql": {
"error": {
"code": "rename-wildcard",
"line": 1,
"col": 33
}
},
"promql": {
"error": {
"code": "promql-unsupported-stage",
"line": 1,
"col": 13
}
}
}
}
1 change: 1 addition & 0 deletions conformance/cases/rename/wildcard-target.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename user_name as *
19 changes: 19 additions & 0 deletions conformance/cases/rename/wildcard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"description": "ES|QL RENAME has no wildcard form, so a wildcarded rename is refused at the field rather than guessed",
"targets": {
"esql": {
"error": {
"code": "rename-wildcard",
"line": 1,
"col": 20
}
},
"promql": {
"error": {
"code": "promql-unsupported-stage",
"line": 1,
"col": 13
}
}
}
}
1 change: 1 addition & 0 deletions conformance/cases/rename/wildcard.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index=web | rename EU* as EMEA*
Loading
Loading