nssalian commented on code in PR #1206: URL: https://github.com/apache/arrow-go/pull/1206#discussion_r3884716457
########## parquet/variant/path.go: ########## @@ -0,0 +1,108 @@ +// 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. + +package variant + +import ( + "errors" + "fmt" + + "github.com/apache/arrow-go/v18/arrow" +) + +// pathElem is one step of a VariantPath: an object field when name != "", else an +// array index. +type pathElem struct { + name string + index int +} + +// VariantPath is an ordered list of steps to navigate into a variant value. The +// zero value is the root path; extend it with Field and Index. +type VariantPath struct { + elems []pathElem +} + +// Field returns a copy of the path with an object-field step appended. +func (p VariantPath) Field(name string) VariantPath { + return VariantPath{elems: append(p.grow(), pathElem{name: name})} Review Comment: This is now fixed too. Good catch. pathElem now carries an explicit isField bool; Field sets it, Index leaves it false, and StepAt/GetByPath/path rebuilding branch on isField instead of name != "". {"":42} extracted with Field("") resolves the empty key (returns 42), and Index(0) on it is absent. Covered by TestGetByPathEmptyKey and TestVariantGetEmptyKey. -- 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]
