Exemplo n.º 1
0
    def test_simple_binder_match(self):
        """
        Opr Tree:
                         LogicalFilter
                         /           \
                  LogicalGet      LogicalGet

        Pattern:
                         LogicalFilter
                         /           \
                  LogicalGet      LogicalGet
        """
        child1_opr = LogicalGet(MagicMock(), MagicMock())
        child2_opr = LogicalGet(MagicMock(), MagicMock())
        root_opr = LogicalFilter(MagicMock(), [child1_opr, child2_opr])

        child1_ptn = Pattern(OperatorType.LOGICALGET)
        child2_ptn = Pattern(OperatorType.LOGICALGET)
        root_ptn = Pattern(OperatorType.LOGICALFILTER)
        root_ptn.append_child(child1_ptn)
        root_ptn.append_child(child2_ptn)

        opt_ctxt = OptimizerContext()
        root_grp_expr = opt_ctxt.xform_opr_to_group_expr(root_opr,
                                                         is_root=True)

        binder = Binder(root_grp_expr, root_ptn, opt_ctxt.memo)

        for match in iter(binder):
            self.helper_pre_order_match(root_opr, match)
Exemplo n.º 2
0
    def test_nested_binder_match(self):
        """
        Opr Tree:
                         LogicalFilter
                         /           \
                  LogicalGet      LogicalFilter
                                  /           \
                            LogicalGet       Dummy

        Pattern:
                         LogicalFilter
                         /           \
                  LogicalGet      Dummy
        """

        sub_child_opr = LogicalGet(MagicMock(), MagicMock())
        sub_root_opr = LogicalFilter(MagicMock(), [sub_child_opr, Dummy()])

        child_opr = LogicalGet(MagicMock(), MagicMock())
        root_opr = LogicalFilter(MagicMock(), [child_opr, sub_root_opr])

        # copy for binder to operate on
        sub_child_opr_cpy = LogicalGet(MagicMock(), MagicMock())
        sub_root_opr_cpy = LogicalFilter(
            MagicMock(), [sub_child_opr_cpy, Dummy()])

        child_opr_cpy = LogicalGet(MagicMock(), MagicMock())
        root_opr_cpy = LogicalFilter(MagicMock(),
                                     [child_opr_cpy, sub_root_opr_cpy])

        child_ptn = Pattern(OperatorType.LOGICALGET)
        root_ptn = Pattern(OperatorType.LOGICALFILTER)
        root_ptn.append_child(child_ptn)
        root_ptn.append_child(Pattern(OperatorType.DUMMY))

        opt_ctxt = OptimizerContext()
        root_grp_expr = opt_ctxt.xform_opr_to_group_expr(root_opr_cpy,
                                                         is_root=True)
        binder = Binder(root_grp_expr, root_ptn, opt_ctxt.memo)
        for match in iter(binder):
            self.helper_pre_order_match(root_opr, match)

        opt_ctxt = OptimizerContext()
        sub_root_grp_expr = opt_ctxt.xform_opr_to_group_expr(sub_root_opr_cpy,
                                                             is_root=True)
        binder = Binder(sub_root_grp_expr, root_ptn, opt_ctxt.memo)
        for match in iter(binder):
            self.helper_pre_order_match(sub_root_opr, match)
Exemplo n.º 3
0
 def __init__(self):
     pattern = Pattern(OperatorType.LOGICALLIMIT)
     pattern.append_child(Pattern(OperatorType.DUMMY))
     super().__init__(RuleType.LOGICAL_LIMIT_TO_PHYSICAL, pattern)
Exemplo n.º 4
0
 def __init__(self):
     pattern = Pattern(OperatorType.LOGICALUNION)
     # add 2 dummy children
     pattern.append_child(Pattern(OperatorType.DUMMY))
     pattern.append_child(Pattern(OperatorType.DUMMY))
     super().__init__(RuleType.LOGICAL_UNION_TO_PHYSICAL, pattern)
Exemplo n.º 5
0
 def __init__(self):
     pattern = Pattern(OperatorType.LOGICALQUERYDERIVEDGET)
     pattern.append_child(Pattern(OperatorType.DUMMY))
     super().__init__(RuleType.LOGICAL_DERIVED_GET_TO_PHYSICAL, pattern)
Exemplo n.º 6
0
 def __init__(self):
     pattern = Pattern(OperatorType.LOGICALSAMPLE)
     pattern.append_child(Pattern(OperatorType.DUMMY))
     super().__init__(RuleType.LOGICAL_SAMPLE_TO_UNIFORMSAMPLE, pattern)
Exemplo n.º 7
0
 def __init__(self):
     pattern = Pattern(OperatorType.LOGICALGET)
     # pattern.append_child(Pattern(OperatorType.DUMMY))
     super().__init__(RuleType.LOGICAL_GET_TO_SEQSCAN, pattern)
Exemplo n.º 8
0
 def __init__(self):
     pattern = Pattern(OperatorType.LOGICALCREATEUDF)
     # pattern.append_child(Pattern(OperatorType.DUMMY))
     super().__init__(RuleType.LOGICAL_CREATE_UDF_TO_PHYSICAL, pattern)
Exemplo n.º 9
0
 def __init__(self):
     pattern = Pattern(OperatorType.LOGICALPROJECT)
     pattern_sample = Pattern(OperatorType.LOGICALSAMPLE)
     pattern_sample.append_child(Pattern(OperatorType.LOGICALGET))
     pattern.append_child(pattern_sample)
     super().__init__(RuleType.PUSHDOWN_PROJECT_THROUGH_SAMPLE, pattern)
Exemplo n.º 10
0
 def __init__(self):
     pattern = Pattern(OperatorType.LOGICALPROJECT)
     pattern_get = Pattern(OperatorType.LOGICALQUERYDERIVEDGET)
     pattern_get.append_child(Pattern(OperatorType.DUMMY))
     pattern.append_child(pattern_get)
     super().__init__(RuleType.EMBED_PROJECT_INTO_DERIVED_GET, pattern)
Exemplo n.º 11
0
 def __init__(self):
     pattern = Pattern(OperatorType.LOGICALPROJECT)
     pattern.append_child(Pattern(OperatorType.LOGICALGET))
     super().__init__(RuleType.EMBED_PROJECT_INTO_GET, pattern)