@@ -648,7 +648,10 @@ def _get_graph_name(query_text: str):
648648 """
649649 match = re .match (r"\s*GRAPH\s+(\S+)\.(\S+)" , query_text , re .IGNORECASE )
650650 if match :
651- return (match .group (1 ), match .group (2 ))
651+ (dataset_id , graph_id ) = (match .group (1 )), match .group (2 )
652+ if "`" in dataset_id or "`" in graph_id :
653+ return None # Backticks in graph name not support for schema view
654+ return (dataset_id , graph_id )
652655 return None
653656
654657
@@ -668,10 +671,15 @@ def _get_graph_schema(
668671 job_config = bigquery .QueryJobConfig (
669672 query_parameters = [bigquery .ScalarQueryParameter ("graph_id" , "STRING" , graph_id )]
670673 )
671- info_schema_results = bq_client .query (
672- info_schema_query , job_config = job_config
673- ).to_dataframe ()
674-
674+ job_config .use_legacy_sql = False
675+ try :
676+ info_schema_results = bq_client .query (
677+ info_schema_query , job_config = job_config
678+ ).to_dataframe ()
679+ except Exception :
680+ # If the INFORMATION_SCHEMA query fails for some reason, disable only schema
681+ # view, not the entire visualizer.
682+ return None
675683 if info_schema_results .shape == (1 , 1 ):
676684 return graph_server ._convert_schema (info_schema_results .iloc [0 , 0 ])
677685 return None
@@ -733,7 +741,7 @@ def _add_graph_widget(
733741 "<big><b>Error:</b> The query result is too large for graph visualization.</big>"
734742 )
735743 )
736- return
744+ return False
737745
738746 schema = _get_graph_schema (bq_client , query_text , query_job )
739747
@@ -764,6 +772,7 @@ def _add_graph_widget(
764772 '"bigquery.graph_visualization.NodeExpansion"' ,
765773 )
766774 IPython .display .display (IPython .core .display .HTML (html_content ))
775+ return True
767776
768777
769778def _is_valid_json (s : str ):
@@ -870,7 +879,12 @@ def _make_bq_query(
870879 result = result .to_dataframe (** dataframe_kwargs )
871880
872881 if args .graph and _supports_graph_widget (result ):
873- _add_graph_widget (bq_client , result , query , query_job , args )
882+ if _add_graph_widget (bq_client , result , query , query_job , args ):
883+ # Invoke _handle_result() in case the result is saved to a variable,
884+ # but return None to suppress the default table view, which is redundant
885+ # with the table view in the graph visualizer.
886+ _handle_result (result , args )
887+ return None
874888 return _handle_result (result , args )
875889
876890
0 commit comments