diff --git a/src/share/external_table/ob_external_table_utils.cpp b/src/share/external_table/ob_external_table_utils.cpp index eca100947c..7d8e135374 100644 --- a/src/share/external_table/ob_external_table_utils.cpp +++ b/src/share/external_table/ob_external_table_utils.cpp @@ -282,12 +282,23 @@ int ObExternalTableUtils::prepare_single_scan_range(const uint64_t tenant_id, int ret = OB_SUCCESS; ObSEArray file_urls; ObSEArray tmp_ranges; - if (OB_FAIL(tmp_ranges.assign(ranges))) { + ObSEArray all_locations; + if (OB_ISNULL(GCTX.location_service_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (OB_FAIL(tmp_ranges.assign(ranges))) { LOG_WARN("failed to assign array", K(ret)); } else if (OB_FAIL(ObExternalTableFileManager::get_instance().get_external_files(tenant_id, table_id, is_file_on_disk, range_allocator, file_urls, tmp_ranges.empty() ? NULL : &tmp_ranges))) { LOG_WARN("get external table file error", K(ret)); + } else if (OB_FAIL(GCTX.location_service_->external_table_get(tenant_id, table_id, all_locations))) { + LOG_WARN("fail to get external table location", K(ret)); + } else if (is_file_on_disk + && OB_FAIL(ObExternalTableUtils::filter_files_in_locations(file_urls, + all_locations))) { + //For recovered cluster, the file addr may not in the cluster. Then igore it. + LOG_WARN("filter files in location failed", K(ret)); } else { new_range.reset(); } @@ -422,8 +433,7 @@ int ObExternalTableUtils::calc_assigned_files_to_sqcs( } int ObExternalTableUtils::filter_files_in_locations(common::ObIArray &files, - common::ObIArray &locations, - common::ObIArray &res) + common::ObIArray &locations) { int ret = OB_SUCCESS; for (int64_t i = 0; OB_SUCC(ret) && i < files.count(); i++) { @@ -434,8 +444,10 @@ int ObExternalTableUtils::filter_files_in_locations(common::ObIArray &files, - common::ObIArray &locations, - common::ObIArray &res); + common::ObIArray &locations); private: static bool is_left_edge(const common::ObObj &value); static bool is_right_edge(const common::ObObj &value); diff --git a/src/sql/engine/px/ob_px_util.cpp b/src/sql/engine/px/ob_px_util.cpp index 196c0e5861..3ad7e0d09d 100644 --- a/src/sql/engine/px/ob_px_util.cpp +++ b/src/sql/engine/px/ob_px_util.cpp @@ -160,18 +160,17 @@ int ObPXServerAddrUtil::get_external_table_loc( // ret = OB_NOT_SUPPORTED; // LOG_WARN("Has dynamic params in external table or empty range is not supported", K(ret), // K(pre_query_range.has_exec_param()), K(pre_query_range.get_column_count())); - ObArray tmp_ext_file_urls; if (OB_FAIL(ObSQLUtils::extract_pre_query_range( pre_query_range, ctx.get_allocator(), ctx, ranges, ObBasicSessionInfo::create_dtc_params(ctx.get_my_session())))) { LOG_WARN("failed to extract external file fiter", K(ret)); } else if (OB_FAIL(ObExternalTableFileManager::get_instance().get_external_files( tenant_id, ref_table_id, is_external_files_on_disk, - ctx.get_allocator(), tmp_ext_file_urls, ranges.empty() ? NULL : &ranges))) { + ctx.get_allocator(), ext_file_urls, ranges.empty() ? NULL : &ranges))) { LOG_WARN("fail to get external files", K(ret)); - } else if (OB_FAIL(ObExternalTableUtils::filter_files_in_locations(tmp_ext_file_urls, - all_locations, - ext_file_urls))) { + } else if (is_external_files_on_disk + && OB_FAIL(ObExternalTableUtils::filter_files_in_locations(ext_file_urls, + all_locations))) { //For recovered cluster, the file addr may not in the cluster. Then igore it. LOG_WARN("filter files in location failed", K(ret)); }