GithubHelp home page GithubHelp logo

Comments (4)

terrymanu avatar terrymanu commented on May 19, 2024

or的处理是基于不包含or处理器之上的。mergeCurrentConditionContext这个方法不是为了处理merge聚合列,是为了生产和or统一的返回格式

from shardingsphere.

pingww avatar pingww commented on May 19, 2024

@terrymanu ,我测了一下,有or条件的情况,没有做groupby、avg等分组聚合处理;or的处理是基于不包含or处理器之上的?这个哪里体现的,没有看到啊

from shardingsphere.

hanahmily avatar hanahmily commented on May 19, 2024

@pingww 抱歉一开始没有好好理解你的问题。其实sharding-jdbc对or的结果集归并与其他归并方法相同。
com.dangdang.ddframe.rdb.sharding.jdbc.ShardingPreparedStatement

    @Override
    public ResultSet executeQuery() throws SQLException {
        hasExecuted = true;
        setCurrentResultSet(ResultSetFactory.getResultSet(new PreparedStatementExecutor(getContext().getExecutorEngine(), getRoutedPreparedStatements()).executeQuery(), getMergeContext()));
        return getCurrentResultSet();
    }

...

private List<PreparedStatement> routeSQL(final List<Object> parameters) throws SQLException {
        List<PreparedStatement> result = new ArrayList<>();
        SQLRouteResult sqlRouteResult = getContext().getSqlRouteEngine().route(sql, parameters);
        MergeContext mergeContext = sqlRouteResult.getMergeContext();
        mergeContext.setExecutorEngine(getContext().getExecutorEngine());
        setMergeContext(mergeContext);
        for (SQLExecutionUnit each : sqlRouteResult.getExecutionUnits()) {
            PreparedStatement preparedStatement = generatePrepareStatement(getShardingConnection().getConnection(each.getDataSource()), each.getSql());
            replayMethodsInvovation(preparedStatement);
            setParameters(preparedStatement, parameters);
            result.add(preparedStatement);
        }
        return result;
    }

也就是不管当前sql是什么,流程都是 SqlRouterEngine-》SQLExecutionUnit -》 ResultSetFactory 。

如果你的示例不能执行归并,那么请把日志级别调整为trace然后发出来,我再进行跟踪。
谢谢

from shardingsphere.

pingww avatar pingww commented on May 19, 2024

MergeContext 都是在MySQLSelectVisitor里面生成的,OR解析没有使用这个visitor,所以归并上下文为空。 @hanahmily

from shardingsphere.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.