{"id":1604,"library":"openlineage-sql","title":"OpenLineage SQL","description":"The `openlineage-sql` library provides a Python interface to a high-performance Rust library for SQL lineage extraction. It enables parsing SQL queries to identify input tables, output tables, and query types, crucial for data governance and ETL pipeline observability. Currently at version 1.46.0, it is actively maintained with frequent updates reflecting improvements in its core Rust library and broader OpenLineage specification, requiring Python 3.10 or newer.","status":"active","version":"1.46.0","language":"en","source_language":"en","source_url":"https://github.com/OpenLineage/openlineage-sql","tags":["sql","lineage","data-governance","etl","parser"],"install":[{"cmd":"pip install openlineage-sql","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"parse","correct":"from openlineage.sql import parse"}],"quickstart":{"code":"from openlineage.sql import parse\n\nsql_query = \"SELECT a, b FROM input_table JOIN other_table ON input_table.id = other_table.id WHERE a > 10\"\nresult = parse(sql_query)\n\nprint(f\"SQL Query Type: {result.query_type}\")\nprint(f\"Input Tables: {result.inputs}\")\nprint(f\"Output Tables: {result.outputs}\")\n\n# Example with DDL\nsql_ddl = \"CREATE TABLE new_table (id INT, name VARCHAR(255))\"\nddl_result = parse(sql_ddl)\nprint(f\"\\nDDL Query Type: {ddl_result.query_type}\")\nprint(f\"DDL Output Tables: {ddl_result.outputs}\")","lang":"python","description":"This quickstart demonstrates how to use the `parse` function to extract lineage information (inputs, outputs, and query type) from a given SQL query, including DDL statements."},"warnings":[{"fix":"Ensure a Rust toolchain (e.g., rustup) is installed and correctly configured if `pip install` fails with compilation errors.","message":"Users on less common operating systems or architectures might encounter compilation errors during installation if pre-built wheels are not available. This requires a Rust toolchain to be installed on the system.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Simplify complex queries where possible or pre-process dynamic SQL to its final form before passing it to `openlineage-sql`. Validate results for critical lineage paths.","message":"While supporting many SQL dialects, complex, non-standard, or highly dynamic SQL queries (e.g., involving complex macros, stored procedures, or unusual syntax) might lead to incomplete or inaccurate lineage extraction.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always treat the return value of `parse` as an object and access its attributes (e.g., `result.inputs`) rather than assuming it's a direct list or dictionary.","message":"The `parse` function returns a `SqlMeta` object, not directly a list of tables. Users must access specific attributes like `.inputs`, `.outputs`, and `.query_type` to retrieve the desired lineage details.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}