Skip to main content

HogQL Parser

ANTLR4-based parser for HogQL and Hog, available as both a Python C++ extension and a WebAssembly module for JavaScript/TypeScript.

Packages

Package Runtime Registry
hogql_parser CPython (native C++ extension) PyPI
@posthog/hogql-parser Any JS environment (WebAssembly) npm

Both packages share the same C++ parser core and ANTLR4 grammar, so they produce identical ASTs.

npm package (@posthog/hogql-parser)

Installation

npm install @posthog/hogql-parser

Usage

import createHogQLParser from '@posthog/hogql-parser'

const parser = await createHogQLParser()

// Parse a HogQL expression
const exprAST = JSON.parse(parser.parseExpr('1 + 2'))

// Parse a SELECT statement
const selectAST = JSON.parse(parser.parseSelect('SELECT event FROM events WHERE timestamp > now()'))

// Parse a Hog program
const programAST = JSON.parse(parser.parseProgram('let x := 42; return x;'))

All parse functions return JSON strings. On failure they return a JSON error object instead of throwing:

const result = JSON.parse(parser.parseExpr('!!!'))
if ('error' in result) {
  console.error(result.type, result.message) // e.g. "SyntaxError ..."
}

API

Method Description
parseExpr(input, isInternal?) Parse a HogQL expression
parseSelect(input, isInternal?) Parse a SELECT statement
parseOrderExpr(input, isInternal?) Parse an ORDER BY expression
parseProgram(input, isInternal?) Parse a Hog program
parseFullTemplateString(input, isInternal?) Parse a template string (f'...')
parseStringLiteralText(input) Unquote a string literal

Setting isInternal to true omits position information from the AST.

Python package (hogql_parser)

Installation

pip install hogql_parser

The Python package is a native C++ extension and requires a platform with prebuilt wheels (macOS and Linux, x86_64 and arm64).

Local development

pip install ./common/hogql_parser

Building from source

Python

pip install ./common/hogql_parser

WebAssembly

Requires the Emscripten toolchain and Ninja.

cd common/hogql_parser
npm run build

