@@ -138,7 +138,7 @@ def _reference_getter(table):
138138
139139
140140def _view_use_legacy_sql_getter (
141- table : Union ["Table" , "TableListItem" ]
141+ table : Union ["Table" , "TableListItem" ],
142142) -> Optional [bool ]:
143143 """bool: Specifies whether to execute the view with Legacy or Standard SQL.
144144
@@ -359,6 +359,131 @@ def __repr__(self):
359359 return f"TableReference({ dataset_ref !r} , '{ self .table_id } ')"
360360
361361
362+ class PropertyGraphReference :
363+ """PropertyGraphReferences are pointers to property graphs.
364+
365+ Args:
366+ dataset_ref: A pointer to the dataset
367+ property_graph_id: The ID of the property graph
368+ """
369+
370+ _PROPERTY_TO_API_FIELD = {
371+ "dataset_id" : "datasetId" ,
372+ "project" : "projectId" ,
373+ "property_graph_id" : "propertyGraphId" ,
374+ }
375+
376+ def __init__ (self , dataset_ref : "DatasetReference" , property_graph_id : str ):
377+ self ._properties = {}
378+
379+ _helpers ._set_sub_prop (
380+ self ._properties ,
381+ self ._PROPERTY_TO_API_FIELD ["project" ],
382+ dataset_ref .project ,
383+ )
384+ _helpers ._set_sub_prop (
385+ self ._properties ,
386+ self ._PROPERTY_TO_API_FIELD ["dataset_id" ],
387+ dataset_ref .dataset_id ,
388+ )
389+ _helpers ._set_sub_prop (
390+ self ._properties ,
391+ self ._PROPERTY_TO_API_FIELD ["property_graph_id" ],
392+ property_graph_id ,
393+ )
394+
395+ @property
396+ def project (self ) -> str :
397+ """str: Project bound to the property graph."""
398+ return _helpers ._get_sub_prop (
399+ self ._properties , self ._PROPERTY_TO_API_FIELD ["project" ]
400+ )
401+
402+ @property
403+ def dataset_id (self ) -> str :
404+ """str: ID of dataset containing the property graph."""
405+ return _helpers ._get_sub_prop (
406+ self ._properties , self ._PROPERTY_TO_API_FIELD ["dataset_id" ]
407+ )
408+
409+ @property
410+ def property_graph_id (self ) -> str :
411+ """str: The property graph ID."""
412+ return _helpers ._get_sub_prop (
413+ self ._properties , self ._PROPERTY_TO_API_FIELD ["property_graph_id" ]
414+ )
415+
416+ @classmethod
417+ def from_string (
418+ cls , property_graph_id : str , default_project : Optional [str ] = None
419+ ) -> "PropertyGraphReference" :
420+ """Construct a property graph reference from string.
421+
422+ Args:
423+ property_graph_id (str):
424+ A property graph ID in standard SQL format.
425+ default_project (Optional[str]):
426+ The project ID to use when ``property_graph_id`` does not
427+ include a project ID.
428+
429+ Returns:
430+ PropertyGraphReference: Property graph reference parsed from ``property_graph_id``.
431+ """
432+ from google .cloud .bigquery .dataset import DatasetReference
433+
434+ (
435+ output_project_id ,
436+ output_dataset_id ,
437+ output_property_graph_id ,
438+ ) = _helpers ._parse_3_part_id (
439+ property_graph_id ,
440+ default_project = default_project ,
441+ property_name = "property_graph_id" ,
442+ )
443+
444+ return cls (
445+ DatasetReference (output_project_id , output_dataset_id ),
446+ output_property_graph_id ,
447+ )
448+
449+ @classmethod
450+ def from_api_repr (cls , resource : dict ) -> "PropertyGraphReference" :
451+ """Factory: construct a property graph reference given its API representation."""
452+ from google .cloud .bigquery .dataset import DatasetReference
453+
454+ project = resource ["projectId" ]
455+ dataset_id = resource ["datasetId" ]
456+ property_graph_id = resource ["propertyGraphId" ]
457+
458+ return cls (DatasetReference (project , dataset_id ), property_graph_id )
459+
460+ def to_api_repr (self ) -> dict :
461+ """Construct the API resource representation of this property graph reference."""
462+ return copy .deepcopy (self ._properties )
463+
464+ def __str__ (self ):
465+ return f"{ self .project } .{ self .dataset_id } .{ self .property_graph_id } "
466+
467+ def __repr__ (self ):
468+ from google .cloud .bigquery .dataset import DatasetReference
469+
470+ dataset_ref = DatasetReference (self .project , self .dataset_id )
471+ return f"PropertyGraphReference({ dataset_ref !r} , '{ self .property_graph_id } ')"
472+
473+ def __eq__ (self , other ):
474+ if isinstance (other , PropertyGraphReference ):
475+ return (
476+ self .project == other .project
477+ and self .dataset_id == other .dataset_id
478+ and self .property_graph_id == other .property_graph_id
479+ )
480+ else :
481+ return NotImplemented
482+
483+ def __hash__ (self ):
484+ return hash ((self .project , self .dataset_id , self .property_graph_id ))
485+
486+
362487class Table (_TableBase ):
363488 """Tables represent a set of rows whose values correspond to a schema.
364489
@@ -452,9 +577,9 @@ def biglake_configuration(self, value):
452577 api_repr = value
453578 if value is not None :
454579 api_repr = value .to_api_repr ()
455- self ._properties [
456- self . _PROPERTY_TO_API_FIELD [ "biglake_configuration" ]
457- ] = api_repr
580+ self ._properties [self . _PROPERTY_TO_API_FIELD [ "biglake_configuration" ]] = (
581+ api_repr
582+ )
458583
459584 @property
460585 def require_partition_filter (self ):
@@ -468,9 +593,9 @@ def require_partition_filter(self):
468593
469594 @require_partition_filter .setter
470595 def require_partition_filter (self , value ):
471- self ._properties [
472- self . _PROPERTY_TO_API_FIELD [ "require_partition_filter" ]
473- ] = value
596+ self ._properties [self . _PROPERTY_TO_API_FIELD [ "require_partition_filter" ]] = (
597+ value
598+ )
474599
475600 @property
476601 def schema (self ):
@@ -568,9 +693,9 @@ def encryption_configuration(self, value):
568693 api_repr = value
569694 if value is not None :
570695 api_repr = value .to_api_repr ()
571- self ._properties [
572- self . _PROPERTY_TO_API_FIELD [ "encryption_configuration" ]
573- ] = api_repr
696+ self ._properties [self . _PROPERTY_TO_API_FIELD [ "encryption_configuration" ]] = (
697+ api_repr
698+ )
574699
575700 @property
576701 def created (self ):
@@ -845,9 +970,9 @@ def expires(self, value):
845970 if not isinstance (value , datetime .datetime ) and value is not None :
846971 raise ValueError ("Pass a datetime, or None" )
847972 value_ms = google .cloud ._helpers ._millis_from_datetime (value )
848- self ._properties [
849- self . _PROPERTY_TO_API_FIELD [ "expires" ]
850- ] = _helpers . _str_or_none ( value_ms )
973+ self ._properties [self . _PROPERTY_TO_API_FIELD [ "expires" ]] = (
974+ _helpers . _str_or_none ( value_ms )
975+ )
851976
852977 @property
853978 def friendly_name (self ):
@@ -1043,9 +1168,9 @@ def external_data_configuration(self, value):
10431168 api_repr = value
10441169 if value is not None :
10451170 api_repr = value .to_api_repr ()
1046- self ._properties [
1047- self . _PROPERTY_TO_API_FIELD [ "external_data_configuration" ]
1048- ] = api_repr
1171+ self ._properties [self . _PROPERTY_TO_API_FIELD [ "external_data_configuration" ]] = (
1172+ api_repr
1173+ )
10491174
10501175 @property
10511176 def snapshot_definition (self ) -> Optional ["SnapshotDefinition" ]:
0 commit comments