There are three types of array encodings: 1. One-level encoding A bare repeated field. This is interpreted as a required array of required items. Example: repeated item; 2. Two-level encoding A group containing a single repeated field. This is interpreted as a array of required items ( is either optional or required). Example: grou
| 910 | // encoding, determined by 'array_encoding'. '*node' is set to the repeated field for all |
| 911 | // three encodings (unless '*pos_field' or '*missing_field' are set to true). |
| 912 | Status ParquetSchemaResolver::ResolveArray(ArrayEncoding array_encoding, |
| 913 | const SchemaPath& path, int idx, SchemaNode** node, bool* pos_field, |
| 914 | bool* missing_field) const { |
| 915 | if (array_encoding == ONE_LEVEL) { |
| 916 | if (!(*node)->is_repeated()) { |
| 917 | ErrorMsg msg(TErrorCode::PARQUET_UNRECOGNIZED_SCHEMA, filename_, |
| 918 | PrintSubPath(tbl_desc_, path, idx), "array", (*node)->DebugString()); |
| 919 | return Status::Expected(msg); |
| 920 | } |
| 921 | } else { |
| 922 | // In the multi-level case, we always expect the outer group to contain a single |
| 923 | // repeated field |
| 924 | if ((*node)->children.size() != 1 || !(*node)->children[0].is_repeated()) { |
| 925 | ErrorMsg msg(TErrorCode::PARQUET_UNRECOGNIZED_SCHEMA, filename_, |
| 926 | PrintSubPath(tbl_desc_, path, idx), "array", (*node)->DebugString()); |
| 927 | return Status::Expected(msg); |
| 928 | } |
| 929 | // Set *node to the repeated field |
| 930 | *node = &(*node)->children[0]; |
| 931 | } |
| 932 | DCHECK((*node)->is_repeated()); |
| 933 | |
| 934 | if (idx + 1 < path.size()) { |
| 935 | if (path[idx + 1] == SchemaPathConstants::ARRAY_POS) { |
| 936 | // The next index in 'path' is the artifical position field. |
| 937 | DCHECK_EQ(path.size(), idx + 2) << "position field cannot have children!"; |
| 938 | *pos_field = true; |
| 939 | *node = NULL; |
| 940 | return Status::OK(); |
| 941 | } else { |
| 942 | // The next value in 'path' should be the item index |
| 943 | DCHECK_EQ(path[idx + 1], SchemaPathConstants::ARRAY_ITEM); |
| 944 | } |
| 945 | } |
| 946 | return Status::OK(); |
| 947 | } |
| 948 | |
| 949 | // According to the parquet spec, map columns are represented like: |
| 950 | // <map-repetition> group <name> (MAP) { |
nothing calls this directly
no test coverage detected