@@ -828,7 +828,8 @@ public ResultSet getProcedures(
828828 (rt ) -> rt .getRoutineId ().getRoutine (),
829829 procedureNamePattern ,
830830 procedureNameRegex ,
831- LOG );
831+ LOG ,
832+ false );
832833 Future <List <Routine >> apiFuture = apiExecutor .submit (apiCallable );
833834 apiFutures .add (apiFuture );
834835 }
@@ -1130,7 +1131,8 @@ List<RoutineId> listMatchingProcedureIdsFromDatasets(
11301131 (rt ) -> rt .getRoutineId ().getRoutine (),
11311132 procedureNamePattern ,
11321133 procedureNameRegex ,
1133- logger );
1134+ logger ,
1135+ false );
11341136 listRoutineFutures .add (listRoutinesExecutor .submit (listCallable ));
11351137 }
11361138 logger .fine (
@@ -1629,7 +1631,8 @@ public ResultSet getTables(
16291631 (tbl ) -> tbl .getTableId ().getTable (),
16301632 tableNamePattern ,
16311633 tableNameRegex ,
1632- LOG );
1634+ LOG ,
1635+ false );
16331636 Future <List <Table >> apiFuture = apiExecutor .submit (apiCallable );
16341637 apiFutures .add (apiFuture );
16351638 }
@@ -1943,7 +1946,8 @@ public ResultSet getColumns(
19431946 (tbl ) -> tbl .getTableId ().getTable (),
19441947 tableNamePattern ,
19451948 tableNameRegex ,
1946- LOG );
1949+ LOG ,
1950+ false );
19471951
19481952 for (Table table : tablesToScan ) {
19491953 if (Thread .currentThread ().isInterrupted ()) {
@@ -3828,7 +3832,8 @@ public ResultSet getFunctions(String catalog, String schemaPattern, String funct
38283832 (rt ) -> rt .getRoutineId ().getRoutine (),
38293833 functionNamePattern ,
38303834 functionNameRegex ,
3831- LOG );
3835+ LOG ,
3836+ false );
38323837 };
38333838 Future <List <Routine >> apiFuture = apiExecutor .submit (apiCallable );
38343839 apiFutures .add (apiFuture );
@@ -4179,7 +4184,8 @@ List<RoutineId> listMatchingFunctionIdsFromDatasets(
41794184 (rt ) -> rt .getRoutineId ().getRoutine (),
41804185 functionNamePattern ,
41814186 functionNameRegex ,
4182- logger );
4187+ logger ,
4188+ false );
41834189 listRoutineFutures .add (listRoutinesExecutor .submit (listCallable ));
41844190 }
41854191 logger .fine (
@@ -4615,7 +4621,8 @@ <T> List<T> findMatchingBigQueryObjects(
46154621 Function <T , String > nameExtractor ,
46164622 String pattern ,
46174623 Pattern regex ,
4618- BigQueryJdbcCustomLogger logger )
4624+ BigQueryJdbcCustomLogger logger ,
4625+ boolean throwOn404 )
46194626 throws InterruptedException {
46204627
46214628 boolean needsList = needsListing (pattern );
@@ -4664,9 +4671,9 @@ <T> List<T> findMatchingBigQueryObjects(
46644671 }
46654672
46664673 } catch (BigQueryException e ) {
4667- boolean isBroadDatasetScan = needsList && "Dataset" .equals (objectTypeName );
4668- if (e .getCode () == 404 && !isBroadDatasetScan ) {
4674+ if (e .getCode () == 404 && !throwOn404 ) {
46694675 logger .info ("%s '%s' not found (API error 404)." , objectTypeName , pattern );
4676+ return Collections .emptyList ();
46704677 } else {
46714678 logger .warning (
46724679 "BigQueryException finding %ss for pattern '%s': %s (Code: %d)" ,
@@ -4982,7 +4989,8 @@ private void signalEndOfData(
49824989 }
49834990
49844991 private List <Dataset > fetchDatasetsForProject (
4985- String project , String schemaPattern , Pattern schemaRegex ) throws SQLException {
4992+ String project , String schemaPattern , Pattern schemaRegex , boolean throwOn404 )
4993+ throws SQLException {
49864994 try {
49874995 List <Dataset > datasets =
49884996 findMatchingBigQueryObjects (
@@ -4992,7 +5000,8 @@ private List<Dataset> fetchDatasetsForProject(
49925000 (ds ) -> ds .getDatasetId ().getDataset (),
49935001 schemaPattern ,
49945002 schemaRegex ,
4995- LOG );
5003+ LOG ,
5004+ throwOn404 );
49965005 return datasets != null ? datasets : Collections .emptyList ();
49975006 } catch (InterruptedException e ) {
49985007 Thread .currentThread ().interrupt ();
@@ -5012,9 +5021,11 @@ private List<Dataset> fetchMatchingDatasets(
50125021 return Collections .emptyList ();
50135022 }
50145023
5024+ boolean isBroadScan = (catalog == null );
5025+
50155026 // Single project path
50165027 if (projects .size () == 1 ) {
5017- return fetchDatasetsForProject (projects .get (0 ), schemaPattern , schemaRegex );
5028+ return fetchDatasetsForProject (projects .get (0 ), schemaPattern , schemaRegex , isBroadScan );
50185029 }
50195030
50205031 // Multi-project path
@@ -5026,7 +5037,8 @@ private List<Dataset> fetchMatchingDatasets(
50265037 for (String project : projects ) {
50275038 Callable <Void > task =
50285039 () -> {
5029- List <Dataset > datasets = fetchDatasetsForProject (project , schemaPattern , schemaRegex );
5040+ List <Dataset > datasets =
5041+ fetchDatasetsForProject (project , schemaPattern , schemaRegex , isBroadScan );
50305042 allDatasets .addAll (datasets );
50315043 return null ;
50325044 };
0 commit comments