use of org.apache.ignite.internal.processors.query.ColumnInformation in project ignite by apache.
the class IgniteH2Indexing method columnsInformation.
/**
* {@inheritDoc}
*/
@Override
public Collection<ColumnInformation> columnsInformation(String schemaNamePtrn, String tblNamePtrn, String colNamePtrn) {
Collection<ColumnInformation> infos = new ArrayList<>();
// Gather information about tables.
schemaMgr.dataTables().stream().filter(t -> matches(t.getSchema().getName(), schemaNamePtrn)).filter(t -> matches(t.getName(), tblNamePtrn)).flatMap(tbl -> {
IndexColumn affCol = tbl.getAffinityKeyColumn();
return Stream.of(tbl.getColumns()).filter(Column::getVisible).filter(c -> matches(c.getName(), colNamePtrn)).map(c -> {
GridQueryProperty prop = tbl.rowDescriptor().type().property(c.getName());
boolean isAff = affCol != null && c.getColumnId() == affCol.column.getColumnId();
return new ColumnInformation(c.getColumnId() - QueryUtils.DEFAULT_COLUMNS_COUNT + 1, tbl.getSchema().getName(), tbl.getName(), c.getName(), prop.type(), c.isNullable(), prop.defaultValue(), prop.precision(), prop.scale(), isAff);
});
}).forEach(infos::add);
// Gather information about system views.
if (matches(QueryUtils.SCHEMA_SYS, schemaNamePtrn)) {
schemaMgr.systemViews().stream().filter(v -> matches(v.getTableName(), tblNamePtrn)).flatMap(view -> Stream.of(view.getColumns()).filter(c -> matches(c.getName(), colNamePtrn)).map(c -> new ColumnInformation(c.getColumnId() + 1, QueryUtils.SCHEMA_SYS, view.getTableName(), c.getName(), IgniteUtils.classForName(DataType.getTypeClassName(c.getType()), Object.class), c.isNullable(), null, (int) c.getPrecision(), c.getScale(), false))).forEach(infos::add);
}
return infos;
}
Aggregations