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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.82-cp313-cp313-macosx_15_0_x86_64.whl (667.9 kB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

hogql_parser-1.3.82-cp313-cp313-macosx_14_0_arm64.whl (658.4 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.82-cp312-cp312-macosx_15_0_x86_64.whl (668.0 kB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

hogql_parser-1.3.82-cp312-cp312-macosx_14_0_arm64.whl (658.3 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.82-cp311-cp311-macosx_15_0_x86_64.whl (667.9 kB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

hogql_parser-1.3.82-cp311-cp311-macosx_14_0_arm64.whl (658.4 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.82-cp310-cp310-macosx_15_0_x86_64.whl (667.9 kB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

hogql_parser-1.3.82-cp310-cp310-macosx_14_0_arm64.whl (658.4 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: hogql_parser-1.3.82.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.82.tar.gz
Algorithm Hash digest
SHA256 0e626a938bf8b7aa386ae75816079f7861c7deebd423e17f2b717c63f7bdec5f
MD5 c1f9d7bb9b3dd24ae35f1db668547362
BLAKE2b-256 2bc3e2efe1ed9fe592d8bc7158da53700d537bbb6c16b29f18c5b3523c83bcc8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5c2b7d615a7699eea1a2b600b9890c9b85bd1f667aa1c4fe98e734fd7465f5c4
MD5 7be0efc3182eda6635f094ef0b04b5df
BLAKE2b-256 0a29c7c084a44769b8b3a18822db499e96873a0399087c1750f86eae582768e2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9701ea608f42f72c02c09adae41436f2a5d0bae53268d7d69e9a45c24eb2346a
MD5 7e372d83d85246872a4d980c835e16dd
BLAKE2b-256 05099fe3e013fe44460e9f7a390bd3adb428b77f4ad79e7903b4c8335216d60b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 34745288712326ec96d41acb4ac79026c32ab1dda22c1805725ab16ee1e6b14f
MD5 e08360a3db6bca90589032761ae492ba
BLAKE2b-256 95a6ca4227916a4533163df499c861f5572e1d968689a4b2ac25fec55a9b5fe9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 56ca8562be5b467d4f57edf8ad3f4c234e86796dfba95a1fe9974f86f51a308e
MD5 4e269203ae7bd87c9084d5fce26bffc4
BLAKE2b-256 e7b6281ecc67763893be82437c40b9a0cfaf2b48b9ebade887d6a803d3f47ee5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e33ad80883897795916c38ca36fb165f92ffa4e13bb45cd9d83e3ab913254759
MD5 2009000d005ec823e358c9a29ce891dd
BLAKE2b-256 9f9adf2cc32c264188736fe083cec6779eb162ddd3c460a24570924d47a25018

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 213f1453f4298c6826d84ad9be69fb748fed74eee4e42260eec034e48b7a47cb
MD5 5cb99ba82eaf9e5bcb963782274bdb7c
BLAKE2b-256 80ed4b74ae4a80adaaa12fc964f2db2b5bb7907f27b465f57628a499d0da49a4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 aa26d18a8d3af642b034406d8f5473df41b2cff3d15dd49dba3c26d4e55da6c5
MD5 f2aaabf7ea6a67f846e65d4c793efe6c
BLAKE2b-256 f572b1b710d213e92d172df0e98200e8b18018ae936777610ae38078e4472d72

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 44e69366e4b4a68156395e7e958a1ac044ce85504dd259793e092f07626e5ca7
MD5 7eedc49cd7eaaa9b9c994d2a76b71d1c
BLAKE2b-256 b71a5dd5e6f46fc892118f53f8462929ed7b842aad711c2534b4dd09e06c6fd0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bdb2e5071f2510cfb1366337e42c78c2c3d11f42bf9bc07a6ec09342550bbd12
MD5 8abe6cc47b0225a663d187a958f46ea8
BLAKE2b-256 6c33e3c59fb1fa58db23a1ce3dac0fc256d7ede6c4a31dc07edae840df58e61d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5076af26798136fa5ffccda0093f5cf17978d96ef243509e2ddaef367e580db2
MD5 587b26a4545224626314b1ae9b426f56
BLAKE2b-256 dcb927b2d16b8e054af89547afa7fcffb5c68d805dd584063d2017bb9cdc05c8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 10905726f6e0d628f3bcbd4504d0ff9a9c254dd3887990ef3c31ad15241c2256
MD5 d24aeeb616fb795372ac096c03c7fd45
BLAKE2b-256 5e9df189cf2264ac3bc1dd8d00f14e71a32ed454bb37607593ab02e10c3ce4bc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6bd53a32b1d11af0b9c83f023acc22d30282edb32095ab523ef459ac205d6913
MD5 abcd26a9ad40f00ff48c010a9e306266
BLAKE2b-256 18c79b3655f1e175d32bff377daeeb6da2df52358cca2359a84f19724aed2726

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 add2e3412fe328bc37a0bdc0947c416e70d57b7898dac9f630bb58f6b584b6cb
MD5 129e8f9ff74e676b7b623d910d5cda13
BLAKE2b-256 90b1ef5f183b91c8c2064deaa818fa5c12e8237df135b330fd65700385a726ea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 758080471395b6e11b8faf03d40a0b0a69653bb043ce25341ebd02b370b687eb
MD5 c7a31e9c46cfdb49ffc10626f8c00396
BLAKE2b-256 a01cc5c582490a0124249a2b46bc1583b5bb920be1a3fccc9130494b4eb62043

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 75212273386f511ab49dca996854515dfb252f3d9c22ad4a1232918c614f9d29
MD5 fade69f1a62a29aed07a42d55cf8941e
BLAKE2b-256 6e2c9518c02913d5590b5c5fc78edbf0942bdd4e68ace088444a43def7135481

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.82-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 dd991d054336333e31b8ce1ff565de20dca315a9314a4f69fe8c34a46ac22ac2
MD5 f49608e2621dec70f01fec191916b513
BLAKE2b-256 c5f9ffc3c803e3b7a2a9359a1427060544690b80bd0c8d596c84ff57e0b2a58d

See more details on using hashes here.

Provenance

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

This release

1.3.82 This release

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