Copilot commented on code in PR #4784: URL: https://github.com/apache/texera/pull/4784#discussion_r3177480860
########## amber/src/test/scala/org/apache/texera/amber/engine/common/ambermessage/DataPayloadSpec.scala: ########## @@ -0,0 +1,77 @@ +/* + * 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 org.apache.texera.amber.engine.common.ambermessage + +import org.apache.texera.amber.core.tuple.{Attribute, AttributeType, Schema, Tuple} +import org.scalatest.flatspec.AnyFlatSpec + +class DataPayloadSpec extends AnyFlatSpec { + + private val schema: Schema = + Schema().add(new Attribute("v", AttributeType.INTEGER)) + + private def tuple(v: Int): Tuple = + Tuple.builder(schema).add(new Attribute("v", AttributeType.INTEGER), Integer.valueOf(v)).build() + + "DataFrame.inMemSize" should "be zero for an empty frame" in { + assert(DataFrame(Array.empty).inMemSize == 0L) + } + + it should "be the sum of inMemSize across the contained tuples" in { + val a = tuple(1) + val b = tuple(2) + val df = DataFrame(Array(a, b)) + assert(df.inMemSize == a.inMemSize + b.inMemSize) + } + + "DataFrame.equals" should "consider two empty frames equal" in { + assert(DataFrame(Array.empty) == DataFrame(Array.empty)) + } Review Comment: The PR description/issue mentions testing `equals` reflexivity for empty frames, but the current test checks equality between two separate empty frames. If the intent is reflexivity specifically, consider adding an explicit `val df = DataFrame(Array.empty); assert(df == df)` (or adjust the description/test wording to match what’s being asserted). ########## amber/src/test/scala/org/apache/texera/amber/engine/common/ambermessage/DataPayloadSpec.scala: ########## @@ -0,0 +1,77 @@ +/* + * 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 org.apache.texera.amber.engine.common.ambermessage + +import org.apache.texera.amber.core.tuple.{Attribute, AttributeType, Schema, Tuple} +import org.scalatest.flatspec.AnyFlatSpec + +class DataPayloadSpec extends AnyFlatSpec { + + private val schema: Schema = + Schema().add(new Attribute("v", AttributeType.INTEGER)) + + private def tuple(v: Int): Tuple = + Tuple.builder(schema).add(new Attribute("v", AttributeType.INTEGER), Integer.valueOf(v)).build() Review Comment: In the `tuple` helper, `Tuple.builder(schema).add(new Attribute("v", ...), ...)` creates a new `Attribute` instance instead of reusing the schema’s attribute. `Tuple.Builder.add(Attribute, field)` only type-checks against the provided `Attribute` (and `build()` doesn’t re-validate field types against the schema), so this helper could silently construct tuples whose field types don’t match `schema` if either side is changed later. Consider defining `val attr = schema.getAttribute("v")` (or keeping a single `Attribute` val used to build the schema) and using that in `add`, or use `addSequentially` for schema-ordered fields. -- 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]
