コード例 #1
0
 def query(self):
   """The Query that defines the view."""
   if not self.exists():
     return None
   self._table._load_info()
   if 'view' in self._table._info and 'query' in self._table._info['view']:
     return _query.Query(self._table._info['view']['query'], context=self._context)
   return None
コード例 #2
0
  def __init__(self, name, context=None):
    """Initializes an instance of a View object.

    Args:
      name: the name of the view either as a string or a 3-part tuple
          (projectid, datasetid, name). If a string, it must have the form
          '<project>:<dataset>.<view>' or '<dataset>.<view>'.
      context: an optional Context object providing project_id and credentials. If a specific
          project id or credentials are unspecified, the default ones configured at the global
          level are used.
    Raises:
      Exception if the name is invalid.
      """
    if context is None:
      context = gcp.Context.default()
    self._context = context
    self._table = _table.Table(name, context=context)
    self._materialization = _query.Query('SELECT * FROM %s' % self._repr_sql_(), context=context)