Skip to content

Commit

Permalink
JDBC client should catch task failed exception in the incremental mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cfmcgrady committed Apr 14, 2023
1 parent 7b94196 commit 66bb527
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ abstract class SparkOperation(session: Session)
setOperationException(ke)
throw ke
} else if (isTerminalState(state)) {
setOperationException(KyuubiSQLException(errMsg))
warn(s"Ignore exception in terminal state with $statementId: $errMsg")
val ke = KyuubiSQLException(errMsg)
setOperationException(ke)
throw ke
} else {
error(s"Error operating $opType: $errMsg", e)
val ke = KyuubiSQLException(s"Error operating $opType: $errMsg", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.apache.kyuubi.config.{KyuubiConf, KyuubiReservedKeys}
import org.apache.kyuubi.config.KyuubiConf.SESSION_CONF_ADVISOR
import org.apache.kyuubi.engine.ApplicationState
import org.apache.kyuubi.jdbc.KyuubiHiveDriver
import org.apache.kyuubi.jdbc.hive.KyuubiConnection
import org.apache.kyuubi.jdbc.hive.{KyuubiConnection, KyuubiSQLException}
import org.apache.kyuubi.metrics.{MetricsConstants, MetricsSystem}
import org.apache.kyuubi.plugin.SessionConfAdvisor
import org.apache.kyuubi.session.{KyuubiSessionManager, SessionType}
Expand Down Expand Up @@ -281,6 +281,16 @@ class KyuubiOperationPerConnectionSuite extends WithKyuubiServer with HiveJDBCTe
assert(rs.getString(2) === KYUUBI_VERSION)
}
}

test("JDBC client should catch task failed exception in the incremental mode") {
withJdbcStatement() { statement =>
statement.executeQuery(s"set ${KyuubiConf.OPERATION_INCREMENTAL_COLLECT.key}=true;")
val resultSet = statement.executeQuery(
"SELECT raise_error('client should catch this exception');")
val e = intercept[KyuubiSQLException](resultSet.next())
assert(e.getMessage.contains("client should catch this exception"))
}
}
}

class TestSessionConfAdvisor extends SessionConfAdvisor {
Expand Down

0 comments on commit 66bb527

Please sign in to comment.