Represents a resolved or unresolved dot-separated path that is rooted at a registered tuple descriptor, catalog table/view, or an existing resolved path. This class implements the resolution logic for mapping an implicit or explicit raw path to the corresponding physical types/positions in the sche
| 115 | * of the query block that it is used in. |
| 116 | */ |
| 117 | public class Path { |
| 118 | private final static Logger LOG = LoggerFactory.getLogger(Path.class); |
| 119 | |
| 120 | // Implicit field names of collections. |
| 121 | public static final String ARRAY_ITEM_FIELD_NAME = "item"; |
| 122 | public static final String ARRAY_POS_FIELD_NAME = "pos"; |
| 123 | public static final String MAP_KEY_FIELD_NAME = "key"; |
| 124 | public static final String MAP_VALUE_FIELD_NAME = "value"; |
| 125 | |
| 126 | public static enum PathType { |
| 127 | SLOT_REF, |
| 128 | TABLE_REF, |
| 129 | STAR, |
| 130 | ANY, // Reference to any field or table in schema. |
| 131 | } |
| 132 | |
| 133 | // Implicit or explicit raw path to be resolved relative to rootDesc_ or rootTable_. |
| 134 | // Every raw-path element is mapped to zero, one or two types/positions in resolution. |
| 135 | private final List<String> rawPath_; |
| 136 | |
| 137 | // Registered table alias that this path is rooted at, if any. |
| 138 | // Null if the path is rooted at a catalog table/view. |
| 139 | // Note that this is also set for STAR path of "v.*" when "v" is a catalog table/view. |
| 140 | private final TupleDescriptor rootDesc_; |
| 141 | |
| 142 | // Catalog table that this resolved path is rooted at, if any. |
| 143 | // Null if the path is rooted at a registered tuple that does not |
| 144 | // belong to a catalog table/view. |
| 145 | private final FeTable rootTable_; |
| 146 | |
| 147 | // Root path that a relative path was created from. |
| 148 | private final Path rootPath_; |
| 149 | |
| 150 | // List of matched types and field positions set during resolution. The matched |
| 151 | // types/positions describe the physical path through the schema tree of a catalog |
| 152 | // table/view. Empty if the path corresponds to a catalog table/view, e.g. when it's a |
| 153 | // TABLE_REF or when it's a STAR on a table/view. |
| 154 | private final List<Type> matchedTypes_ = new ArrayList<>(); |
| 155 | private final List<Integer> matchedPositions_ = new ArrayList<>(); |
| 156 | |
| 157 | // Remembers the indices into rawPath_ and matchedTypes_ of the first collection |
| 158 | // matched during resolution. |
| 159 | private int firstCollectionPathIdx_ = -1; |
| 160 | private int firstCollectionTypeIdx_ = -1; |
| 161 | |
| 162 | // Indicates whether this path has been resolved. Set in resolve(). |
| 163 | private boolean isResolved_ = false; |
| 164 | |
| 165 | // Caches the result of getAbsolutePath() to avoid re-computing it. |
| 166 | private List<Integer> absolutePath_ = null; |
| 167 | |
| 168 | private TVirtualColumnType virtualColType_ = TVirtualColumnType.NONE; |
| 169 | |
| 170 | // Resolved path before we resolved it again inside the table masking view. |
| 171 | private Path pathBeforeMasking_ = null; |
| 172 | |
| 173 | // Fully-qualified raw path. Populated on first call to getFullyQualifiedRawPath. |
| 174 | // Its inputs are all private final fields, so value can't change after init. |