This compiles the parser to WASM and places the output in dist/.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hogql_parser-1.3.83.tar.gz (93.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.83-cp313-cp313-macosx_15_0_x86_64.whl (668.7 kB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

hogql_parser-1.3.83-cp313-cp313-macosx_14_0_arm64.whl (659.1 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

hogql_parser-1.3.83-cp312-cp312-manylinux_2_28_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

hogql_parser-1.3.83-cp312-cp312-manylinux_2_28_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.83-cp312-cp312-macosx_15_0_x86_64.whl (668.7 kB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

hogql_parser-1.3.83-cp312-cp312-macosx_14_0_arm64.whl (659.1 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

hogql_parser-1.3.83-cp311-cp311-manylinux_2_28_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

hogql_parser-1.3.83-cp311-cp311-manylinux_2_28_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.83-cp311-cp311-macosx_15_0_x86_64.whl (668.6 kB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

hogql_parser-1.3.83-cp311-cp311-macosx_14_0_arm64.whl (659.1 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

hogql_parser-1.3.83-cp310-cp310-manylinux_2_28_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

hogql_parser-1.3.83-cp310-cp310-manylinux_2_28_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.83-cp310-cp310-macosx_15_0_x86_64.whl (668.6 kB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

hogql_parser-1.3.83-cp310-cp310-macosx_14_0_arm64.whl (659.1 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file hogql_parser-1.3.83.tar.gz.

File metadata

  • Download URL: hogql_parser-1.3.83.tar.gz
  • Upload date:
  • Size: 93.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hogql_parser-1.3.83.tar.gz
Algorithm Hash digest
SHA256 918d01242c520133ef9ecfcb10777c1fad50bbefb33ec6fa4e223dd57bfaa0cd
MD5 18bb2f105f6a516219f7ef52ec6b66c7
BLAKE2b-256 1174454ad6b88a8413dcfd3d9836882bb07100c7104f34f4344fb007b98823c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83.tar.gz:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 491fe843ea4d386cd2f067ea77d78ee9431fc0ceedd224ac3b1ffe663ae2c166
MD5 65ccddfb791a4982dd0222b6b2eb332b
BLAKE2b-256 b6de13b7ad4db2c2fa87fb811b437bb511f128f71a3c6f8461684c8e0a08a165

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bc8d0b44e6bf012e28861fcc5d1dfc5b652c9c67c5a345de2bca281dd2119116
MD5 b4b6ac7900e42af0d8a34ad1b1137670
BLAKE2b-256 b1ed97179b82f94e548e577dc3fd78832d8d2ba1bab591051936cf2a15eea24a

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp313-cp313-manylinux_2_28_aarch64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp313-cp313-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 81b7f3dd65efdb5dc0e127d076b91163b1deee5caf69bb85d1cd025dec44df58
MD5 1574500a75e11f476e8428caeb027191
BLAKE2b-256 9dda5ba6cc064dc1793a27d875eb2cc00c46f633e64f361923bb1150feeca038

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp313-cp313-macosx_15_0_x86_64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 35c70d6e32c943ea2a0169ebecd82cf7ec87637991c5a6480cb04e1433613455
MD5 860f111a03c848271216bcab0028d6d7
BLAKE2b-256 424703db0642fb99ec9f1e85117c6a33deca82a5dd02ad1e0c61470c6c6ff75e

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ed3dec3b3f6d9c343665ea8ff128ef88ae79b08ec027a966c78a452b0b2299bd
MD5 b71105546e9199a94993687249a8b0bc
BLAKE2b-256 f262fb14211ec2f284423624265e8926da5c30f844b8e196a7dd7e1590891ea2

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0b6c7c0861fd7b1e53f6df0c0ca962b8ccec52fe4e03daa7638641f59ff0997b
MD5 f38a74eeb78b736e298edab599ecf4b7
BLAKE2b-256 5320ef0011c5dcbbd9bc43c0793bb8b3ae6158f464a3d2adb9a38647855db0a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp312-cp312-manylinux_2_28_aarch64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp312-cp312-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 e7ac2cd4460240482860e15fd0148f052e5cafd8366e752c05e174328d142762
MD5 81c8af8f4304c65faaa502b842a26a93
BLAKE2b-256 5fdd92290e06d185d7498a2319d9a67286592078fd62023c434409ab2cfb6642

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp312-cp312-macosx_15_0_x86_64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 dbcc74dbbc109f65f034bc57b969d142e7a351d60e0ec19df08b69240e45d2f3
MD5 a78504546eb58335c10f6002460ccac9
BLAKE2b-256 4b10b86fd0902cf81ac944df7aa1b7272f1d36043a38b72742d27629a21a8835

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 391456c9e555d66045dc1af93ebd3abf8699ab8d10dc0aeaabeecc4494fe6ecc
MD5 573dddd943dcc3a9f057b4bb9ae27630
BLAKE2b-256 63535fd4fefe89c21dfda69f562808395714720c4c678c67226ae2b889e1251e

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0c802a392f92267f67a205b4d937403d1888cb2c8b03b6298cae4f7df37f548f
MD5 a4799a375c23b1581a6c061cff8aafc7
BLAKE2b-256 158f641f488388fbeb9a51154c13e5fcef0ba2de435ad4899c2f8f33874d1280

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp311-cp311-manylinux_2_28_aarch64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp311-cp311-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 82ef2e5af4606569df78e6fb8ce4d1fedc7b55d3a6e97295c9f79647500a9ed7
MD5 6d4e285803864fe61a09f88e874d86f7
BLAKE2b-256 acc46e0b0a87a0c832dd720082c98c9e13f5ae35248177e0e7406fa31a0d15b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp311-cp311-macosx_15_0_x86_64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c05d1a580a08c8a9f5f018782f027bd3687a6ea5e8cd28a516288ad332fe679d
MD5 75a0fe8b7ce56222a36893807d68c59b
BLAKE2b-256 09ca7475ff4e874a164acde9ee198231c1435946d85d0a6dc17044f408a47633

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6cd9298185caab0baf1c580d9d993c4dcbdcaf7c8340e9e67c7d46225e1e49bc
MD5 032bc4dd49ca61dc9d6778335374a04c
BLAKE2b-256 c237262f926a69595571df8729637d130915b38bcbb040f7b504ffd225cd9bd1

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cbd2900243873f0516287f62c4de94c87239409d03ee3c4a48a8281d36bb62f5
MD5 86fddee33b0f0160e325d7b6859e2866
BLAKE2b-256 cb729ee748d55cc23bd5b42640221901b313e97322b40544e54531e22bcc6ca6

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp310-cp310-manylinux_2_28_aarch64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp310-cp310-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 2f16384912d583e65cfb91dafdf161449d6a6300d91ab0b83f94f8bec971a1de
MD5 1bfe5fd07c872baf437c0db2b00ceef4
BLAKE2b-256 9e30b4f7ca65b45cf7476b63a969fd047d12597745c7c6f20d423200f5fd4a4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp310-cp310-macosx_15_0_x86_64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hogql_parser-1.3.83-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.83-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8912a28724944e62a12f18315fe7dd310b365b138dd1b14ea45854f38d0262d9
MD5 9740bb7c9d34c15dfaa2a7892a15c2ca
BLAKE2b-256 9b7ae71a830f896a7a158026a44b1baccccfc0dd2bfb9c422a2b773aad622b64

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.83-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: build-hogql-parser.yml on PostHog/posthog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.3.84

17 files

This release

1.3.83 This release

17 files

1.3.82

17 files

1.3.81

17 files

1.3.80

17 files

1.3.79

17 files

1.3.78

17 files

1.3.77

17 files

1.3.76

17 files

1.3.75

17 files

1.3.74

17 files

1.3.73

17 files

1.3.72

17 files

1.3.71

17 files

1.3.70

17 files

1.3.69

17 files

1.3.68

17 files

1.3.66

17 files

1.3.65

17 files

1.3.64

17 files

1.3.63

17 files

1.3.62

17 files

1.3.61

17 files

1.3.60

17 files

1.3.58

17 files

1.3.57

17 files

1.3.53

17 files

1.3.52

17 files

1.3.51

17 files

1.3.50

17 files

1.3.49

17 files

1.3.48

11 files

1.3.47

17 files

1.3.46

17 files

1.3.45

17 files

1.3.44

17 files

1.3.43

17 files

1.3.42

17 files

1.3.41

17 files

1.3.40

17 files

1.3.39

17 files

1.3.38

17 files

1.3.37

17 files

1.3.35

17 files

1.3.34

17 files

1.3.33

17 files

1.3.32

17 files

1.3.31

17 files

1.3.30

17 files

1.3.29

17 files

1.3.28

17 files

1.3.26

17 files

1.3.24

17 files

1.3.23

17 files

1.3.22

17 files

1.3.21

17 files

1.3.20

17 files

1.3.19

17 files

1.3.18

17 files

1.3.17

17 files

1.3.16

17 files

1.3.15

17 files

1.3.14

17 files

1.3.13

17 files

1.3.11

17 files

1.3.10

17 files

1.3.7

17 files

1.3.6

17 files

1.3.5

17 files

1.3.4

17 files

1.3.2

17 files

1.2.13

17 files

1.2.12

17 files

1.2.11

17 files

1.2.10

17 files

1.2.9

17 files

1.2.8

13 files

1.2.0

13 files

1.1.2

13 files

1.1.1

13 files

1.1.0

13 files

1.0.460

13 files

1.0.459

13 files

1.0.458

13 files

1.0.457

13 files

1.0.456

13 files

1.0.455

13 files

1.0.454

13 files

1.0.452

13 files

1.0.50

13 files

1.0.49

13 files

1.0.47

13 files

1.0.46

13 files

1.0.45

13 files

1.0.44

13 files

1.0.43

13 files

1.0.42

13 files

1.0.41

13 files

1.0.40

13 files

1.0.39

13 files

1.0.38

13 files

1.0.37

13 files

1.0.36

13 files

1.0.35

13 files

1.0.34

13 files

1.0.33

13 files

1.0.32

13 files

1.0.31

13 files

1.0.30

13 files

1.0.29

13 files

1.0.28

13 files

1.0.27

13 files

1.0.26

13 files

1.0.25

13 files

1.0.23

13 files

1.0.21

13 files

1.0.20

13 files

1.0.19

13 files

1.0.18

13 files

1.0.15

13 files

1.0.14

13 files

1.0.13

13 files

1.0.12

13 files

1.0.11

13 files

1.0.10

13 files

1.0.8

13 files

1.0.7

13 files

1.0.6

13 files

1.0.5

13 files

1.0.4

13 files

1.0.3

13 files

1.0.2

13 files

1.0.1

13 files

1.0.0

13 files

0.1.12

13 files

0.1.11

13 files

0.1.10

13 files

0.1.9

13 files

0.1.8

13 files

0.1.7

13 files

0.1.6

13 files

0.1.5

13 files

0.1.4

13 files

0.1.3

13 files

0.1.2

10 files

0.1.1

13 files

0.1

9 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page