Polars database reader/writer record file metadata, so SQL lineage is missing
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Related: #1720
PolarsDatabaseReader and PolarsDatabaseWriter (in both polars_post_1_0_0_extensions.py and polars_pre_1_0_0_extension.py) describe database I/O with get_file_and_dataframe_metadata. They pass the SQL query or table name in where a file path is expected:
# PolarsDatabaseReader.load_data
metadata = utils.get_file_and_dataframe_metadata(self.query, df)
# PolarsDatabaseWriter.save_data
return utils.get_file_and_dataframe_metadata(self.table_name, data)
This happens whatever connection is passed, including a SQLAlchemy Engine.
Effects
- The metadata has no
sql_metadatablock. So theOpenLineageAdaptercan't identify the tables, andsql_dataset_identity="datasource"(from #1720) resolves nothing:sql_datasets()returnsSQL datasource is unknown; no dataset emitted. - Lineage treats database I/O as filesystem I/O:
- a read becomes an input dataset named after the node (e.g.
orders_df), withstorageLayer="FileSystem"and the SQL text as itsdataSourceURI; - a write becomes an output dataset named after the table, also marked
FileSystem; - no
sqljob facet is emitted.
- a read becomes an input dataset named after the node (e.g.
file_metadatacarries meaningless values, e.g.path: "SELECT * FROM orders",scheme: "", and a note that the file does not exist.
Reproduction
import polars as pl
from sqlalchemy import create_engine
from hamilton.plugins.polars_post_1_0_0_extensions import PolarsDatabaseReader
engine = create_engine("sqlite:///a.db") # with a table `orders`
df, md = PolarsDatabaseReader(query="SELECT * FROM orders", connection=engine).load_data(pl.DataFrame)
print(sorted(md)) # ['dataframe_metadata', 'file_metadata']
print(md["file_metadata"]["path"]) # 'SELECT * FROM orders'
Proposed fix
- In both Polars database classes, record
get_sql_metadata(query_or_table, results, db_connection=self.connection, operation="read" | "write")plusget_dataframe_metadata, asPandasSqlReaderandPandasSqlWriterdo. SQLAlchemy URLs, Engines and Connections, andsqlite3connections, then get full datasource identity. - Extend
get_sql_sourceto recognise the other connections Polars accepts (ADBC connections, connectorx URI strings, cursors). Until then these are left out of lineage with a note, which is safe but gives no lineage. - Add Polars read and write tests against SQLite, mirroring the pandas SQL lineage tests.
Compatibility
Metadata for Polars database I/O changes from file_metadata to sql_metadata. Default-mode ("legacy") OpenLineage output changes with it: the fake filesystem datasets are replaced by the legacy SQL datasets. Anyone consuming file_metadata from these classes would be affected, so this probably deserves a changelog entry.
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 2.6k
- Fork
- 218
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 18
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/hamilton
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Engine crashes when client sends nan or inf float to UICó thể làm lại được @Exudev đã nhận 232 ngày trước và không có pull request nào đang mở. Đang mởbug SDK
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
apache/hamilton#1458 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
More detailed type annotations in graph visualizationsCó thể làm lại được @Nishant-Manocha đã nhận 367 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
apache/hamilton#1383 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Documentation: add explainer for FastAPICó thể làm lại được @Aditya-Deshwal23 đã nhận 187 ngày trước và không có pull request nào đang mở. Đang mởdocumentation
Độ khó 2/5 1-2 ngày Mức phù hợp với người mới 65/100
apache/hamilton#1304 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Link back to github from reference API docsCó thể đã có người làm @naikvaib đã nhận 24 ngày trước. Đang mởdocumentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/hamilton#572 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày