Search in sources :

Example 36 with ShardingTable

use of io.mycat.calcite.table.ShardingTable in project Mycat2 by MyCATApache.

the class PredicateAnalyzerTest method testOr.

// 
@Test
public void testOr() {
    DrdsSqlCompiler drds = DrdsTest.getDrds();
    RexNode leftRexNode = rexBuilder.makeCall(SqlStdOperatorTable.GREATER_THAN, rexBuilder.makeInputRef(MycatCalciteSupport.TypeFactory.createSqlType(SqlTypeName.INTEGER), 0), rexBuilder.makeDynamicParam(MycatCalciteSupport.TypeFactory.createSqlType(SqlTypeName.INTEGER), 0));
    RexNode rightRexNode = rexBuilder.makeCall(SqlStdOperatorTable.LESS_THAN, rexBuilder.makeInputRef(MycatCalciteSupport.TypeFactory.createSqlType(SqlTypeName.INTEGER), 0), rexBuilder.makeDynamicParam(MycatCalciteSupport.TypeFactory.createSqlType(SqlTypeName.INTEGER), 1));
    RexNode rexNode = rexBuilder.makeCall(SqlStdOperatorTable.OR, leftRexNode, rightRexNode);
    List<String> columnList = Arrays.asList("id");
    PredicateAnalyzer predicateAnalyzer2 = new PredicateAnalyzer(Arrays.asList(KeyMeta.of("default", Arrays.asList("id"))), columnList);
    MetadataManager metadataManager = DrdsTest.getMetadataManager();
    ShardingTable table = (ShardingTable) metadataManager.getTable("db1", "sharding");
    Map<QueryType, List<IndexCondition>> queryTypeListMap = predicateAnalyzer2.translateMatch(rexNode);
    Assert.assertEquals(0, queryTypeListMap.size());
    System.out.println();
}
Also used : PredicateAnalyzer(io.mycat.calcite.rewriter.PredicateAnalyzer) ShardingTable(io.mycat.calcite.table.ShardingTable) QueryType(io.mycat.querycondition.QueryType) RexNode(org.apache.calcite.rex.RexNode) Test(org.junit.Test)

Aggregations

ShardingTable (io.mycat.calcite.table.ShardingTable)36 Test (org.junit.Test)26 MetadataManager (io.mycat.MetadataManager)22 Partition (io.mycat.Partition)17 RexNode (org.apache.calcite.rex.RexNode)15 CustomRuleFunction (io.mycat.router.CustomRuleFunction)14 ShardingTableConfig (io.mycat.config.ShardingTableConfig)12 RangeVariable (io.mycat.RangeVariable)11 ValuePredicateAnalyzer (io.mycat.calcite.rewriter.ValuePredicateAnalyzer)11 DrdsSqlCompiler (io.mycat.DrdsSqlCompiler)10 QueryType (io.mycat.querycondition.QueryType)10 Map (java.util.Map)10 java.util (java.util)8 ImmutableList (com.google.common.collect.ImmutableList)6 GlobalTable (io.mycat.calcite.table.GlobalTable)6 NormalTable (io.mycat.calcite.table.NormalTable)6 SqlTypeName (org.apache.calcite.sql.type.SqlTypeName)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 MycatCalciteSupport (io.mycat.calcite.MycatCalciteSupport)5 ValueIndexCondition (io.mycat.calcite.rewriter.ValueIndexCondition)5