nssalian commented on code in PR #2045: URL: https://github.com/apache/iceberg-go/pull/2045#discussion_r4077170000
########## website/src/variant.md: ########## @@ -0,0 +1,121 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. +--> + +# Variant Type + +`variant` is the Iceberg v3 semi-structured type: a single self-describing column +that holds arbitrary JSON-like values (objects, arrays, and scalars) without a +fixed schema. iceberg-go supports both non-shredded and shredded variants, and can +push predicates down into individual variant fields. + +## Reading and writing + +A variant column is declared with `iceberg.VariantType{}` in the table schema and +maps to the Arrow `variant` extension type (see [API](./api.md)). Non-shredded +variant values need no extra configuration: write an Arrow record whose variant +column uses the extension type, and read it back the same way. + +Build the column with a variant builder and write it like any other Arrow column +(the table must be format version 3): + +```go +import ( + "github.com/apache/arrow-go/v18/arrow" + "github.com/apache/arrow-go/v18/arrow/array" + "github.com/apache/arrow-go/v18/arrow/extensions" + "github.com/apache/arrow-go/v18/arrow/memory" + "github.com/apache/arrow-go/v18/parquet/variant" Review Comment: I re-produced this locally and the imports we already there and I missed porting those over initially. This is fixed now. I added `github.com/apache/iceberg-go` and `github.com/apache/iceberg-go/table` (and `fmt`, which the read snippet needs). Rebuilt the snippet against exactly its own import block, so it compiles now. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
