IMPALA-14408: (addendum) Log Calcite exception in profile

This addendum logs the exception thrown in the runtime profile
under the CalciteFailureReason key.

Testing: test_ranger.py uses this.

Change-Id: Ia18a52c488f9c73d51690997b277fd8e918c645f
Reviewed-on: http://gerrit.cloudera.org:8080/23686
Reviewed-by: Joe McDonnell <joemcdonnell@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
Steve Carlin
2025-11-18 15:59:43 -08:00
parent a6bb0c7c45
commit e67b627858
3 changed files with 15 additions and 11 deletions

View File

@@ -299,6 +299,7 @@ public class Frontend {
private static final String CPU_ASK_BOUNDED = "CpuAskBounded";
private static final String AVG_ADMISSION_SLOTS_PER_EXECUTOR =
"AvgAdmissionSlotsPerExecutor";
private static final String CALCITE_FAILURE_REASON = "CalciteFailureReason";
// info about the planner used. In this code, we will always use the Original planner,
// but other planners may set their own planner values
@@ -2396,6 +2397,7 @@ public class Frontend {
PlanCtx planCtx, EventSequence timeline) throws ImpalaException {
TExecRequest request = null;
CompilerFactory compilerFactory = getCalciteCompilerFactory(planCtx);
String exceptionClass = null;
if (compilerFactory != null) {
try {
request = getTExecRequest(compilerFactory, planCtx, timeline);
@@ -2403,7 +2405,8 @@ public class Frontend {
if (!shouldFallbackToRegularPlanner(planCtx, e)) {
throw e;
}
LOG.info("Calcite planner failed: ", e);
LOG.info("Calcite planner failed: {}", e.getClass());
exceptionClass = e.getClass().toString();
timeline.markEvent("Failing over from Calcite planner");
}
}
@@ -2414,7 +2417,7 @@ public class Frontend {
compilerFactory = new CompilerFactoryImpl();
request = getTExecRequest(compilerFactory, planCtx, timeline);
}
addPlannerToProfile(compilerFactory.getPlannerString());
addPlannerToProfile(compilerFactory.getPlannerString(), exceptionClass);
return request;
}
@@ -2841,9 +2844,12 @@ public class Frontend {
}
}
public static void addPlannerToProfile(String planner) {
public static void addPlannerToProfile(String planner, String exceptionClass) {
TRuntimeProfileNode profile = createTRuntimeProfileNode(PLANNER_PROFILE);
addInfoString(profile, PLANNER_TYPE, planner);
if (exceptionClass != null) {
addInfoString(profile, CALCITE_FAILURE_REASON, exceptionClass);
}
FrontendProfile.getCurrent().addChildrenProfile(profile);
}

View File

@@ -169,7 +169,7 @@ public class ExecRequestCreator implements CompilerStep {
TRuntimeProfileNode calciteProfile =
this.queryCtx.getFrontend().createTRuntimeProfileNode(Frontend.PLANNER_PROFILE);
this.queryCtx.getFrontend().addPlannerToProfile("CalcitePlanner");
this.queryCtx.getFrontend().addPlannerToProfile("CalcitePlanner", null);
result.setProfile(FrontendProfile.getCurrent().emitAsThrift());
result.setProfile_children(FrontendProfile.getCurrent().emitChildrenAsThrift());
if (isExplain) {

View File

@@ -1650,8 +1650,6 @@ class TestRanger(CustomClusterTestSuite):
table_2 = "alltypestiny"
test_select_query_1 = "select id from {0}.{1}".format(database, table_1)
test_select_query_2 = "select id from {0}.{1}".format(database, table_2)
select_error = "UnsupportedFeatureException: Column masking and row filtering " \
"are not yet supported by the Calcite planner."
policy_cnt = 0
try:
@@ -1662,17 +1660,17 @@ class TestRanger(CustomClusterTestSuite):
admin_client.execute("grant select (id) on table {0}.{1} to user {2}"
.format(database, table_1, grantee_user))
result = self.execute_query_expect_failure(non_owner_client, test_select_query_1)
assert select_error in str(result)
result = self.execute_query_expect_success(non_owner_client, test_select_query_1)
assert "UnsupportedFeatureException" in str(result.runtime_profile)
TestRanger._add_row_filtering_policy(
unique_name + str(policy_cnt), grantee_user, database, table_2, "id % 2 = 0")
policy_cnt += 1
admin_client.execute("grant select (id) on table {0}.{1} to user {2}"
.format(database, table_1, grantee_user))
result = self.execute_query_expect_failure(non_owner_client, test_select_query_2)
assert select_error in str(result)
.format(database, table_2, grantee_user))
result = self.execute_query_expect_success(non_owner_client, test_select_query_2)
assert "UnsupportedFeatureException" in str(result.runtime_profile)
finally:
admin_client.execute("revoke select (id) on table {0}.{1} from user {2}"
.format(database, table_1, grantee_user))