davisusanibar commented on code in PR #183:
URL: https://github.com/apache/arrow-cookbook/pull/183#discussion_r848643956
##########
java/source/schema.rst:
##########
@@ -94,122 +93,135 @@ A schema is a list of Fields, where each Field is defined
by name and type.
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.FieldType;
+ import java.util.ArrayList;
+ import java.util.List;
Field name = new Field("name", FieldType.nullable(new ArrowType.Utf8()),
null);
- Map<String, String> metadata = new HashMap<>();
- metadata.put("A", "Id card");
- metadata.put("B", "Passport");
- metadata.put("C", "Visa");
- Field document = new Field("document", new FieldType(true, new
ArrowType.Utf8(), null, metadata), null);
+ Field document = new Field("document", new FieldType(true, new
ArrowType.Utf8(), null), null);
Field age = new Field("age", FieldType.nullable(new ArrowType.Int(32,
true)), null);
FieldType intType = new FieldType(true, new ArrowType.Int(32, true),
/*dictionary=*/null);
FieldType listType = new FieldType(true, new ArrowType.List(),
/*dictionary=*/null);
Field childField = new Field("intCol", intType, null);
List<Field> childFields = new ArrayList<>();
childFields.add(childField);
Field points = new Field("points", listType, childFields);
-
- // create a definition
Schema schemaPerson = new Schema(asList(name, document, age, points));
- System.out.print(schemaPerson)
+ System.out.print(schemaPerson);
.. testoutput::
Schema<name: Utf8, document: Utf8, age: Int(32, true), points:
List<intCol: Int(32, true)>>
+Adding Metadata for Schema
+==========================
+
+In case we need to add metadata to our definition we could use:
+
+.. testcode::
+
+ import org.apache.arrow.vector.types.pojo.Schema;
+ import static java.util.Arrays.asList;
Review Comment:
Sorted
--
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]