pathwaycom/pathway · error · RuntimeError

parsing {query} failed

Error message

parsing {query} failed

What it means

Pathway's SQL engine (pathway.sql / pw.sql) parses the query with sqlglot.parse_one. If sqlglot returns None — which happens for an empty or whitespace-only query string — the wrapper raises RuntimeError('parsing {query} failed'). This is a pre-execution failure: the query never reaches Pathway's SQL-to-table translation.

Source

Thrown at python/pathway/internals/sql/__init__.py:77

    - INTERSECT does not support INTERSECT ALL.
    - COALESCE, IFNULL are not supported.
    - FULL JOIN and NATURAL JOIN are not supported.
    - CAST is not supported

    '''

    with optional_imports("sql"):
        import sqlglot
        import sqlglot.expressions as sql_expr
        from sqlglot.errors import OptimizeError
        from sqlglot.optimizer import qualify_columns

        from pathway.internals.sql.processing import _run

    kwargs = {name: tab.copy() for name, tab in kwargs.items()}
    root: sql_expr.Expression = sqlglot.parse_one(query)
    if root is None:
        raise RuntimeError(f"parsing {query} failed")
    try:
        root = qualify_columns.qualify_columns(
            root,
            {name: tab.schema.typehints() for name, tab in kwargs.items()},
        )
    except OptimizeError:
        pass
    tab, _ = _run(root, kwargs)
    return tab

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Validate the query is non-empty and contains at least one SQL statement before calling pw.sql
  2. Log/print the exact query string right before the call to catch templating bugs
  3. If the query is user-supplied, reject blank input early with a clear error

Example fix

# before
tab = pw.sql(query)  # query == "" -> RuntimeError

# after
if not query or not query.strip():
    raise ValueError("SQL query is empty")
tab = pw.sql(query)
Defensive patterns

Strategy: validation

Validate before calling

def is_runnable_sql(query: str) -> bool:
    return bool(query and query.strip())

Type guard

def assert_nonempty_query(query: str) -> None:
    if not query or not query.strip():
        raise ValueError("SQL query is empty")

Try / catch

try:
    tab = pw.sql(query)
except RuntimeError as e:
    if "parsing" in str(e):
        raise ValueError(f"Bad SQL query: {query!r}") from e
    raise

Prevention

When it happens

Trigger: Calling pw.sql(query) or pathway.internals.sql with query="" or query that is only whitespace/comments; a f-string or templating bug that interpolates to an empty string; passing None-like input after string concatenation.

Common situations: Dynamically assembled SQL where a WHERE/SELECT clause variable is empty; config-driven query strings with a missing value; trailing whitespace-only strings from user input.

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/5a5d708178bb5d0e. Report an issue: GitHub.