def visit_insert(self, statement: AbstractStatement):
        """Converter for parsed insert statement

        Arguments:
            statement {AbstractStatement} -- [input insert statement]
        """
        # Bind the table reference
        video = statement.table
        catalog_table_id = bind_table_ref(video.table_info)

        # Bind column_list
        col_list = statement.column_list
        for col in col_list:
            if col.table_name is None:
                col.table_name = video.table_info.table_name
            if col.table_metadata_id is None:
                col.table_metadata_id = catalog_table_id
        bind_columns_expr(col_list, {})

        # Nothing to be done for values as we add support for other variants of
        # insert we will handle them
        value_list = statement.value_list

        # Ready to create Logical node
        insert_opr = LogicalInsert(
            video, catalog_table_id, col_list, value_list)
        self._plan = insert_opr
示例#2
0
 def _visit_orderby(self, orderby_list):
     # orderby_list structure: List[(TupleValueExpression, EnumInt), ...]
     orderby_columns = [orderbyexpr[0] for orderbyexpr in orderby_list]
     bind_columns_expr(orderby_columns, self._column_map)
     orderby_opr = LogicalOrderBy(orderby_list)
     orderby_opr.append_child(self._plan)
     self._plan = orderby_opr
示例#3
0
    def visit_select(self, statement: AbstractStatement):
        """convertor for select statement

        Arguments:
            statement {AbstractStatement} -- [input select statement]
        """
        # Create a logical get node
        video = statement.from_table
        if video is not None:
            self.visit_table_ref(video)

        # Filter Operator
        predicate = statement.where_clause
        if predicate is not None:
            # Binding the expression
            bind_predicate_expr(predicate)
            filter_opr = LogicalFilter(predicate)
            filter_opr.append_child(self._plan)
            self._plan = filter_opr

        # Projection operator
        select_columns = statement.target_list

        # ToDO
        # add support for SELECT STAR
        if select_columns is not None:
            # Bind the columns using catalog
            bind_columns_expr(select_columns)
            projection_opr = LogicalProject(select_columns)
            projection_opr.append_child(self._plan)
            self._plan = projection_opr
 def _visit_projection(self, select_columns):
     # Bind the columns using catalog
     bind_columns_expr(select_columns, self._column_map)
     projection_opr = LogicalProject(select_columns)
     projection_opr.append_child(self._plan)
     self._plan = projection_opr
示例#5
0
 def test_bind_columns_calls_bind_func_expr_if_type_functional(
         self, mock_bind):
     func_expr = FunctionExpression(None, name='temp')
     bind_columns_expr([func_expr], {})
     mock_bind.assert_called_with(func_expr, {})