

def create_view(self, dataset, view, query):
    'Create a new view in the dataset.\n\n        Parameters\n        ----------\n        dataset : str\n            The dataset to create the view in\n        view : str\n            The name of the view to create\n        query : dict\n            A query that BigQuery executes when the view is referenced.\n\n        Returns\n        -------\n        Union[bool, dict]\n            bool indicating if the view was successfully created or not,\n            or response from BigQuery if swallow_results is set to False.\n        '
    body = {
        'tableReference': {
            'tableId': view,
            'projectId': self.project_id,
            'datasetId': dataset,
        },
        'view': {
            'query': query,
        },
    }
    try:
        view = self.bigquery.tables().insert(projectId=self.project_id, datasetId=dataset, body=body).execute()
        if self.swallow_results:
            return True
        else:
            return view
    except HttpError as e:
        logger.error('Cannot create view {0}.{1}\nHttp Error: {2}'.format(dataset, view, e.content))
        if self.swallow_results:
            return False
        else:
            return {
                
            }

dataset/ETHPy150Open tylertreat/BigQuery-Python/bigquery/client.py BigQueryClient.create_view/original