Exemple #1
0
 def test_should_return_correct_plan_tree_for_input_logical_tree(self):
     logical_plan = LogicalCreateUDF('udf', True, ['inp'], ['out'], 'tmp')
     plan = PlanGenerator().build(logical_plan)
     self.assertIsInstance(plan, CreateUDFPlan)
     self.assertEqual(plan.name, 'udf')
     self.assertEqual(plan.inputs, ['inp'])
     self.assertEqual(plan.outputs, ['out'])
     self.assertEqual(plan.impl_path, 'tmp')
     self.assertEqual(plan.if_not_exists, True)
    def visit_create_udf(self, statement: CreateUDFStatement):
        """Convertor for parsed create udf statement

        Arguments:
            statement {CreateUDFStatement} -- Create UDF Statement
        """
        annotated_inputs = column_definition_to_udf_io(statement.inputs, True)
        annotated_outputs = column_definition_to_udf_io(
            statement.outputs, False)

        create_udf_opr = LogicalCreateUDF(statement.name,
                                          statement.if_not_exists,
                                          annotated_inputs, annotated_outputs,
                                          statement.impl_path,
                                          statement.udf_type)
        self._plan = create_udf_opr
Exemple #3
0
 def test_should_return_false_for_unequal_plans(self):
     create_plan = LogicalCreate(TableRef(TableInfo('video')),
                                 [MagicMock()])
     create_udf_plan = LogicalCreateUDF('udf', False, None, None, None)
     insert_plan = LogicalInsert(MagicMock(), 0, [MagicMock()],
                                 [MagicMock()])
     query_derived_plan = LogicalQueryDerivedGet()
     load_plan = LogicalLoadData(MagicMock(), MagicMock())
     self.assertEqual(create_plan, create_plan)
     self.assertEqual(create_udf_plan, create_udf_plan)
     self.assertNotEqual(create_plan, create_udf_plan)
     self.assertNotEqual(create_udf_plan, create_plan)
     create_plan.append_child(create_udf_plan)
     self.assertNotEqual(create_plan, create_udf_plan)
     self.assertNotEqual(query_derived_plan, create_plan)
     self.assertNotEqual(insert_plan, query_derived_plan)
     self.assertNotEqual(load_plan, insert_plan)
 def test_should_call_create_udf_generator_for_logical_create_udf(
         self, mock):
     mock_instance = mock.return_value
     l_create_udf = LogicalCreateUDF('udf', True, [], [], 'tmp')
     PlanGenerator().build(l_create_udf)
     mock_instance.build.assert_called_with(l_create_udf)