use of io.dingodb.exec.base.Job in project dingo by dingodb.
the class DingoDriverParser method parseQuery.
@Nonnull
public DingoSignature parseQuery(String sql, CalcitePrepare.Context context) throws SqlParseException {
SqlNode sqlNode = parse(sql);
if (sqlNode.getKind().belongsTo(SqlKind.DDL)) {
final DdlExecutor ddlExecutor = parserConfig.parserFactory().getDdlExecutor();
ddlExecutor.executeDdl(context, sqlNode);
return new DingoSignature(ImmutableList.of(), sql, Meta.CursorFactory.OBJECT, Meta.StatementType.OTHER_DDL);
}
JavaTypeFactory typeFactory = context.getTypeFactory();
sqlNode = validate(sqlNode);
Meta.StatementType statementType;
RelDataType type;
switch(sqlNode.getKind()) {
case INSERT:
case DELETE:
case UPDATE:
statementType = Meta.StatementType.IS_DML;
type = RelOptUtil.createDmlRowType(sqlNode.getKind(), typeFactory);
break;
default:
statementType = Meta.StatementType.SELECT;
type = getValidatedNodeType(sqlNode);
break;
}
RelDataType jdbcType = makeStruct(typeFactory, type);
List<List<String>> originList = getFieldOrigins(sqlNode);
final List<ColumnMetaData> columns = getColumnMetaDataList(typeFactory, jdbcType, originList);
final Meta.CursorFactory cursorFactory = Meta.CursorFactory.ARRAY;
RelRoot relRoot = convert(sqlNode);
RelNode relNode = optimize(relRoot.rel, DingoConventions.ROOT);
Job job = DingoJobVisitor.createJob(relNode, true);
return new DingoSignature(columns, sql, null, null, cursorFactory, statementType, job);
}
Aggregations