Skip to content

Conversation

EeshanBembi
Copy link
Contributor

Fixes #18020

Summary

Enables concat function to concatenate arrays like array_concat while
preserving all existing string concatenation behavior.

Before:

SELECT concat([1, 2, 3], [4, 5]);
-- Result: [1, 2, 3][4, 5]  ❌

After:

  SELECT concat([1, 2, 3], [4, 5]);
  -- Result: [1, 2, 3, 4, 5]  ✅

Implementation

  • Extended concat function signature to accept array types
  • Added type detection in invoke_with_args() to delegate array operations to Arrow
    compute functions
  • Enhanced type coercion to handle mixed array types and empty arrays
  • Maintains full backward compatibility with string concatenation

Test Coverage

  • ✅ Array concatenation: [1,2] + [3,4] → [1,2,3,4]
  • ✅ Empty arrays: [1,2] + [] → [1,2]
  • ✅ Nested arrays: [[1,2]] + [[3,4]] → [[1,2],[3,4]]
  • ✅ String concatenation unchanged: 'hello' + 'world' → 'helloworld'
  • ✅ Mixed type coercion: true + 42 + 'test' → 'true42test'
  • ✅ Error handling: [1,2] + 'string' → Error

Approach Benefits

Function-level implementation vs planner replacement:

  • Cleaner architecture (single responsibility)
  • No planner complexity
  • Better performance
  • Easier testing and maintenance

- Extend concat function to handle both string and array concatenation
- Add type detection logic to delegate array ops to Arrow compute functions
- Maintain full backward compatibility with existing string concatenation
- Add comprehensive test coverage for arrays, mixed types, and edge cases
- Fix SQL logic tests to use proper type indicators for array results

Fixes apache#18020
@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unexpected output for concat for arrays

1 participant