|
44 | 44 | import org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.MapPrimitive;
|
45 | 45 | import org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.Nested;
|
46 | 46 | import org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.NonContiguousOneOf;
|
| 47 | +import org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.NullablePrimitive; |
47 | 48 | import org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.OneOf;
|
48 | 49 | import org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.OuterOneOf;
|
49 | 50 | import org.apache.beam.sdk.extensions.protobuf.Proto3SchemaMessages.Primitive;
|
@@ -111,6 +112,47 @@ static Schema.Options withTypeName(String typeName) {
|
111 | 112 | "proto3_schema_messages.Primitive"))
|
112 | 113 | .build();
|
113 | 114 |
|
| 115 | + static final Schema NULLABLE_PRIMITIVE_SCHEMA = |
| 116 | + Schema.builder() |
| 117 | + .addField(withFieldNumber("primitive_double", FieldType.DOUBLE, 1).withNullable(true)) |
| 118 | + .addField(withFieldNumber("primitive_float", FieldType.FLOAT, 2).withNullable(true)) |
| 119 | + .addField(withFieldNumber("primitive_int32", FieldType.INT32, 3).withNullable(true)) |
| 120 | + .addField(withFieldNumber("primitive_int64", FieldType.INT64, 4).withNullable(true)) |
| 121 | + .addField( |
| 122 | + withFieldNumber("primitive_uint32", FieldType.logicalType(new UInt32()), 5) |
| 123 | + .withNullable(true)) |
| 124 | + .addField( |
| 125 | + withFieldNumber("primitive_uint64", FieldType.logicalType(new UInt64()), 6) |
| 126 | + .withNullable(true)) |
| 127 | + .addField( |
| 128 | + withFieldNumber("primitive_sint32", FieldType.logicalType(new SInt32()), 7) |
| 129 | + .withNullable(true)) |
| 130 | + .addField( |
| 131 | + withFieldNumber("primitive_sint64", FieldType.logicalType(new SInt64()), 8) |
| 132 | + .withNullable(true)) |
| 133 | + .addField( |
| 134 | + withFieldNumber("primitive_fixed32", FieldType.logicalType(new Fixed32()), 9) |
| 135 | + .withNullable(true)) |
| 136 | + .addField( |
| 137 | + withFieldNumber("primitive_fixed64", FieldType.logicalType(new Fixed64()), 10) |
| 138 | + .withNullable(true)) |
| 139 | + .addField( |
| 140 | + withFieldNumber("primitive_sfixed32", FieldType.logicalType(new SFixed32()), 11) |
| 141 | + .withNullable(true)) |
| 142 | + .addField( |
| 143 | + withFieldNumber("primitive_sfixed64", FieldType.logicalType(new SFixed64()), 12) |
| 144 | + .withNullable(true)) |
| 145 | + .addField(withFieldNumber("primitive_bool", FieldType.BOOLEAN, 13).withNullable(true)) |
| 146 | + .addField(withFieldNumber("primitive_string", FieldType.STRING, 14).withNullable(true)) |
| 147 | + .addField(withFieldNumber("primitive_bytes", FieldType.BYTES, 15).withNullable(true)) |
| 148 | + .setOptions( |
| 149 | + Schema.Options.builder() |
| 150 | + .setOption( |
| 151 | + SCHEMA_OPTION_META_TYPE_NAME, |
| 152 | + FieldType.STRING, |
| 153 | + "proto3_schema_messages.NullablePrimitive")) |
| 154 | + .build(); |
| 155 | + |
114 | 156 | static final Schema OPTIONAL_PRIMITIVE_SCHEMA =
|
115 | 157 | Schema.builder()
|
116 | 158 | .addField(withFieldNumber("primitive_int32", FieldType.INT32, 1))
|
@@ -181,6 +223,10 @@ static Schema.Options withTypeName(String typeName) {
|
181 | 223 | .setPrimitiveBytes(ByteString.copyFrom(BYTE_ARRAY))
|
182 | 224 | .build();
|
183 | 225 |
|
| 226 | + static final NullablePrimitive NULLABLE_PRIMITIVE_PROTO = NullablePrimitive.newBuilder().build(); |
| 227 | + |
| 228 | + static final Row NULLABLE_PRIMITIVE_ROW = Row.nullRow(NULLABLE_PRIMITIVE_SCHEMA); |
| 229 | + |
184 | 230 | // A sample instance of the row.
|
185 | 231 | static final Row OPTIONAL_PRIMITIVE_ROW =
|
186 | 232 | Row.withSchema(OPTIONAL_PRIMITIVE_SCHEMA).addValues(32, true, "horsey", BYTE_ARRAY).build();
|
|
0 commit comments