Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Arctic-1266][AMS]: Use ArcticSparkSessionCatalog for terminal #1264

Merged
merged 3 commits into from
Apr 3, 2023

Conversation

li36909
Copy link
Contributor

@li36909 li36909 commented Mar 22, 2023

Why are the changes needed?

Fix #1266
Support terminal access hive table when switch to a catalog with HMS metastore 。

Brief change log

  • Use ArcticSparkSessionCatalog for terminal
  • Add a config properties to support access hive in terminal.

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before making a pull request

Documentation

  • Does this pull request introduces a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@zhoujinsong
Copy link
Contributor

@li36909 Hi, thanks a lot for your PR!
Is there an issue associated with PR?
As this is your first PR for Arctic, I recommend you check out the Community Guide first:
#1216

@codecov
Copy link

codecov bot commented Mar 23, 2023

Codecov Report

Patch coverage: 54.05% and project coverage change: -1.26 ⚠️

Comparison is base (37b407b) 29.33% compared to head (55eb3fb) 28.07%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1264      +/-   ##
============================================
- Coverage     29.33%   28.07%   -1.26%     
+ Complexity     5390     4876     -514     
============================================
  Files           695      652      -43     
  Lines         70818    67137    -3681     
  Branches       8170     7822     -348     
============================================
- Hits          20771    18851    -1920     
+ Misses        48041    46402    -1639     
+ Partials       2006     1884     -122     
Flag Coverage Δ
core 28.07% <54.05%> (+0.04%) ⬆️
trino ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ctic/ams/server/terminal/kyuubi/KyuubiSession.java 0.00% <0.00%> (ø)
.../terminal/kyuubi/KyuubiTerminalSessionFactory.java 0.00% <0.00%> (ø)
...ms/server/terminal/local/LocalTerminalSession.java 39.28% <0.00%> (-4.72%) ⬇️
...e/arctic/ams/server/terminal/SparkContextUtil.java 48.14% <50.00%> (-4.24%) ⬇️
...se/arctic/ams/server/terminal/TerminalSession.java 50.00% <66.66%> (+50.00%) ⬆️
...se/arctic/ams/server/terminal/TerminalManager.java 60.63% <100.00%> (+2.57%) ⬆️
...ic/ams/server/terminal/TerminalSessionFactory.java 73.17% <100.00%> (+2.90%) ⬆️
...ams/server/terminal/local/LocalSessionFactory.java 80.76% <100.00%> (ø)

... and 47 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@baiyangtx
Copy link
Contributor

The terminal module is designed to support different backend, we provider 2 default backend, Kyuubi and LocalSpark, so we can't assume that the backend implement of terminal is Spark.

I suggest to add addtion properties about catalog type passed to TerminalSessionFactory, and replace ArcticSparkCatalog to ArcticSparkSessionCatalog in each TerminalSessionFactory implement class.

@li36909
Copy link
Contributor Author

li36909 commented Mar 23, 2023

The terminal module is designed to support different backend, we provider 2 default backend, Kyuubi and LocalSpark, so we can't assume that the backend implement of terminal is Spark.

I suggest to add addtion properties about catalog type passed to TerminalSessionFactory, and replace ArcticSparkCatalog to ArcticSparkSessionCatalog in each TerminalSessionFactory implement class.

thanks, this change is universal for both spark backend and kyuubi, and if we will use another engine (eg trino) as terminal backend, maybe we can do this at a new pr.
and I will add a new property for terminal, thanks for you check

@baiyangtx baiyangtx changed the title use ArcticSparkSessionCatalog for terminal [Arctic-1266][AMS]: Use ArcticSparkSessionCatalog for terminal Mar 30, 2023
@baiyangtx
Copy link
Contributor

I suggest to solve this issue in this way.

  1. add a property to terminal configs to force use ArcticSparkSessionCatalog for hive.
ams.terminal.backend=local
ams.terminal.local.using-session-catalog-for-hive=true

or
ams.terminal.backend=kyuubi
ams.terminal.kyuubi.using-session-catalog-for-hive=true
  1. the TerminalManager already passed the catalog.type to TerminalSessionFactory. so we can replace the ArcticSparkCatalog in the implement class.

