Skip to content

Conversation

@richardc-db
Copy link
Contributor

@richardc-db richardc-db commented Jul 8, 2024

What changes were proposed in this pull request?

adds support for variant type in InMemoryTableScan, or df.cache() by supporting writing variant values to an inmemory buffer.

Why are the changes needed?

prior to this PR, calling df.cache() on a df that has a variant would fail because InMemoryTableScan does not support reading variant types.

Does this PR introduce any user-facing change?

no

How was this patch tested?

added UTs

Was this patch authored or co-authored using generative AI tooling?

no

@github-actions github-actions bot added the SQL label Jul 8, 2024
override def append(v: VariantVal, buffer: ByteBuffer): Unit = {
val varLenSize: Int = 4 + v.getValue().length + v.getMetadata().length
ByteBufferHelper.putInt(buffer, varLenSize)
ByteBufferHelper.putInt(buffer, v.getValue().length)
Copy link
Contributor

Choose a reason for hiding this comment

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

why not simply one int for value size and one int for metadata size?

Copy link
Contributor Author

@richardc-db richardc-db Jul 23, 2024

Choose a reason for hiding this comment

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

This was done initially to mimic the VariantVal unsafe row representation here. I can switch it to write one int for value and one int for metadata if you'd prefer

@cloud-fan
Copy link
Contributor

the protobuf failure is unrelated, thanks, merging to master!

@cloud-fan cloud-fan closed this in 0c9b072 Jul 24, 2024
ilicmarkodb pushed a commit to ilicmarkodb/spark that referenced this pull request Jul 29, 2024
### What changes were proposed in this pull request?

adds support for variant type in `InMemoryTableScan`, or `df.cache()` by supporting writing variant values to an inmemory buffer.

### Why are the changes needed?

prior to this PR, calling `df.cache()` on a df that has a variant would fail because `InMemoryTableScan` does not support reading variant types.

### Does this PR introduce _any_ user-facing change?

no
### How was this patch tested?

added UTs
### Was this patch authored or co-authored using generative AI tooling?

no

Closes apache#47252 from richardc-db/variant_dfcache_support.

Authored-by: Richard Chen <r.chen@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants