use of io.crate.metadata.ColumnIdent in project crate by crate.
the class SysNodesExpressionsTest method testNestedBytesRefExpressionsString.
@Test
public void testNestedBytesRefExpressionsString() throws Exception {
Reference refInfo = refInfo("sys.nodes.version", DataTypes.OBJECT, RowGranularity.NODE);
ColumnIdent versionColIdent = refInfo.ident().columnIdent();
io.crate.operation.reference.NestedObjectExpression version = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(versionColIdent.name());
assertThat(version.value().get("number"), instanceOf(String.class));
}
use of io.crate.metadata.ColumnIdent in project crate by crate.
the class FileWriterCountCollector method toNestedStringObjectMap.
@VisibleForTesting
static Map<String, Object> toNestedStringObjectMap(Map<ColumnIdent, Object> columnIdentObjectMap) {
Map<String, Object> nestedMap = new HashMap<>();
Map<String, Object> parent = nestedMap;
for (Map.Entry<ColumnIdent, Object> entry : columnIdentObjectMap.entrySet()) {
ColumnIdent key = entry.getKey();
Object value = entry.getValue();
if (key.path().isEmpty()) {
nestedMap.put(key.name(), value);
} else {
LinkedList<String> path = new LinkedList<>(key.path());
path.add(0, key.name());
while (true) {
String currentKey = path.pop();
if (path.isEmpty()) {
parent.put(currentKey, value);
break;
}
Object o = parent.get(currentKey);
if (o == null) {
Map<String, Object> child = new HashMap<>();
parent.put(currentKey, child);
parent = child;
} else {
assert o instanceof Map : "o must be instance of Map";
parent = (Map) o;
}
}
}
}
return nestedMap;
}
use of io.crate.metadata.ColumnIdent in project crate by crate.
the class FileLineReferenceResolver method getImplementation.
public static LineCollectorExpression<?> getImplementation(Reference refInfo) {
ColumnIdent columnIdent = refInfo.ident().columnIdent();
Supplier<LineCollectorExpression<?>> supplier = EXPRESSION_BUILDER.get(columnIdent.name());
if (supplier == null) {
return new ColumnExtractingLineExpression(columnIdent);
}
return supplier.get();
}
use of io.crate.metadata.ColumnIdent in project crate by crate.
the class NodeStatsRequest method readFrom.
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
columns = new HashSet<>();
int columnIdentsSize = in.readVInt();
for (int i = 0; i < columnIdentsSize; i++) {
columns.add(new ColumnIdent(in));
}
}
use of io.crate.metadata.ColumnIdent in project crate by crate.
the class TableReferenceResolver method resolveField.
@Override
public Reference resolveField(QualifiedName qualifiedName, @Nullable List<String> path, Operation operation) {
List<String> parts = qualifiedName.getParts();
ColumnIdent columnIdent = new ColumnIdent(parts.get(parts.size() - 1), path);
if (parts.size() != 1) {
throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Column reference \"%s\" has too many parts. " + "A column must not have a schema or a table here.", qualifiedName));
}
for (Reference reference : tableReferences) {
if (reference.ident().columnIdent().equals(columnIdent)) {
if (reference instanceof GeneratedReference) {
throw new IllegalArgumentException("A generated column cannot be based on a generated column");
}
references.add(reference);
return reference;
}
}
throw new ColumnUnknownException(columnIdent.sqlFqn());
}
Aggregations