Both KyuubiTerminalSessionFactory and LocalTerminalSessionFactory are using SparkContextUtil.getSparkConf to generate the spark configs. Replace the catalog name and implement class here.

public static Map<String, String> getSparkConf(Configuration sessionConfig, bool usingSessionCatalogForHive) {
    //.....
   if("iceberg".equal(connector)){
   } else if (sessionConfig.get('type).equal("hive) && usingSessionCatalogForHive) {
       sparkConf.put("spark.sql.catalog." + catalog, ArcticSparkSessionCatalog.class.getName());
        sparkConf.put("spark.sql.catalog." + catalog + ".url", catalogUrlBase + catalog);
   } else {
      //....
  }

}
  1. in TerminalSession, ignore use {catalog} if current catalog is spark_catalog

@github-actions github-actions bot added module:ams-server Ams server module module:ams-dashboard Ams dashboard module labels Mar 31, 2023
@li36909
Copy link
Contributor Author

li36909 commented Apr 3, 2023

I suggest to solve this issue in this way.

  1. add a property to terminal configs to force use ArcticSparkSessionCatalog for hive.
ams.terminal.backend=local
ams.terminal.local.using-session-catalog-for-hive=true

or
ams.terminal.backend=kyuubi
ams.terminal.kyuubi.using-session-catalog-for-hive=true
  1. the TerminalManager already passed the catalog.type to TerminalSessionFactory. so we can replace the ArcticSparkCatalog in the implement class.

Both KyuubiTerminalSessionFactory and LocalTerminalSessionFactory are using SparkContextUtil.getSparkConf to generate the spark configs. Replace the catalog name and implement class here.

public static Map<String, String> getSparkConf(Configuration sessionConfig, bool usingSessionCatalogForHive) {
    //.....
   if("iceberg".equal(connector)){
   } else if (sessionConfig.get('type).equal("hive) && usingSessionCatalogForHive) {
       sparkConf.put("spark.sql.catalog." + catalog, ArcticSparkSessionCatalog.class.getName());
        sparkConf.put("spark.sql.catalog." + catalog + ".url", catalogUrlBase + catalog);
   } else {
      //....
  }

}
  1. in TerminalSession, ignore use {catalog} if current catalog is spark_catalog

thanks, I have fix it as this suggestion

@baiyangtx
Copy link
Contributor

Tks for your PR, the code is fine, could please add some tests? or add a local test screenshot in this PR's comment?

@li36909
Copy link
Contributor Author

li36909 commented Apr 3, 2023

Tks for your PR, the code is fine, could please add some tests? or add a local test screenshot in this PR's comment?

thanks, here is my test screenshot:

  1. create hive type catalog and arctic catalog

image

2. using hive_catalog to access both origin hive table and mix_hive table

image

image

image

image

image

3. using arctic catalog to access origin hive table, it should fail

image

Copy link
Contributor

@baiyangtx baiyangtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@baiyangtx
Copy link
Contributor

This PR has add a new AMS config property, so could you please update the docs?

@github-actions github-actions bot added the type:docs Improvements or additions to documentation label Apr 3, 2023
@li36909
Copy link
Contributor Author

li36909 commented Apr 3, 2023

This PR has add a new AMS config property, so could you please update the docs?

Added!

@baiyangtx baiyangtx merged commit ac2be3a into apache:master Apr 3, 2023
zhoujinsong pushed a commit that referenced this pull request May 31, 2023
…ve catalog (#1264)

* Support terminal access hive table when switch to a catalog with HMS metastore

* add document for arctic.ams.terminal.local.using-session-catalog-for-hive

---------

Co-authored-by: geoli <geoli@tencent.com>
Co-authored-by: baiyangtx <xiangnebula@163.com>
ShawHee pushed a commit to ShawHee/arctic that referenced this pull request Dec 29, 2023
…ve catalog (apache#1264)

* Support terminal access hive table when switch to a catalog with HMS metastore

* add document for arctic.ams.terminal.local.using-session-catalog-for-hive

---------

Co-authored-by: geoli <geoli@tencent.com>
Co-authored-by: baiyangtx <xiangnebula@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:ams-dashboard Ams dashboard module module:ams-server Ams server module type:docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: Support terminal access hive table when switch to a catalog with HMS metastore .
3 participants