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.80.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.80-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.80-cp313-cp313-manylinux_2_28_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.80-cp313-cp313-macosx_15_0_x86_64.whl (668.5 kB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

hogql_parser-1.3.80-cp313-cp313-macosx_14_0_arm64.whl (659.0 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

hogql_parser-1.3.80-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.80-cp312-cp312-manylinux_2_28_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.80-cp312-cp312-macosx_15_0_x86_64.whl (668.5 kB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

hogql_parser-1.3.80-cp312-cp312-macosx_14_0_arm64.whl (658.9 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

hogql_parser-1.3.80-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.80-cp311-cp311-manylinux_2_28_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.80-cp311-cp311-macosx_15_0_x86_64.whl (668.5 kB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

hogql_parser-1.3.80-cp311-cp311-macosx_14_0_arm64.whl (658.9 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

hogql_parser-1.3.80-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.80-cp310-cp310-manylinux_2_28_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.80-cp310-cp310-macosx_15_0_x86_64.whl (668.5 kB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

hogql_parser-1.3.80-cp310-cp310-macosx_14_0_arm64.whl (658.9 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: hogql_parser-1.3.80.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.80.tar.gz
Algorithm Hash digest
SHA256 aeca90ad82e9c0edb34004660eb896ce2b40a85cc9cacb8b896ab81903619141
MD5 f50ee6d212329d4005885c44dac405ed
BLAKE2b-256 9594042105b6f0d7ca1be9d4e5c42e48a53e6ecea378b3e7f0d71a73ceafe6a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80.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.80-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8f91f28f6efc3b479004810a301575ac686266ebf89455cfe5665596f3d9e741
MD5 0316d7ddbec5df793c7c9bf036f5588f
BLAKE2b-256 09f4b681b1b475beba2f29c4d33ac3dffa5673b3a721179cbd3ca23d4ef09b55

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4d2cf65ede9f45e49338d606299dbb26044fc9afa9820e3410481de527b43a35
MD5 0e4a7f31743a73a5b1bc1287bb5abdbb
BLAKE2b-256 5a7ea333ee452e435d21a5cbe9710e92fc7393896298cca624ffbe0db5e39e9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp313-cp313-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 7919592665342122b870c7aab7b36edec85824bc65fd37bdd4495b44b86acd53
MD5 76a4254d169419523358e574e3b511e7
BLAKE2b-256 83bb1cf6076e4158bb73b7ce74d6ca24afbf629c7dd13e6a82c484a3ab2d5e98

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f81984ed31776d717ba88ec508cbfc1575eefda08058c75e5503a1cb95de2eae
MD5 9f77e3fd3ee5a0bf38c771b463f1c6ff
BLAKE2b-256 e6bed31023f008b23fd656d88a64a981c51585b2657b2dc8aa0d18e38d1687c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b514c544de98842481f5103f8d9a2606dcbb2df4e4921a3f5a21eed9decf8c65
MD5 ef42408d867339503cd4b75a356ad3ca
BLAKE2b-256 94c942eff326a151258b80081ecba6754d02d46cb14a59cf4d4f32874e9dfa93

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5112cd9785e17366314f9b23c281fa0cfdea8a54249a2128c78f40cd5ef789e6
MD5 6ba4eefe4355b738379099f582e8e024
BLAKE2b-256 459d7d63ac6a4db2cdcb68abccab5ac5de133e8a8454ae72e5cc4baefbdcfa51

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp312-cp312-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 44fe6c15ad166f99b6be9d1fbc1e092159c1687d5427869689c5a567ffd73289
MD5 1b9fd245ec980e6d3d365b402b6523b8
BLAKE2b-256 f9064ab52a669df71eb17ca78716f92c7fdd1aa9f8e40a50e78cdf0a68761917

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 99b6c5c128354e9cc04d1aabc3cd0f55c96612907a3f9cd686a69f8be73885e3
MD5 1461b27dce937d96a6ec7187575f785d
BLAKE2b-256 fe9ffad0307a82eede3445173e2dfe143365b7bee25b0711679ad3fa9109b5c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 47714be3ec98a830b53f1fcb0e4626196c62f3623acc0dc343a5910450f0e2b6
MD5 ecfb63a12486e2b403897257358748db
BLAKE2b-256 008b1e8188a98178233438478f72c45696ad9b5153be910297bb62ab8367868b

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bc8bf3b051d17c6a9bbd9fd2acb08433d530845952e5ec4cabe061eb82c7d0df
MD5 32eef58daac57813a2b16177490202bc
BLAKE2b-256 c03cd41ea01a623b3fef39931d0cb96862c3a3ca6680eca01a5c8b4eb70874b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp311-cp311-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 7e4fc2fa2ea197480779d002fc4489870415c5e93a344f8b5fdc18154dc4a5f0
MD5 4c43840b6bb3812d01c3ed1458553d27
BLAKE2b-256 e3aed7a70ba5c94b1034638097d895e1e236658781dfab2f4b6be951198242ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 03bdd12590b1943955357e5f81de045761b270cc573920e77d08f43bf3d6550e
MD5 dfbdf4c38e3a94eaa878652d5ee32e73
BLAKE2b-256 2264618d88c4b88a9db2b90792e051da94cc0c4a377924a813dc9cd3034426a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7d84c800e4c09b1b50979be525774448b2fc110d1034e095574268f3735c6daf
MD5 ae98291ce06e982fd25313b67dcb3fb4
BLAKE2b-256 7cf6ad2e7b7c848541e4de3b26bbedf2f9e7a68b4bdd2937cc45ca218cddb75c

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d52eea1b3fb930007b9308f9312d4f98b3127d71f25a282a1d3708b61c113a0d
MD5 f1206f9c88044faab32612498a14f5be
BLAKE2b-256 c35620baf63f70f43f00f56ce05a203c7397dba898c0a0c745e3aeb334d8aee7

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp310-cp310-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 247589f71c720c30a69a40ec323402e9e5f4c3567df2ed7d8d99f252cfbe7147
MD5 7f7194a83afbc7ba1e41ab329d62242b
BLAKE2b-256 d9248b147e75de30b03d49fee473fa3214425b75e33e20aca19f962bc9ef43c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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.80-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for hogql_parser-1.3.80-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 5c27567961c2be3b2dc4bfc52350f4b677f1d40e74ffda7859503fe70f39fcb6
MD5 6a239d9079774fbb0981d75135f88d85
BLAKE2b-256 c069e64b3a969d93ee473b2d6c1f88a34a92845a30650678e7f141f33305f0e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for hogql_parser-1.3.80-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

1.3.83

17 files

1.3.82

17 files

1.3.81

17 files

This release

1.3.80 This release

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