[NO ISSUE][OM] Add path creator from a list of field names
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
Allow to create ARecordType from a list of field names
Change-Id: I8d4c29a55e6e89ecbfa3fc6d521a4fb06e866baa
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17692
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Hussain Towaileb <hussainht@gmail.com>
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/ProjectionFiltrationTypeUtil.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/ProjectionFiltrationTypeUtil.java
index ab837b8..41c990b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/ProjectionFiltrationTypeUtil.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/utils/ProjectionFiltrationTypeUtil.java
@@ -45,7 +45,7 @@
public static ARecordType getRecordType(List<List<String>> paths) throws AlgebricksException {
ARecordType result = EMPTY_TYPE;
for (List<String> path : paths) {
- ARecordType type = getRecordType(path, "root", 0, BuiltinType.ANY);
+ ARecordType type = getPathRecordType(path);
result = (ARecordType) RecordMergeTypeComputer.merge(result, type);
}
@@ -58,13 +58,17 @@
ARecordType result = EMPTY_TYPE;
for (int i = 0; i < paths.size(); i++) {
List<String> path = paths.get(i);
- ARecordType type = getRecordType(path, "root", 0, types.get(i));
+ ARecordType type = getPathRecordType(path, types.get(i));
result = (ARecordType) RecordMergeTypeComputer.merge(result, type);
}
return new ARecordType("root", result.getFieldNames(), result.getFieldTypes(), true);
}
+ public static ARecordType getPathRecordType(List<String> path) {
+ return getRecordType(path, "root", 0, BuiltinType.ANY);
+ }
+
/**
* Get the expected type for an array index
*
@@ -98,6 +102,10 @@
return new ARecordType("root", result.getFieldNames(), result.getFieldTypes(), true);
}
+ private static ARecordType getPathRecordType(List<String> path, IAType type) {
+ return getRecordType(path, "root", 0, type);
+ }
+
private static IAType getType(String typeName, List<String> path, int fieldIndex, IAType leafType) {
if (fieldIndex == path.size()) {
return leafType;