Search in sources :

Example 1 with TestJoinTaskContext

use of com.qlangtech.tis.order.center.TestJoinTaskContext in project tis by qlangtech.

the class TestSqlRewriter method testTotalpaySummaryRewriteByWithoutDefinePrimaryTableShareKey.

/**
 * 执行索引全量构建过程中,测试ERRule没有定义主表的<b>shareKey</b>,会导致final表的分区函数无法正常创建,需要主动抛出一个异常
 */
public void testTotalpaySummaryRewriteByWithoutDefinePrimaryTableShareKey() {
    TestJoinTaskContext taskContext = new TestJoinTaskContext(ExecutePhaseRange.fullRange());
    SqlTaskNodeMeta nodeMeta = getSqlTaskNodeMeta(totalpaySummary);
    ERRules erRules = createMockErRules(new TableMeta(totalpayinfo.getTableName(), null));
    EasyMock.replay(erRules);
    Exception occurException = null;
    try {
        assertFull(totalpaySummary, true, nodeMeta, taskContext, erRules, nodeMeta.getSql());
        fail("shall throw new exception");
    } catch (Exception e) {
        occurException = e;
    }
    assertNotNull("must throw an error", occurException);
    assertEquals(SqlRewriter.ERROR_WithoutDefinePrimaryTableShareKey, ExceptionUtils.getRootCause(occurException).getMessage());
    EasyMock.verify(erRules);
}
Also used : TableMeta(com.qlangtech.tis.sql.parser.er.TableMeta) TestJoinTaskContext(com.qlangtech.tis.order.center.TestJoinTaskContext) ERRules(com.qlangtech.tis.sql.parser.er.ERRules)

Example 2 with TestJoinTaskContext

use of com.qlangtech.tis.order.center.TestJoinTaskContext in project tis by qlangtech.

the class TestSqlRewriter method testTotalpaySummaryRewriteByWithoutDefinePrimaryTable.

/**
 * 执行索引全量构建过程中,测试ERRule没有定义主表,会导致final表的分区函数无法正常创建,需要主动抛出一个异常
 */
public void testTotalpaySummaryRewriteByWithoutDefinePrimaryTable() {
    TestJoinTaskContext taskContext = new TestJoinTaskContext(ExecutePhaseRange.fullRange());
    SqlTaskNodeMeta nodeMeta = getSqlTaskNodeMeta(totalpaySummary);
    // ERRules erRules = EasyMock.createMock("erRules", ERRules.class);
    // EasyMock.expect(erRules.getTabFieldProcessorMap()).andReturn(Collections.emptyMap());
    // EasyMock.expect(erRules.getPrimaryTab(totalpayinfo))
    // .andReturn(Optional.empty()/** 没有定义主表*/).anyTimes();
    ERRules erRules = createMockErRules(null);
    EasyMock.replay(erRules);
    Exception occurException = null;
    try {
        assertFull(totalpaySummary, true, nodeMeta, taskContext, erRules, nodeMeta.getSql());
        fail("shall throw new exception");
    } catch (Exception e) {
        occurException = e;
    }
    assertNotNull("must throw an error", occurException);
    assertEquals(SqlRewriter.ERROR_WithoutDefinePrimaryTableShareKey, ExceptionUtils.getRootCause(occurException).getMessage());
    EasyMock.verify(erRules);
}
Also used : TestJoinTaskContext(com.qlangtech.tis.order.center.TestJoinTaskContext) ERRules(com.qlangtech.tis.sql.parser.er.ERRules)

Example 3 with TestJoinTaskContext

use of com.qlangtech.tis.order.center.TestJoinTaskContext in project tis by qlangtech.

the class TestSqlRewriter method testTotalpaySummaryRewrite.

public void testTotalpaySummaryRewrite() {
    SqlTaskNodeMeta nodeMeta = getSqlTaskNodeMeta(totalpaySummary);
    final int sharedCount = 999;
    TestJoinTaskContext taskContext = new TestJoinTaskContext(ExecutePhaseRange.fullRange()) {

        @Override
        public int getIndexShardCount() {
            return sharedCount;
        }
    };
    assertFull(totalpaySummary, true, nodeMeta, taskContext, nodeMeta.getSql());
}
Also used : TestJoinTaskContext(com.qlangtech.tis.order.center.TestJoinTaskContext)

Example 4 with TestJoinTaskContext

use of com.qlangtech.tis.order.center.TestJoinTaskContext in project tis by qlangtech.

the class TestSqlRewriter method testRewriteTable.

public void testRewriteTable() throws Exception {
    TestJoinTaskContext taskContext = new TestJoinTaskContext();
    // taskContext
    topology.getNodeMetas().stream().forEach((meta) -> {
        // waitProcessAliasTabsSetSize);
        if ("totalpay_summary".equals(meta.getExportName())) {
            return;
        }
        assertFull(meta.getExportName(), meta, taskContext, meta.getSql());
    });
    String extraSql = processFileContent(getScriptContent("sqlrewrite.txt"));
    String extraSqlAssert = processFileContent(getScriptContent("sqlrewrite_assert.txt"));
    MetaContent meta = this.getMetaContent("sqlrewrite_meta.txt");
    final String orderInstance = "order_instance";
    SqlTaskNodeMeta nodeMeta = getSqlTaskNodeMeta(orderInstance);
    rewriteAssert(orderInstance, nodeMeta, extraSqlAssert, extraSql, meta, taskContext);
}
Also used : TestJoinTaskContext(com.qlangtech.tis.order.center.TestJoinTaskContext)

Example 5 with TestJoinTaskContext

use of com.qlangtech.tis.order.center.TestJoinTaskContext in project tis by qlangtech.

the class TestSqlRewriter method testOrder_instance.

public void testOrder_instance() {
    final String order_instance = "order_instance";
    SqlTaskNodeMeta nodeMeta = getSqlTaskNodeMeta(order_instance);
    TestJoinTaskContext taskContext = new TestJoinTaskContext();
    assertFull(order_instance, nodeMeta, taskContext, nodeMeta.getSql());
}
Also used : TestJoinTaskContext(com.qlangtech.tis.order.center.TestJoinTaskContext)

Aggregations

TestJoinTaskContext (com.qlangtech.tis.order.center.TestJoinTaskContext)6 ERRules (com.qlangtech.tis.sql.parser.er.ERRules)2 TableMeta (com.qlangtech.tis.sql.parser.er.TableMeta)1