final String partitionCol = partitionColMapping.get(colName.getRootSegmentPath()); if (partitionCol != null) { nativeScanCols.add(SchemaPath.getSimplePath(partitionCol)); } else { nativeScanCols.add(colName);
private static FieldPath getFieldPathForProjection(SchemaPath column) { Stack<PathSegment.NameSegment> pathSegments = new Stack<>(); PathSegment seg = column.getRootSegment(); while (seg != null && seg.isNamed()) { pathSegments.push((PathSegment.NameSegment) seg); seg = seg.getChild(); } FieldSegment.NameSegment child = null; while (!pathSegments.isEmpty()) { child = new FieldSegment.NameSegment(pathSegments.pop().getPath(), child, false); } return new FieldPath(child); }
@Test public void testUnIndexedArrayInTheMiddle() { SchemaPath schemaPath = SchemaPath.parseFromString("`a`.`b`[0].`c`.`d`"); assertEquals("Schema path should match", SchemaPath.parseFromString("`a`.`b`.`c`.`d`"), schemaPath.getUnIndexed()); }
/** * Returns schema path with for arrays without index. * Is used to find column statistics in parquet metadata. * Example: a.b.c[0] -> a.b.c, a[0].b[1] -> a.b * * @return un-indexed schema path */ public SchemaPath getUnIndexed() { NameSegment nameSegment = getUnIndexedNameSegment(rootSegment, null); return new SchemaPath(nameSegment); }
public static SchemaPath create(NamePart namePart) { Preconditions.checkArgument(namePart.getType() == NamePart.Type.NAME); return new SchemaPath((NameSegment) getPathSegment(namePart)); }
byte[] fieldValue = processor.getValue(); boolean sortOrderAscending = processor.isSortOrderAscending(); boolean isRowKey = field.getRootSegmentPath().equals(ROW_KEY); if (!(isRowKey || (!field.getRootSegment().isLastPath() && field.getRootSegment().getChild().isLastPath() && field.getRootSegment().getChild().isNamed()) byte[] family = HBaseUtils.getBytes(field.getRootSegment().getPath()); byte[] qualifier = HBaseUtils.getBytes(field.getRootSegment().getChild().getNameSegment().getPath()); filter = new SingleColumnValueFilter(family, qualifier, compareOp, comparator); ((SingleColumnValueFilter)filter).setLatestVersionOnly(true);
private SchemaPath fieldName2SchemaPath(String fieldName) { if (fieldName.contains(":")) { fieldName = fieldName.split(":")[1]; } if (fieldName.contains(".")) { return FieldPathHelper.fieldPath2SchemaPath(FieldPath.parseFrom(fieldName)); } return SchemaPath.getSimplePath(fieldName); }
public static RelDataTypeField findField(String fieldName, RelDataType rowType) { final String rootPart = SchemaPath.parseFromString(fieldName).getRootSegmentPath(); for (RelDataTypeField f : rowType.getFieldList()) { if (rootPart.equalsIgnoreCase(f.getName())) { return f; } } return null; }
if (column.equals(ROW_KEY_PATH)) { MaterializedField field = MaterializedField.create(column.getAsNamePart().getName(), ROW_KEY_TYPE); rowKeyVector = outputMutator.addField(field, VarBinaryVector.class); } else { getOrCreateFamilyVector(column.getRootSegment().getPath(), false);
if (!isStarQuery()) { for (SchemaPath column : columns) { if (column.getRootSegment().getPath().equalsIgnoreCase(ROW_KEY)) { transformed.add(ROW_KEY_PATH); continue; NameSegment root = column.getRootSegment(); byte[] family = root.getPath().getBytes(); transformed.add(SchemaPath.getSimplePath(root.getPath())); PathSegment child = root.getChild(); if (child != null && child.isNamed()) {
@Override public Boolean visitSchemaPath(SchemaPath path, LogicalExpression valueArg) throws RuntimeException { this.path = path.getRootSegmentPath();
final SchemaPath schemaPath = SchemaPath.getCompoundPath(column.getPath()); if (fields.contains(schemaPath)) { columnDescMap.put(schemaPath, column); final SchemaPath schemaPath = SchemaPath.getSimplePath(se.getName()); if (fields.contains(schemaPath)) { schemaElementMap.put(schemaPath, se); final SchemaPath schemaPath = SchemaPath.getCompoundPath(colMetaData.getPath().toArray()); if (fields.contains(schemaPath)) { columnChkMetaMap.put(schemaPath, colMetaData); final String columnName = path.getRootSegment().getPath(); if (implicitColValues.containsKey(columnName)) { TypeProtos.MajorType type = Types.required(TypeProtos.MinorType.VARCHAR);
private MapVector getOrCreateFamilyVector(String familyName, boolean allocateOnCreate) { try { MapVector v = familyVectorMap.get(familyName); if(v == null) { SchemaPath column = SchemaPath.getSimplePath(familyName); MaterializedField field = MaterializedField.create(column.getAsNamePart().getName(), COLUMN_FAMILY_TYPE); v = outputMutator.addField(field, MapVector.class); if (allocateOnCreate) { v.allocateNew(); } getColumns().add(column); familyVectorMap.put(familyName, v); } return v; } catch (SchemaChangeException e) { throw new DrillRuntimeException(e); } }
/** * Verify the presence of a column family in the schema path of the hbase table or whether the schema path is * the row key column. * * @param columns List of the selected columns * @param hTableDesc HTableDescriptor of HBase/MapR-DB_binary table (consists the details about that table) * @throws DrillRuntimeException if column family does not exist, or is not row_key column. */ public static void verifyColumns(List<SchemaPath> columns, HTableDescriptor hTableDesc) { if (Utilities.isStarQuery(columns)) { return; } for (SchemaPath column : columns) { if (!(column.equals(DrillHBaseConstants.ROW_KEY_PATH) || hTableDesc.hasFamily(HBaseUtils.getBytes(column.getRootSegment().getPath())))) { DrillRuntimeException.format("The column family '%s' does not exist in HBase table: %s .", column.getRootSegment().getPath(), hTableDesc.getNameAsString()); } } }
for (int i = 0; i < schemaPathStrings.length; i++) { SchemaPath schemaPath = encodedPathsItr.next(); if (schemaPath.getRootSegmentPath().startsWith(ENC_PREFIX)) { schemaPathStrings[i] = schemaPath.getRootSegmentPath(); } else { schemaPathStrings[i] = schemaPath.toExpr(); builder.add(SchemaPath.STAR_COLUMN); } else { builder.add(SchemaPath.parseFromString(decodedString));
public static SchemaPath getCompoundPath(String... strings) { NameSegment s = null; // loop through strings in reverse order for (int i = strings.length - 1; i >= 0; i--) { s = new NameSegment(strings[i], s); } return new SchemaPath(s); }
SchemaPath schemaPath = SchemaPath.getCompoundPath(columnMetadata.getName()); columnMetadataMap.put(schemaPath, columnMetadata); ColumnMetadata columnMetadata = columnMetadataMap.get(field.getUnIndexed()); if (columnMetadata != null) { ColumnStatisticsBuilder statisticsBuilder = ColumnStatisticsBuilder.builder() final String columnName = field.getRootSegment().getPath(); if (implicitColValues.containsKey(columnName)) { TypeProtos.MajorType type = Types.required(TypeProtos.MinorType.VARCHAR);
for (SchemaPath path : columns) { List<String> segments = Lists.newArrayList(); PathSegment seg = path.getRootSegment(); do { if (seg.isNamed()) { String[] pathSegments = new String[segments.size()]; segments.toArray(pathSegments); SchemaPath modifiedSchemaPath = SchemaPath.getCompoundPath(pathSegments); modifiedColumns.add(modifiedSchemaPath); for (ColumnDescriptor columnDescriptor : schemaColumns) { String[] schemaColDesc = Arrays.copyOf(columnDescriptor.getPath(), columnDescriptor.getPath().length); SchemaPath schemaPath = SchemaPath.getCompoundPath(schemaColDesc); schemaPaths.add(schemaPath); boolean notFound = true; for (SchemaPath schemaPath : schemaPaths) { if (schemaPath.contains(columnPath)) { selectedSchemaPaths.add(schemaPath); notFound = false; PathSegment seg = schemaPath.getRootSegment(); do { segments.add(seg.getNameSegment().getPath());
@Override public SchemaPath deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { return parseFromString(jp.getText()); } }