aglinxinyuan commented on code in PR #6099:
URL: https://github.com/apache/texera/pull/6099#discussion_r3524198015


##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/source/scan/arrow/ArrowSourceOpDescSpec.scala:
##########
@@ -81,4 +122,24 @@ class ArrowSourceOpDescSpec extends AnyFlatSpec with 
Matchers {
     r.limit shouldBe Some(7)
     r.offset shouldBe Some(3)
   }
+
+  "ArrowSourceOpDesc.inferSchema" should "infer the Texera schema from a valid 
Arrow file" in {
+    val file = writeArrowFile(Seq("a", "b"))
+    val d = new ArrowSourceOpDesc
+    d.fileName = Some(file.toURI.toString)
+    val schema = d.inferSchema()
+    schema.getAttributes should have length 1
+    schema.getAttributes.head.getName shouldBe "s"
+    schema.getAttributes.head.getType shouldBe AttributeType.STRING
+  }

Review Comment:
   Expanded it — added an `inferSchema` case over all nine attribute types 
(INTEGER/LONG/DOUBLE/BOOLEAN/STRING/TIMESTAMP/BINARY/LARGE_BINARY/ANY), written 
from an all-null row so it also exercises the null-writing path for every type 
(0bc50ef). On the exception path: the existing "not a valid Arrow file → 
IOException" case covers it, and a mixed/wrong field can't occur in a valid 
Arrow file since each column is strongly typed — `inferSchema` reads the 
declared schema. Exhaustive value/null round-tripping (including reading nulls 
back) already lives in ArrowUtilsSpec.



##########
common/workflow-core/src/test/scala/org/apache/texera/amber/core/tuple/AttributeSpec.scala:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.core.tuple
+
+import org.scalatest.flatspec.AnyFlatSpec
+
+class AttributeSpec extends AnyFlatSpec {
+
+  "Attribute" should "expose its name and type" in {
+    val attribute = new Attribute("age", AttributeType.INTEGER)
+    assert(attribute.getName == "age")
+    assert(attribute.getType == AttributeType.INTEGER)
+  }
+

Review Comment:
   Added a case that constructs an `Attribute` for every `AttributeType` and 
checks the name/type round-trip (0bc50ef). The enum's own semantics — wire 
names, field-class mapping, ANY handling — are already covered separately in 
AttributeTypeSpec, so I kept this one focused on the Attribute holder.



-- 
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]

Reply via email to