def test_bind_dataset(self, mock): video = MagicMock() catalog = mock.return_value actual = bind_dataset(video) catalog.get_dataset_metadata.assert_called_with( video.database_name, video.table_name) self.assertEqual(actual, catalog.get_dataset_metadata.return_value)
def visit_table_ref(self, video: TableRef): """Bind table ref object and convert to Logical get operator Arguments: video {TableRef} -- [Input table ref object created by the parser] """ catalog_vid_metadata = bind_dataset(video.table_info) self._populate_column_map(catalog_vid_metadata) self._plan = LogicalGet(video, catalog_vid_metadata)
def visit_load_data(self, statement: LoadDataStatement): """Convertor for parsed load data statement If the input table already exists we return its metadata. Else we will create a new metadata object for this table name. Arguments: statement(LoadDataStatement): [Load data statement] """ table = statement.table table_metainfo = bind_dataset(table.table_info) if table_metainfo is None: # Create a new metadata object table_metainfo = create_video_metadata(table.table_info.table_name) load_data_opr = LogicalLoadData(table_metainfo, statement.path) self._plan = load_data_opr
def visit_table_ref(self, table_ref: TableRef): """Bind table ref object and convert to Logical get operator Arguments: table {TableRef} -- [Input table ref object created by the parser] """ if table_ref.is_select(): # NestedQuery self.visit_select(table_ref.table) child_plan = self._plan self._plan = LogicalQueryDerivedGet() self._plan.append_child(child_plan) else: # Table catalog_vid_metadata = bind_dataset(table_ref.table) self._populate_column_map(catalog_vid_metadata) self._plan = LogicalGet(table_ref, catalog_vid_metadata) if table_ref.sample_freq: self._visit_sample(table_ref.sample_freq)