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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.79-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.79-cp313-cp313-macosx_14_0_arm64.whl (658.9 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.79-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.79-cp312-cp312-macosx_14_0_arm64.whl (658.8 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.79-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.79-cp311-cp311-macosx_14_0_arm64.whl (658.9 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

hogql_parser-1.3.79-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.79-cp310-cp310-macosx_14_0_arm64.whl (658.8 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: hogql_parser-1.3.79.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.79.tar.gz
Algorithm Hash digest
SHA256 fc45fd569f7af39ba75e28999c949b8342115de6bced295623160368e790eba0
MD5 d128f8f02a7d41d8506be678c27e51b7
BLAKE2b-256 0a96e2b47c796f1d1996b5c5b3f158e6371d24b3a05c9a1e189fa0b73eee2628

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 55fa5b1e432022e99ea3d89e80b4cdcc7ceb6e84c6db283e22e96779e22b8eac
MD5 2fe4276483367908a117f3f9bd3af7a0
BLAKE2b-256 4ac180ffbb7a18c351db92b9ace815425ee2c8309a7b30348481f3a3dbb4dcf3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5989d1a4bf8ffdd77b37df04b806d3119cbaca0fb83b41171207556b99eb90eb
MD5 b473ad02ea91dd6af76208a0129f9045
BLAKE2b-256 6a72e5c3fcc5b4317835c3adbc4c823959484d3c5097a12c020d60a7cf4d02fd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 94e573f8d22327804a6454a4f33e09fab390281ce6e5fc1c7e74fdd782591473
MD5 008e39c6732489bc1073d6c3df3bb176
BLAKE2b-256 f185ab98ba2a7359b0e2c9828378c0abc6b0939cfa7fec73f701c7988b71a3c1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 587bffc8f633702b207f1daadd3580672e78398c694833c4c1846d2d6624b878
MD5 8714829ce409f1e5ceca8a3cf6e5b603
BLAKE2b-256 c9e47471b47e7ea6cd216dc668de296c3fa6d87d53799beead9a31f52a65b1e2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 154a6bdcbcc4fd1c40910eed03d82ae5c7c74336e1a84e3a4cd167f47dbe9f0a
MD5 9b6710b712796b88af953cecc4657a8f
BLAKE2b-256 3fe04604a72f0d0a2cec32f54857b726e39e83f83d9bd3522dd422333318c91b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 020c0564fe65a498688f24746171cf814fb997b9f32b9aa7cebc47d7bdeb5e34
MD5 bc675e9a7972fe61f98722d5bb319a1f
BLAKE2b-256 dbfcb67faf31c6a103a32d50614b109be7e9a91e9b0d8ed563c9b43fc3b136fc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 16f04d1195a8520d058fc819fc3768971d305b476db998a33ff3300902fd9564
MD5 afe99c30455c8b11619cc07e2de9ec5b
BLAKE2b-256 426b7d8d3dfcf776cbe3934837d3fd21ad429981c75ce30106654e0c71afd2d7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 86cd82dfcbad03ae7a302f995b1931c14064eb889b7302177f185066dcde8932
MD5 835254669c132fbdee6164bb037919ed
BLAKE2b-256 a8939fb5481eb7549dee885b22e3a37cb67efc2d25f1a5fd964d163e64830e8f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d2f7a398640df94a97c35ba39b24fc04efbd999b9aa1f14872e4026079512b65
MD5 55c379ad5697a26df5ce1db2277c0d43
BLAKE2b-256 d3ed309a1f03efd4fcc94d7ede660862f01c868a7c9eae7d5386e5b928e57c99

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 031580caf759df0f379561de41da573852698c6902235aa9a583c0b51ee930c9
MD5 531678edf8227f5009749edcc5eda5aa
BLAKE2b-256 cf0dec3f11692974eba9db95af09dbea32fe34dfb638025b0775a632095257f4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 862a93f5e2a7d2c715b7fce9405f8022d6b260d8fd3a8854c8888c34e8d10ca3
MD5 bfc94cc63d959493d58e4c001ac5db35
BLAKE2b-256 03b593553b2ecad13e269ffbc3e0a7c8ded1761602b97f3812c5a4fbe980a7cd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 410eaee2e9370bb5cda675359c98aaedcd7841f0fb7c134f348d021f7c85a558
MD5 9cf6424be850d5f11a8b3d1018aa67f2
BLAKE2b-256 7e5e29b8a176988e6b4bd2369fc65d573f1f0c68459eafbf81dda8d34707051d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 547fed54dc5e3a0cb886e750decebf2da7fb326817077d5dbcb9af94088aa5bb
MD5 8a0b92fed8c370d6bfbd677f7a643f1b
BLAKE2b-256 b37d5776436238cc5d3b9b81b02001bb53880561e647a7a83ad0d41d8eaba9bd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 001e3e1bbeff77a75c8289374deea611768025305b3e2df950f71bc9a91b73fe
MD5 4a58e6eb38d1fe046b55f765f0a3f694
BLAKE2b-256 0e9ed922b74b5dc9584b4253850ace1e11809283514ce5d1e22448090af3260a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 8c9c09e17d68e023bf87c54809a063a73bc46ed98cef90c7d7fb9821aedf8850
MD5 c8e6365719ea888465f035a5c3cab7c8
BLAKE2b-256 9091759d3e6f1ebcd9518f19293c848e6465b508b5f864f61ee6485aeca5e263

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for hogql_parser-1.3.79-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d74029737a7461756d2f189305198aad462e4dd04aabaaf483ae513ad15bedba
MD5 639ee96c64290ae7104c9af0d503859c
BLAKE2b-256 d9627dd907f8395bd539b84441c0210d4635e7b6ddce749b65dac43bc6f058ee

See more details on using hashes here.

Provenance

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

1.3.80

17 files

This release

1.3.79 This release

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