use of io.mycat.TableHandler in project Mycat2 by MyCATApache.
the class MycatTableScan method implement.
@Override
public Result implement(MycatEnumerableRelImplementor implementor, Prefer pref) {
final BlockBuilder builder = new BlockBuilder();
final PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), JavaRowFormat.ARRAY);
ParameterExpression root = implementor.getRootExpression();
TableScan tableScan = (TableScan) this.relNode;
MycatLogicTable mycatLogicTable = (MycatLogicTable) tableScan.getTable().unwrap(AbstractMycatTable.class);
TableHandler table = mycatLogicTable.getTable();
Method getObservable = Types.lookupMethod(NewMycatDataContext.class, "getTableObservable", String.class, String.class);
builder.add(Expressions.call(root, getObservable, Expressions.constant(table.getSchemaName()), Expressions.constant(table.getTableName())));
return implementor.result(physType, builder.toBlock());
}
use of io.mycat.TableHandler in project Mycat2 by MyCATApache.
the class LocalTableScan method getMycatRelDataType.
@Override
public MycatRelDataType getMycatRelDataType() {
MycatLogicTable mycatTable = getTable().unwrap(MycatLogicTable.class);
TableHandler tableTable = mycatTable.getTable();
List<MycatField> mycatFields = tableTable.getColumns().stream().map(c -> c.toMycatField()).collect(Collectors.toList());
return MycatRelDataType.of(mycatFields);
}
use of io.mycat.TableHandler in project Mycat2 by MyCATApache.
the class MycatRouteUpdateCore method explainTerms.
public RelWriter explainTerms(RelWriter pw) {
TableHandler table = MetaClusterCurrent.wrapper(MetadataManager.class).getTable(schemaName, tableName);
pw.item("sql", sqlStatement + "\n");
int index = 0;
for (Partition partition : getDataNodes(table)) {
pw.item("dataNodes$" + index, partition + "\n");
}
return pw;
}
use of io.mycat.TableHandler in project Mycat2 by MyCATApache.
the class VisualTablePlanImpl method execute.
@Override
public Observable<VectorSchemaRoot> execute(RootContext rootContext) {
RelOptTable table = relNode.getRelNode().getTable();
MycatLogicTable logicTable = table.unwrap(MycatLogicTable.class);
TableHandler tableHandler = logicTable.getTable();
VisualTableHandler visualTableHandler = (VisualTableHandler) tableHandler;
MetadataManager metadataManager = MetaClusterCurrent.wrapper(MetadataManager.class);
MycatRelDataType mycatRelDataTypeByCalcite = relNode.getMycatRelDataTypeByCalcite();
Schema schema = toArrowSchema(mycatRelDataTypeByCalcite);
return ValuesPlan.create(schema, MycatRxJavaUtl.blockingIterable(visualTableHandler.scanAll())).execute(rootContext);
}
use of io.mycat.TableHandler in project Mycat2 by MyCATApache.
the class PrototypeHandlerImpl method showCreateTable.
@Override
public List<Object[]> showCreateTable(SQLShowCreateTableStatement statement) {
SQLPropertyExpr sqlPropertyExpr = (SQLPropertyExpr) statement.getName();
String schemaName = SQLUtils.normalize(sqlPropertyExpr.getOwnerName());
String tableName = SQLUtils.normalize(sqlPropertyExpr.getSimpleName());
MetadataManager metadataManager = MetaClusterCurrent.wrapper(MetadataManager.class);
TableHandler tableHandler = metadataManager.getTable(schemaName, tableName);
String createTableSQL = tableHandler.getCreateTableSQL();
ArrayList<Object[]> objects = new ArrayList<>();
objects.add(new Object[] { tableName, createTableSQL });
return objects;
}
Aggregations