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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.81-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.81-cp313-cp313-macosx_14_0_arm64.whl (659.0 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.81-cp312-cp312-macosx_15_0_x86_64.whl (668.6 kB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

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

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.81-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.81-cp311-cp311-macosx_14_0_arm64.whl (659.0 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.81-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.81-cp310-cp310-macosx_14_0_arm64.whl (659.0 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: hogql_parser-1.3.81.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.81.tar.gz
Algorithm Hash digest
SHA256 b1c85d045cafc691c4aced1162f4abc6818c0cd8d98f0ff3d840736061ee4858
MD5 207c6427928ea7bce054204516b0b5ed
BLAKE2b-256 a5b8edafa55c2d6e76046e43e70f32dd932f0faf88e145239f389cc532065a1d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d558da96f897599b7f9332023841f23760a84a0aa4d4efacb31a19268eb4d30
MD5 883c5763a62bc8634783c392f3669d32
BLAKE2b-256 0c0b8468fdfb3c5c4bb16cb4aeec45b8ffab64a25df48bcc567956a5a742c9fd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f50a9e174a68fbce1bad69ff64ebb80d6746407657a288d07b35ef556173d931
MD5 d704bb34a2f9d2c9cebbbdde2ae883b1
BLAKE2b-256 448a15bb1ac1c1c16e1cc7f3c8bcbd9c2a98a69a908c8238bfdad3c41659613d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 651d3d89aafe54e9b7a976cd31c1b024a7c9273fd7a48faeb0b08e9d50720a38
MD5 20fb25ada2cf2455e65148daf3e38e7f
BLAKE2b-256 f2ae877e69b576977fd9d7d368f85c88bd48ff4eb4403320f6ad76e277a30c11

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ce7959bcf2f4874a4dce68d4d74945e713c4791559aeab2858a20f6994be0166
MD5 658d9e70f2be61921b33ccb90df0c1f9
BLAKE2b-256 a35c5e07a4bff3f8e9dde654788ed7926457ae2efbd6b22dea3a27fff36e618a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2928c4bb57bcf28bdddfde7164c6d312c1408002f64e00428277c085f71a2194
MD5 04802e8ea67641e2dc9cf9ba178a62dd
BLAKE2b-256 744009f13a1074243d26daec22c0a4af18134f734c4238800206662a7f5a4cfb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d82bd9618ee210e5f0d8d79b9856ee26380b197e06e382cb261c539143ff57e7
MD5 550f83dc4d1b71c20b1eb6eef155fcba
BLAKE2b-256 19a8d3046a060f9b01422cd8e2a7fb7715e5c219f784e6e484c433cc3b4d39f3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 24c04c043ef1b4f640c801c9aedcae2c44675ba7b2919602c6d71cde28c031a3
MD5 6729242328ec8571bcd2993c02e69555
BLAKE2b-256 eb703b118da2014f05e73ff50f650190c728a3177379dae3a159b4ad1ff7b567

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7358497ab8c3aca787a3f038565eff26588bf0ab89fe2a4eb08c335112a0bf1b
MD5 ee2500221c50212c371636b4665efa83
BLAKE2b-256 913ff840321f5cef52d689ae9e87f37957f3c43af03d1333d761faabf60e4d72

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 adac29b7b7a9048e9f0d73597dc61e732483a15aa1be383a0a76a31ccf0e2e71
MD5 3dcc894949e77ab13d48eb9952390468
BLAKE2b-256 81deb94651c52169854b7e8c293dda7766659f731a76f775c738a5d84ca336a4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f7868ff211e731e74bb7ac549a9f8837c6de1a8b002154ea143c207ffac10086
MD5 36ecdcee4671d523e543c9d345454cb1
BLAKE2b-256 2d77aa8186eded5ef705c209c569823c026bcaa71408f5c7d719e6d552a401e3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 4ca34429004ca1e2b85a5eda56f681874b87ed5567c63d5d04631a89f81779a6
MD5 110dc18563f8afb19a8d5397b04d55f6
BLAKE2b-256 1d81109b2785b44f4623fce072fada5a7e9e8549d9e029c53a5c976730360841

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 5faef45315770ffea850247e1e507659656855643d395ce48c19b49ab9094ce4
MD5 0be8fd8b585c3e9dc2009df34ee2b0c8
BLAKE2b-256 30d6ff761267589cb162815fd530684c56f8ebd1247fe16f66b4af2d47ed71d5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 202cfc250e94e56980f609648ca9fea0b782ffcd9d523b5b17e8f8d7dee18b80
MD5 c51094b5c7664f479596e6258721eb7b
BLAKE2b-256 fb623343493feeb3b723cec093d5712a24c028aeeb47abc1c58e7dc3b1c3c679

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 94cef2841d08c8264e5f35cb92499aa5c932724979b1b8117a9d269039c853e4
MD5 4d5b731612e43b1c8405bd6700f07e06
BLAKE2b-256 e717611cb836eb643a5556eb37c89fa3d834283e6fb6b50e219e69e69f617b22

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 2c2ff99eaaad49d9a8f8499d75c29ee031ad09e0ea87b9f7f9a39957e03d4b2e
MD5 f603cced6136c3cf01286fdf23d72f3e
BLAKE2b-256 df020e09c0e0bb58d9c62dd419f130b27f165a57a2c9542f164737422632b201

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.81-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 842d8a17f39fb960caf8a699fbd5bf355d311b65eb6b74589b0e31d46984c707
MD5 48d63b0d8d435325f229af95580344ea
BLAKE2b-256 3e995453a9ae606f8f41acc104364ac207740db1edeff15c612f5735e9311a81

See more details on using hashes here.

Provenance

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

This release

1.3.81 This release

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