Skip to content

Commit

Permalink
[AMORO-2373] resolve the catalog problem when querying base on kyuubi…
Browse files Browse the repository at this point in the history
…+flink (#2395)

(cherry picked from commit a6f1425)
Signed-off-by: zhoujinsong <zhoujinsong0505@163.com>
  • Loading branch information
liuzyou6 authored and zhoujinsong committed Feb 2, 2024
1 parent bb4130d commit 03de5ee
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,26 @@ public Map<String, String> configs() {
@Override
public ResultSet executeStatement(String catalog, String statement) {
if (currentCatalog == null || !currentCatalog.equalsIgnoreCase(catalog)) {
String useCatalog;
if (TerminalSession.canUseSparkSessionCatalog(sessionConf, catalog)) {
logs.add(
String.format(
"current catalog is %s, "
+ "since it's a hive type catalog and can use spark session catalog, "
+ "switch to spark_catalog before execution",
currentCatalog));
execute("use `spark_catalog`");
useCatalog = "spark_catalog";
} else {
logs.add(
String.format(
"current catalog is %s, switch to %s before execution", currentCatalog, catalog));
execute("use `" + catalog + "`");
useCatalog = catalog;
}
try {
connection.setCatalog(useCatalog);
} catch (SQLException e) {
throw new RuntimeException(
String.format("Failed to set catalog %s on the connection", useCatalog), e);
}
this.currentCatalog = catalog;
}
Expand Down

0 comments on commit 03de5ee

Please sign in to comment.