@@ -0,0 +1,3195 @@
+# Copyright 2019-present Kensho Technologies, LLC.%0Afrom textwrap import dedent%0Aimport unittest%0A%0Afrom graphql import parse, print_ast%0A%0Afrom ...schema_transformation.make_query_plan import make_query_plan%0Afrom ...schema_transformation.split_query import split_query%0Afrom .example_schema import basic_merged_schema%0A%0A%0Aclass TestMakeQueryPlan(unittest.TestCase):%0A    def test_basic_make_query_plan(self):%0A        query_str = dedent('''%5C%0A            %7B%0A              Animal %7B%0A                out_Animal_Creature %7B%0A                  age @output(out_name: %22age%22)%0A                %7D%0A              %7D%0A            %7D%0A        ''')%0A        parent_str = dedent('''%5C%0A            %7B%0A              Animal %7B%0A                uuid @output(out_name: %22__intermediate_output_0%22)%0A              %7D%0A            %7D%0A        ''')%0A        child_str_no_filter = dedent('''%5C%0A            %7B%0A              Creature %7B%0A                age @output(out_name: %22age%22)%0A                id @output(out_name: %22__intermediate_output_1%22)%0A              %7D%0A            %7D%0A        ''')%0A        child_str_with_filter = dedent('''%5C%0A            %7B%0A              Creature %7B%0A                age @output(out_name: %22age%22)%0A                id @output(out_name: %22__intermediate_output_1%22) %5C%0A@filter(op_name: %22in_collection%22, value: %5B%22$__intermediate_output_0%22%5D)%0A              %7D%0A            %7D%0A        ''')%0A        query_node, intermediate_outputs = split_query(parse(query_str), basic_merged_schema)%0A        query_plan_descriptor = make_query_plan(query_node, intermediate_outputs)%0A        # Check the child ASTs in the input query node are unchanged (@filter not added))%0A        child_query_node = query_node.child_query_connections%5B0%5D.sink_query_node%0A        self.assertEqual(print_ast(child_query_node.query_ast), child_str_no_filter)%0A        # Check the query plan%0A        parent_sub_query_plan = query_plan_descriptor.root_sub_query_plan%0A        self.assertEqual(print_ast(parent_sub_query_plan.query_ast), parent_str)%0A        self.assertEqual(parent_sub_query_plan.schema_id, 'first')%0A        self.assertIsNone(parent_sub_query_plan.parent_query_plan)%0A        self.assertEqual(len(parent_sub_query_plan.child_query_plans), 1)%0A        # Check the child query plan%0A        child_sub_query_plan = parent_sub_query_plan.child_query_plans%5B0%5D%0A        self.assertEqual(print_ast(child_sub_query_plan.query_ast), child_str_with_filter)%0A        self.assertEqual(child_sub_query_plan.schema_id, 'second')%0A        self.assertIs(child_sub_query_plan.parent_query_plan, parent_sub_query_plan)%0A        self.assertEqual(len(child_sub_query_plan.child_query_plans), 0)%0A        # Check the output join descriptors%0A        output_join_descriptors = query_plan_descriptor.output_join_descriptors%0A        self.assertEqual(len(output_join_descriptors), 1)%0A        output_join_descriptor = output_join_descriptors%5B0%5D%0A        self.assertEqual(%0A            output_join_descriptor.output_names,%0A            ('__intermediate_output_0', '__intermediate_output_1')%0A        )%0A        # Check set of intermediate output names%0A        self.assertEqual(%0A            query_plan_descriptor.intermediate_output_names,%0A            %7B'__intermediate_output_0', '__intermediate_output_1'%7D%0A        )%0A

Add a test for make_query (#494)