Support _etag virtual column for HDFS storage - #108255
Conversation
HDFS has no native ETag, so synthesise a version identifier from the fields exposed by `hdfsFileInfo`: the modification time and the size. Populate it in both `tryGetObjectMetadata` and `listObjects` so the `_etag` virtual column, `use_parquet_metadata_cache`, the filesystem cache and the page cache become usable on HDFS (previously they were silently disabled because the etag was empty). The token has only second precision: libhdfs3 truncates the NameNode millisecond mtime to seconds in `mLastMod`, so a rewrite within the same wall-clock second that keeps the exact same size collides. This is acceptable for the virtual column and mirrors the mtime-based versioning used for local files; the limitation is documented next to the helper. Also fix a leak in `tryGetObjectMetadata`: the raw `hdfsFileInfo *` was freed manually after building the metadata, so an exception in between would leak it. Use the existing `HDFSFileInfo` RAII wrapper instead. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Workflow [PR], commit [cf0bc35] Summary: ✅
AI ReviewSummaryThis PR makes HDFS populate Final Verdict
|
…document the `_etag` virtual column Co-authored-by: Cursor <cursoragent@cursor.com>
tiandiwonder
left a comment
There was a problem hiding this comment.
No test for the new behavior. Worth adding a focused one: assert SELECT _etag FROM hdfs(...) is non-empty, and ideally that an HDFS read does not engage the parquet metadata cache (since etag_is_strong is false) while strong-etag storage still does. Otherwise a regression that re-empties the token or flips a cache gate goes uncaught. tests/integration/test_storage_hdfs/ can host it.
|
The description still says this makes `use_parquet_metadata_cache`, the filesystem cache and the page cache usable on HDFS, but the code now sets `etag_is_strong = false`, so those caches stay disabled for HDFS — only the `_etag` virtual column is actually enabled. Worth updating the description and the changelog entry to reflect just the `_etag` column. |
…g` token never keys a cache, with unit tests for the contract Co-authored-by: Cursor <cursoragent@cursor.com>
Thanks — I agree the new behavior should be guarded against regressions. The tests/integration/test_storage_hdfs/ directory is only a leftover stub, cluster.py no longer has a To make this testable without a NameNode I extracted the metadata construction into a pure static |
|
@zhangyifan27 please merge with latst master. |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 40/59 (67.80%) · Uncovered code |
|
📊 Cloud Performance Report ✅ AI verdict: This PR changes only HDFS object-storage metadata handling (a synthesized weak clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
a8c156e
|
Hi @zhangyifan27 @tiandiwonder — while reviewing this PR I found the following:
Happy to discuss — close anything that's wrong or already addressed. |
HDFS has no native ETag, so synthesise a version identifier from the fields exposed by
hdfsFileInfo: the modification time and the size. Populate it in bothtryGetObjectMetadataandlistObjectsso the_etagvirtual column is vailable on HDFS (previously it was always empty).The token has only second precision: libhdfs3 truncates the NameNode millisecond mtime to seconds in
mLastMod, so a rewrite within the same wall-clock second that keeps the exact same size collides. Because it is not a strong content identifier, it is marked withObjectMetadata::etag_is_strong = falseand is deliberately NOT used as a content-cache key: the Parquet metadata cache, the filesystem cache and the page cache still skip HDFS (they require a strong etag), so a same-second/same-size rewrite can never serve stale cached data. The limitation is documented next to the helper, and the_etagcolumn is documented for the HDFS engine and table function.Also fix a leak in
tryGetObjectMetadata: the rawhdfsFileInfo *was freed manually after building the metadata, so an exception in between would leak it. Use the existingHDFSFileInfoRAII wrapper instead.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Support
_etagvirtual column for HDFS storageVersion info
26.8.1.181(included in26.8and later)