Skip to content

HIVE-28503: Vectorization: concat (||) on string columns returns NULL for non-null inputs#6607

Open
maheshrajus wants to merge 2 commits into
apache:masterfrom
maheshrajus:HIVE-28503_fix
Open

HIVE-28503: Vectorization: concat (||) on string columns returns NULL for non-null inputs#6607
maheshrajus wants to merge 2 commits into
apache:masterfrom
maheshrajus:HIVE-28503_fix

Conversation

@maheshrajus

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

  • In StringGroupConcatColCol.evaluate(), on the "no nulls in either input" branch, set outV.noNulls = true before writing. (Matches what the sibling StringGroupColConcatStringScalar / StringScalarConcatStringGroupCol already do)
  • Added two JUnit tests in TestVectorStringConcat that pre-set outV.noNulls = false (simulating a prior batch that carried NULLs), then assert the flag is restored after evaluate()

Why are the changes needed?

The output BytesColumnVector(outV) is reused across batches. A previous batch that went through a null-carrying branch leaves outV.noNulls = false. The no-nulls branch wrote per-row isNull[i] = false but never reset outV.noNulls = true, so downstream vectorized consumers that utilizes on noNulls treated fully-populated rows as NULL and producing NULL for a || b on rows where both operands were non-null.

More code level details we can find in the jira: https://issues.apache.org/jira/browse/HIVE-28503

Does this PR introduce any user-facing change?

No

How was this patch tested?

With added unit tests

@sonarqubecloud

Copy link
Copy Markdown

/*
* Do careful maintenance of the outputColVector.noNulls flag.
*
* HIVE-28503: when both inputs have noNulls=true the output vector(outV) must set true.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep the comment concise and clear. No need to mention HIVE-28503

* sibling scalar variants (StringGroupColConcatStringScalar and
* StringScalarConcatStringGroupCol) already do on their no-nulls paths.
*/
outV.noNulls = true;

@deniskuzZ deniskuzZ Jul 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maheshrajus should we do instead

if (!outV.noNulls) {                                                                                                                                                                                         
  // Assume it is almost always a performance win to fill all of isNull so we can                                                                                                                            
  // safely reset noNulls.                                                                                                                                                                                   
  Arrays.fill(outV.isNull, false);                                                                                                                                                                           
  outV.noNulls = true;                                                                                                                                                                                       
}

same pattern is used in other places

@deniskuzZ deniskuzZ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maheshrajus

Copy link
Copy Markdown
Contributor Author

Thank you @deniskuzZ for the review. I will check and address the comments.

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.

4 participants