use of io.mycat.MetadataManager 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.MetadataManager 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;
}
use of io.mycat.MetadataManager in project Mycat2 by MyCATApache.
the class AnalyzeHanlder method onExecute.
@Override
protected Future<Void> onExecute(SQLRequest<MySqlAnalyzeStatement> request, MycatDataContext dataContext, Response response) {
MySqlAnalyzeStatement ast = request.getAst();
List<SQLExprTableSource> tableSources = Optional.ofNullable(ast.getTableSources()).orElse(Collections.emptyList());
if (tableSources.isEmpty()) {
return response.sendError(new MycatException("need tables"));
} else {
ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
resultSetBuilder.addColumnInfo("Table", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("Op", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("Msg_type", JDBCType.VARCHAR);
resultSetBuilder.addColumnInfo("Msg_Text", JDBCType.VARCHAR);
for (SQLExprTableSource tableSource : tableSources) {
String schemaName = SQLUtils.normalize(tableSource.getSchema());
String tableName = SQLUtils.normalize(tableSource.getTableName());
resultSetBuilder.addObjectRowPayload(Arrays.asList(schemaName + "." + tableName, "analyze", "status", "OK"));
MetadataManager metadataManager = MetaClusterCurrent.wrapper(MetadataManager.class);
TableHandler tableHandler = metadataManager.getTable(schemaName, tableName);
if (tableHandler == null) {
return response.sendError(new MycatException(tableSource + "不存在"));
}
StatisticCenter statisticCenter = MetaClusterCurrent.wrapper(StatisticCenter.class);
statisticCenter.fetchTableRowCount(tableHandler);
}
return response.sendResultSet(resultSetBuilder.build());
}
}
use of io.mycat.MetadataManager in project Mycat2 by MyCATApache.
the class MycatRouteInsertCore method logicTable.
public ShardingTableHandler logicTable() {
MetadataManager metadataManager = MetaClusterCurrent.wrapper(MetadataManager.class);
TableHandler tableHandler = metadataManager.getTable(schemaName, tableName);
return (ShardingTableHandler) tableHandler;
}
Aggregations