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

[feat](iceberg)Supports using rest type catalog to read tables in unity catalog #43525

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

wuwenchi
Copy link
Contributor

@wuwenchi wuwenchi commented Nov 8, 2024

What problem does this PR solve?

  1. We now support using the rest type catalog to read tables in the unity catalog (https://github.com/unitycatalog/unitycatalog).
  2. When reading the parquet file on the be side, we find the corresponding column name based on the column id, which naturally supports the column rename function.

example:

CREATE CATALOG `uc3`
PROPERTIES (
"type"  =  "iceberg",
"iceberg.catalog.type"  =  "rest",
"uri"  =  "http://127.0.0.1:8080/api/2.1/unity-catalog/iceberg",
"external_catalog.name" = "unity"  --- catalog name in unity catalog
);

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@@ -259,6 +259,10 @@ std::vector<tparquet::KeyValue> ParquetReader::get_metadata_key_values() {
return _t_metadata->key_value_metadata;
}

const FieldDescriptor ParquetReader::get_file_metadata_schema() {
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: return type 'const std::doris::vectorized::FieldDescriptor' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness [readability-const-return-type]

Suggested change
const FieldDescriptor ParquetReader::get_file_metadata_schema() {
FieldDescriptor ParquetReader::get_file_metadata_schema() {

be/src/vec/exec/format/parquet/vparquet_reader.h:151:

-     const FieldDescriptor get_file_metadata_schema();
+     FieldDescriptor get_file_metadata_schema();

@wuwenchi
Copy link
Contributor Author

wuwenchi commented Nov 8, 2024

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 37.91% (9867/26030)
Line Coverage: 29.09% (82270/282777)
Region Coverage: 28.26% (42368/149947)
Branch Coverage: 24.80% (21452/86500)
Coverage Report: http://coverage.selectdb-in.cc/coverage/0b472c1d54bb438937c943b2672ca3caa904e331_0b472c1d54bb438937c943b2672ca3caa904e331/report/index.html

@wuwenchi
Copy link
Contributor Author

wuwenchi commented Nov 8, 2024

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 37.91% (9868/26030)
Line Coverage: 29.10% (82278/282777)
Region Coverage: 28.25% (42367/149947)
Branch Coverage: 24.80% (21451/86500)
Coverage Report: http://coverage.selectdb-in.cc/coverage/b2105ca203b130292bf414c0203cbd4d5b5bf1bf_b2105ca203b130292bf414c0203cbd4d5b5bf1bf/report/index.html

icebergCatalog = ((HMSExternalCatalog) key.catalog).getIcebergHiveCatalog();
Catalog icebergCatalog = ((HMSExternalCatalog) key.catalog).getIcebergHiveCatalog();
icebergTable = HiveMetaStoreClientHelper.ugiDoAs(((ExternalCatalog) key.catalog).getConfiguration(),
() -> icebergCatalog.loadTable(TableIdentifier.of(key.dbName, key.tableName)));
Copy link
Contributor

Choose a reason for hiding this comment

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

We should unify the interface, both using catalog.loadTable() or using metadataOps.loadTable()

@@ -39,6 +39,7 @@ public abstract class IcebergExternalCatalog extends ExternalCatalog {
public static final String ICEBERG_HADOOP = "hadoop";
public static final String ICEBERG_GLUE = "glue";
public static final String ICEBERG_DLF = "dlf";
public static final String EXTERNAL_SERVER_CATALOG_NAME = "external_server_catalog_name";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static final String EXTERNAL_SERVER_CATALOG_NAME = "external_server_catalog_name";
public static final String EXTERNAL_SERVER_CATALOG_NAME = "external_catalog.name";

_has_schema_change = true;
}
}
Status IcebergParquetReader::_gen_col_name_maps(FieldDescriptor field_desc) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Status IcebergParquetReader::_gen_col_name_maps(FieldDescriptor field_desc) {
Status IcebergParquetReader::_gen_col_name_maps(const FieldDescriptor& field_desc) {

@@ -149,6 +149,7 @@ class ParquetReader : public GenericReader {
const std::unordered_map<std::string, VExprContextSPtr>& missing_columns) override;

std::vector<tparquet::KeyValue> get_metadata_key_values();
Copy link
Contributor

Choose a reason for hiding this comment

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

This method can be removed?

@@ -218,7 +218,7 @@ class IcebergParquetReader final : public IcebergTableReader {
parquet_reader->set_delete_rows(&_iceberg_delete_rows);
}

Status _gen_col_name_maps(std::vector<tparquet::KeyValue> parquet_meta_kv);
Status _gen_col_name_maps(FieldDescriptor field_desc);
Copy link
Contributor

Choose a reason for hiding this comment

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

Need also modify this method in IcebergOrcReader

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The orc format is originally associated according to the id, so there is no need to modify it.

@wuwenchi
Copy link
Contributor Author

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@@ -147,6 +150,14 @@ Status FieldDescriptor::parse_from_thrift(const std::vector<tparquet::SchemaElem
return Status::OK();
}

const doris::Slice FieldDescriptor::get_column_name_from_field_id(int32_t id) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: return type 'const doris::Slice' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness [readability-const-return-type]

Suggested change
const doris::Slice FieldDescriptor::get_column_name_from_field_id(int32_t id) const {
doris::Slice FieldDescriptor::get_column_name_from_field_id(int32_t id) const {

be/src/vec/exec/format/parquet/schema_desc.h:137:

-     const doris::Slice get_column_name_from_field_id(int32_t id) const;
+     doris::Slice get_column_name_from_field_id(int32_t id) const;

// This is for iceberg schema evolution.
std::vector<tparquet::KeyValue> ParquetReader::get_metadata_key_values() {
return _t_metadata->key_value_metadata;
const FieldDescriptor ParquetReader::get_file_metadata_schema() {
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: return type 'const std::doris::vectorized::FieldDescriptor' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness [readability-const-return-type]

Suggested change
const FieldDescriptor ParquetReader::get_file_metadata_schema() {
FieldDescriptor ParquetReader::get_file_metadata_schema() {

be/src/vec/exec/format/parquet/vparquet_reader.h:150:

-     const FieldDescriptor get_file_metadata_schema();
+     FieldDescriptor get_file_metadata_schema();

@wuwenchi
Copy link
Contributor Author

run buildall

@morningman morningman changed the title [bugfix](iceberg)Supports using rest type catalog to read tables in unity catalog [feat](iceberg)Supports using rest type catalog to read tables in unity catalog Nov 12, 2024
@wuwenchi
Copy link
Contributor Author

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants