Repository navigation
[GLUTEN-12447] Add Arrow large var types support - #13018
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Critical issues remain with Bolt export layout handling, unsupported backend layouts, and SparkArrowUtil visibility.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds support for Spark Arrow large variable-width types to prevent oversized allocations for large string and binary columns.
Changes:
- Adds large UTF-8/binary schema mappings and vector accessors.
- Propagates the configuration through Java, JNI, and native export paths.
- Updates Velox/Bolt interfaces and related tests.
Blocking review findings remain in Bolt export compatibility, backend layout handling, and SparkArrowUtil visibility.
File summaries
| File | Summary |
|---|---|
gluten-arrow/src/test/java/org/apache/gluten/vectorized/ArrowWritableColumnVectorTest.java |
Tests large dictionary vectors. |
gluten-arrow/src/main/scala/org/apache/spark/sql/utils/SparkSchemaUtil.scala |
Reads the large-variable-type configuration. |
gluten-arrow/src/main/scala/org/apache/spark/sql/utils/SparkArrowUtil.scala |
Maps Spark variable types to large Arrow types. |
gluten-arrow/src/main/scala/org/apache/gluten/utils/ArrowUtil.scala |
Rebuilds imported schemas using configured types. |
gluten-arrow/src/main/java/org/apache/gluten/vectorized/ArrowWritableColumnVector.java |
Adds large vector accessors and writers. |
gluten-arrow/src/main/java/org/apache/gluten/vectorized/ArrowColumnVector.java |
Adds large vector readers. |
gluten-arrow/src/main/java/org/apache/gluten/columnarbatch/ColumnarBatchJniWrapper.java |
Extends JNI export parameters. |
gluten-arrow/src/main/java/org/apache/gluten/columnarbatch/ColumnarBatches.java |
Passes the large-type setting during export. |
cpp/velox/utils/VeloxArrowUtils.h |
Configures large variable-width exports. |
cpp/velox/memory/VeloxColumnarBatch.h |
Extends Velox batch export APIs. |
cpp/velox/memory/VeloxColumnarBatch.cc |
Applies large export options. |
cpp/velox/memory/GpuBufferColumnarBatch.h |
Updates export API signatures. |
cpp/velox/memory/GpuBufferColumnarBatch.cc |
Updates unsupported export implementations. |
cpp/core/memory/ColumnarBatch.h |
Extends the common batch export interface. |
cpp/core/memory/ColumnarBatch.cc |
Updates core batch implementations. |
cpp/core/jni/JniWrapper.cc |
Propagates the JNI option. |
cpp/bolt/memory/BoltColumnarBatch.h |
Updates Bolt export signatures. |
cpp/bolt/memory/BoltColumnarBatch.cc |
Updates Bolt export implementations. |
backends-velox/src/test/scala/org/apache/gluten/expression/UDFPartialProjectSuite.scala |
Tests both configuration modes. |
backends-velox/src/main/scala/org/apache/spark/sql/execution/unsafe/UnsafeColumnarBuildSideRelation.scala |
Uses configured Arrow schemas. |
backends-velox/src/main/scala/org/apache/spark/sql/execution/datasources/velox/VeloxFormatWriterInjects.scala |
Uses configured writer schemas. |
backends-velox/src/main/scala/org/apache/spark/sql/execution/ColumnarCachedBatchSerializer.scala |
Uses configured cache schemas. |
backends-velox/src/main/scala/org/apache/spark/sql/execution/ColumnarBuildSideRelation.scala |
Uses configured build-side schemas. |
backends-velox/src/main/scala/org/apache/gluten/execution/RowToVeloxColumnarExec.scala |
Uses configured row-to-columnar schemas. |
backends-velox/src-iceberg/main/scala/org/apache/gluten/connector/write/IcebergDataWriteFactory.scala |
Uses configured Iceberg writer schemas. |
Review details
- Files reviewed: 25/25 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| std::shared_ptr<ArrowArray> BoltColumnarBatch::exportArrowArray(bool) { | ||
| auto out = std::make_shared<ArrowArray>(); | ||
| ensureFlattened(); | ||
| bolt::exportToArrow(rowVector_, *out, rowVector_->pool(), ArrowUtils::getBridgeOptions()); |
There was a problem hiding this comment.
Add new backend api supportLargeVarTypes() to disable arrow var type for bolt backend.
| iv.handle(), | ||
| cSchema.memoryAddress(), | ||
| cArray.memoryAddress(), | ||
| SparkSchemaUtil.enableLargeVarTypes()); |
There was a problem hiding this comment.
Removed ArrowUtil.toArrowSchema api, import the native ArrowSchema and ArrowArray together through ArrowAbiUtil so that the schema always describes the actual buffer layout.
| private[utils] def toArrowSchema( | ||
| schema: StructType, | ||
| timeZoneId: String, | ||
| largeVarTypes: Boolean = false): Schema = { |
There was a problem hiding this comment.
Removed the package private declaration.
|
Run Gluten Clickhouse CI on x86 |
3eac8b8 to
fb4f92f
Compare
|
Run Gluten Clickhouse CI on x86 |
|
@zhouyuan Could you take a look again? Added a backend api |
|
Run Gluten Clickhouse CI on x86 |
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
|
This PR was auto-closed because it has been stalled for 10 days with no activity. Please feel free to reopen if it is still valid. Thanks. |
|
hi @wecharyu somehow I missed this patch, apologies for the delay, could you please do a rebase? Thanks. |
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
@zhouyuan No worries at all. I’ve rebased this PR. Gluten now uses Spark’s built-in Arrow reader and writer. #13280 and Spark added support for |
There was a problem hiding this comment.
🟡 Changes recommended
Critical compilation and large-vector accessor issues remain, and the native export path lacks coverage for the new flag behavior.
6 open issues
Use FieldVector for the dictionary lookup result · New Add accessors for large string and binary vectors · New MakingtoArrowSchemapackage-private toorg.apache.spark.sql.utilsbreaks the existing Bolt… This flag is now passed for every backend, but not everyColumnarBatchimplementation honors it:… This override discards the new flag and always exports 32-bit-offset Arrow variable-width arrays.… Add native Velox coverage for large-offset schema and buffer export · New
Review effort: Lite
| def dictionary(field: Field): FieldVector = { | ||
| provider.lookup(field.getDictionary.getId).getVector |
There was a problem hiding this comment.
Dictionary#getVector() returns FieldVector in all four Arrow versions used by this PR (15.0.0, 18.1.0, 18.3.0, and 19.0.0).
| case StringType if !largeVarTypes => ArrowType.Utf8.INSTANCE | ||
| case BinaryType if !largeVarTypes => ArrowType.Binary.INSTANCE | ||
| case StringType if largeVarTypes => ArrowType.LargeUtf8.INSTANCE | ||
| case BinaryType if largeVarTypes => ArrowType.LargeBinary.INSTANCE |
There was a problem hiding this comment.
The ArrowColumnVector missing these accessors is Gluten’s old implementation, which has no callers after #13280.
There are some no used Arrow files (ArrowColumnVector.java, ArrowColumnarMap.java and ArrowColumnarArray.java) could be removed, we can do it in a seprate PR.
| auto out = std::make_shared<ArrowSchema>(); | ||
| ensureFlattened(); | ||
| velox::exportToArrow(rowVector_, *out, ArrowUtils::getBridgeOptions()); | ||
| velox::exportToArrow(rowVector_, *out, ArrowUtils::getBridgeOptions(exportToLargeVarTypes)); |
There was a problem hiding this comment.
Added test ColumnarBatchTest#testLoadVeloxBatchWithLargeVarTypes.
|
Run Gluten Clickhouse CI on x86 |
|
Run Gluten Clickhouse CI on x86 |
|
@WangGuangxin could you please also take a look? |


What changes are proposed in this pull request?
Support Spark conf spark.sql.execution.arrow.useLargeVarTypes when building arrow vectors to avoid OversizedAllocationException for very large string/binary columns.
Fix #12447.
How was this patch tested?
UT.
Was this patch authored or co-authored using generative AI tooling?
Generated by GPT-5.6