Skip to content

HIVE-29227: Apply masking in memory instead of rewriting the file in QOutProcessor#maskPatterns - #6632

Open
cyanzheng2926 wants to merge 2 commits into
apache:masterfrom
cyanzheng2926:HIVE-29227_mask_in_memory
Open

HIVE-29227: Apply masking in memory instead of rewriting the file in QOutProcessor#maskPatterns#6632
cyanzheng2926 wants to merge 2 commits into
apache:masterfrom
cyanzheng2926:HIVE-29227_mask_in_memory

Conversation

@cyanzheng2926

@cyanzheng2926 cyanzheng2926 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Refactored masking from QOutProcessor#maskPatterns that involves file rewrite to in-memory implementation for CliDriver and BeeLine.

What changes were proposed in this pull request?

Removed QOutProcessor#maskPatterns() which rewrites the whole file when masking.
Added in-stream masking methods and states, including maskAndFoldLine(), maskLines(), maskContent(), and MaskingFoldState while retaining the original semantics. Splitted multiline println() on \n for PREHOOK/POSTHOOK text
Wrapped both stdout and stderr with QTestFetchConverter to perform mask before sort for CliDriver. For BeeLine retained original sort before mask behaviour and applied masking on the !record stream.

Why are the changes needed?

Currently masking is scattered across multiple locations and also involves re-writing the q.out files after test execution. This change centralises rules in QOutProcessor, applies them in memory on the
capture path where possible, and preserves existing golden semantics.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Tested and validated with multiple existing qfiles with TestMiniLlapLocalCliDriver, TestMiniLlapCliDriver, TestCliDriver, TestMiniTezCliDriver, TestBeeLineDriver
Also added unit test under TestQOutProcessor

…QOutProcessor#maskPatterns

Refactored masking from QOutProcessor#maskPatterns that involves file rewrite to in-memory implementation  for CliDriver and BeeLine.
…iffs

Apply processLine on stdout before SORT_QUERY_RESULTS (HIVE-29226) and run
maskAndFoldLine via maskOutputFile() before diff so stderr folding matches
master. Keep CachingPrintStream as the outer stderr wrapper for hook tests,
and skip multiline splitting in QTestFetchConverter during active query fetch.
@sonarqubecloud

Copy link
Copy Markdown

@cyanzheng2926

Copy link
Copy Markdown
Contributor Author

metadata_delete.q failure on split-01 (TestIcebergCliDriver)
Locally on 3ccc5e0, metadata_delete.q passes consistently with the expected masked HDFS output at line 77.
The diff is:
actual: PREHOOK/POSTHOOK Output: default@ice_date_year
golden: PREHOOK/POSTHOOK Output: hdfs://### HDFS PATH ###
That means Iceberg took the normal DELETE path on CI, while the golden expects the metadata DELETE path (HDFS write entity → masked path). If the raw line were an hdfs://... URL, maskOutputFile() would still produce hdfs://### HDFS PATH ###
This might seem to be a flaky environment issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants