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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.84-cp313-cp313-macosx_15_0_x86_64.whl (668.2 kB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

hogql_parser-1.3.84-cp313-cp313-macosx_14_0_arm64.whl (658.7 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.84-cp312-cp312-macosx_15_0_x86_64.whl (668.2 kB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

hogql_parser-1.3.84-cp312-cp312-macosx_14_0_arm64.whl (658.7 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.84-cp311-cp311-macosx_15_0_x86_64.whl (668.1 kB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

hogql_parser-1.3.84-cp311-cp311-macosx_14_0_arm64.whl (658.6 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.84-cp310-cp310-macosx_15_0_x86_64.whl (668.1 kB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

hogql_parser-1.3.84-cp310-cp310-macosx_14_0_arm64.whl (658.6 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: hogql_parser-1.3.84.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.84.tar.gz
Algorithm Hash digest
SHA256 bb9caa3d0fcb0f6d7faadfdbf10db8d20f93c64be40a331f1134302994cc6de4
MD5 a9a757503f0c0664e0a76b06141e92ce
BLAKE2b-256 6c478899163a8a02ef242f816e9c9c62b376271591fe06cc4876304c65f2ecd3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 221ec153b9dc5810c7f74729a33b89ceef6142216ce1c7a837f52312ab02c713
MD5 9f4c82b9bfc4c2f06ceccf1aa69ab9c3
BLAKE2b-256 72071f500742a8fea6400d6676ae63204006e60f90dcd5525efbd10ea3dfd2ee

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4059b614279c4f58f43c74589fc27f0325a3e211044f0b961e49b92e39d1791b
MD5 4ac5284977177492213cc69a7a3e6e64
BLAKE2b-256 5625a5c9d05851c9587546908337fffbccd95abe3b616fd52732078d1ca18f31

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 4434287edb0d1adb55601466b6a04fe0eb48becf3cf8adbadc6f1e82b1d60546
MD5 5c15e344cbb4b5ac09cf1562639eb738
BLAKE2b-256 24f0d33bc908c5cf6597726483f05242ae06d113d3de9e20716adbe8020e28b9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9c4e050542a38e526ba28360382f241a747144fec0911b3f654ae72fbb3a0a55
MD5 f28bac2c38f1f74288234835b92fc51a
BLAKE2b-256 c7ee733c62d24180d3ce8a08a32ec059d5dce4b61b485ee24275086eca76d590

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3e5a76a51ad3619018830f1d6ea00ba36db6ee0629cb683466575d8dcae7b4fa
MD5 285f1207ac6a1e82b67a9e757efade51
BLAKE2b-256 b6048e59be4a5436659e3469105abd2880313f2255e192a0562dabc3f2122dad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 865a4d83f866c5c6206267db2d18d80e5a3e11401a307094c9599337a1bc39b3
MD5 a0e69d54e21cad746a064791e323b3fb
BLAKE2b-256 c6125dfd5bccc554d0c319b8441d894bf761e60482ed5ac45424a05c1a3a7434

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 1e1aa0aa2db019e7a03aa5d96d387d6bdad7033b867ba38c501f5b4e63d40ca0
MD5 f37a85ea66b844ac42e80ff03473e315
BLAKE2b-256 177bd956d98358135f70c9c00e72f304cfc7e420113f33cb77493d06a099f894

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 248bb92eb382e3e022af3100048a68ea4c1136418e4587215238216180dfbec5
MD5 7a48cac6d81ac5edec440270a57a95b5
BLAKE2b-256 a935e175e0813042dbccb0feb12d0c964c84f367cc89d3a8ec47959f9b7ee7b7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 88cc96cd7e98c173b269e1f7d5dce8a1b27ffa520dae1f8a390375c7ddc870ad
MD5 f1805aef4d05ba54983e89dd9df95c3e
BLAKE2b-256 3341759715182c0f98c315b31f8eaa26e292cf4fec264ffcfefa7256b491d8e1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 acf1f5cff113e40400e67c6750518d0c9122f9fafd920e891134d56ca169eab6
MD5 d72b6f6259f3b3ca85cb59e6d0434f0c
BLAKE2b-256 b95e8230198ace87a37bdd922cd432eec86cec9988f251bb3f28dd7cc9eac0bd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 cb3c05a71a0f0fa93229fe10bfa5ff24f4fb7b4b5dddf00a59331bc00a60a241
MD5 f1b7e937fb026b03acc6bb43e6fc5647
BLAKE2b-256 559b6f2b75214776d9fd35a2ea181dfb405e994f23e386441e85e2ed5c8cade6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 07b610763369b0fbd14c7f98b028f029261169aaab83b02bd7b7e1733dfa32a7
MD5 7552c36efe14fbf1d8002c549be50810
BLAKE2b-256 15ca359c49eba9eb3de48941f7cff75ea9649162f393b23c63723280f66a1799

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 265291c99853d5fb7f8d68ffbacde741d52e2a782dd0ec65db45298754c49458
MD5 79c6dba318865f7e336e844e3ddb0537
BLAKE2b-256 891384cebecc1d751fa0396e53da17c7fc7af914c2779f66b43d7764d6a290bb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4b6b70f451b4ebb1397a639f829a5df584879be40b7180b4571491c610680a93
MD5 c4426a6df0222bb239e8f4859c99451c
BLAKE2b-256 81b624ee019fdc38cca228789c39b8eb86377bb256134a6a8f7e79888e6011e5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 2d52ee1a8880c2f285fde87bfbfc8429eed66578b9681e1dec3c00d2ce9deff0
MD5 8c704c92296aab6dd9509a85b23b1a74
BLAKE2b-256 78e3ba24789c6016830633e0f3f100df0df0c4117e11346c523860c0661574c7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.84-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 2d82da5aeccb3bd0d8f80b4d0f64d27f024ec8193754546660bc86d0ce75756b
MD5 eade932ea49aaa331e5cc0fb3e3dfe78
BLAKE2b-256 3f198719ca7e6d387c672d86ef275ebaa9f0498daac4af74963eeb19e9767ba6

See more details on using hashes here.

Provenance

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

This release

1.3.84 This release

17 files

1.3.83

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