fix external table bug
This commit is contained in:
@ -282,12 +282,23 @@ int ObExternalTableUtils::prepare_single_scan_range(const uint64_t tenant_id,
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ObSEArray<ObExternalFileInfo, 16> file_urls;
|
ObSEArray<ObExternalFileInfo, 16> file_urls;
|
||||||
ObSEArray<ObNewRange *, 4> tmp_ranges;
|
ObSEArray<ObNewRange *, 4> tmp_ranges;
|
||||||
if (OB_FAIL(tmp_ranges.assign(ranges))) {
|
ObSEArray<ObAddr, 16> 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));
|
LOG_WARN("failed to assign array", K(ret));
|
||||||
} else if (OB_FAIL(ObExternalTableFileManager::get_instance().get_external_files(tenant_id,
|
} else if (OB_FAIL(ObExternalTableFileManager::get_instance().get_external_files(tenant_id,
|
||||||
table_id, is_file_on_disk, range_allocator, file_urls,
|
table_id, is_file_on_disk, range_allocator, file_urls,
|
||||||
tmp_ranges.empty() ? NULL : &tmp_ranges))) {
|
tmp_ranges.empty() ? NULL : &tmp_ranges))) {
|
||||||
LOG_WARN("get external table file error", K(ret));
|
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 {
|
} else {
|
||||||
new_range.reset();
|
new_range.reset();
|
||||||
}
|
}
|
||||||
@ -422,8 +433,7 @@ int ObExternalTableUtils::calc_assigned_files_to_sqcs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ObExternalTableUtils::filter_files_in_locations(common::ObIArray<share::ObExternalFileInfo> &files,
|
int ObExternalTableUtils::filter_files_in_locations(common::ObIArray<share::ObExternalFileInfo> &files,
|
||||||
common::ObIArray<common::ObAddr> &locations,
|
common::ObIArray<common::ObAddr> &locations)
|
||||||
common::ObIArray<share::ObExternalFileInfo> &res)
|
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < files.count(); i++) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < files.count(); i++) {
|
||||||
@ -434,8 +444,10 @@ int ObExternalTableUtils::filter_files_in_locations(common::ObIArray<share::ObEx
|
|||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OB_SUCC(ret) && found) {
|
if (OB_SUCC(ret) && !found) {
|
||||||
ret = res.push_back(table_info);
|
std::swap(files.at(i), files.at(files.count() - 1));
|
||||||
|
files.pop_back();
|
||||||
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@ -101,8 +101,7 @@ class ObExternalTableUtils {
|
|||||||
int64_t sqc_count);
|
int64_t sqc_count);
|
||||||
|
|
||||||
static int filter_files_in_locations(common::ObIArray<share::ObExternalFileInfo> &files,
|
static int filter_files_in_locations(common::ObIArray<share::ObExternalFileInfo> &files,
|
||||||
common::ObIArray<common::ObAddr> &locations,
|
common::ObIArray<common::ObAddr> &locations);
|
||||||
common::ObIArray<share::ObExternalFileInfo> &res);
|
|
||||||
private:
|
private:
|
||||||
static bool is_left_edge(const common::ObObj &value);
|
static bool is_left_edge(const common::ObObj &value);
|
||||||
static bool is_right_edge(const common::ObObj &value);
|
static bool is_right_edge(const common::ObObj &value);
|
||||||
|
|||||||
@ -160,18 +160,17 @@ int ObPXServerAddrUtil::get_external_table_loc(
|
|||||||
// ret = OB_NOT_SUPPORTED;
|
// ret = OB_NOT_SUPPORTED;
|
||||||
// LOG_WARN("Has dynamic params in external table or empty range is not supported", K(ret),
|
// 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()));
|
// K(pre_query_range.has_exec_param()), K(pre_query_range.get_column_count()));
|
||||||
ObArray<ObExternalFileInfo> tmp_ext_file_urls;
|
|
||||||
if (OB_FAIL(ObSQLUtils::extract_pre_query_range(
|
if (OB_FAIL(ObSQLUtils::extract_pre_query_range(
|
||||||
pre_query_range, ctx.get_allocator(), ctx, ranges,
|
pre_query_range, ctx.get_allocator(), ctx, ranges,
|
||||||
ObBasicSessionInfo::create_dtc_params(ctx.get_my_session())))) {
|
ObBasicSessionInfo::create_dtc_params(ctx.get_my_session())))) {
|
||||||
LOG_WARN("failed to extract external file fiter", K(ret));
|
LOG_WARN("failed to extract external file fiter", K(ret));
|
||||||
} else if (OB_FAIL(ObExternalTableFileManager::get_instance().get_external_files(
|
} else if (OB_FAIL(ObExternalTableFileManager::get_instance().get_external_files(
|
||||||
tenant_id, ref_table_id, is_external_files_on_disk,
|
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));
|
LOG_WARN("fail to get external files", K(ret));
|
||||||
} else if (OB_FAIL(ObExternalTableUtils::filter_files_in_locations(tmp_ext_file_urls,
|
} else if (is_external_files_on_disk
|
||||||
all_locations,
|
&& OB_FAIL(ObExternalTableUtils::filter_files_in_locations(ext_file_urls,
|
||||||
ext_file_urls))) {
|
all_locations))) {
|
||||||
//For recovered cluster, the file addr may not in the cluster. Then igore it.
|
//For recovered cluster, the file addr may not in the cluster. Then igore it.
|
||||||
LOG_WARN("filter files in location failed", K(ret));
|
LOG_WARN("filter files in location failed", K(ret));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user