Skip to content

[feature-wip](iceberg) Step1: Support create Iceberg external table - #7391

Merged
morningman merged 9 commits into
apache:masterfrom
qidaye:iceberg_sp
Jan 27, 2022
Merged

[feature-wip](iceberg) Step1: Support create Iceberg external table#7391
morningman merged 9 commits into
apache:masterfrom
qidaye:iceberg_sp

Conversation

@qidaye

@qidayeqidaye commented Dec 14, 2021

Copy link
Copy Markdown
Contributor

Proposed changes

Close related #7389

Support create Iceberg external table in Doris.

This is the first step to support Iceberg external table.

Create Iceberg external table

This pr describes two ways to create Iceberg external tables. Both ways do not require explicitly specifying column definitions, Doris automatically converts them based on Iceberg's column definitions.

  1. Create an Iceberg external table directly
 CREATE [EXTERNAL] TABLE table_name ENGINE = ICEBERG
[COMMENT "comment"]
PROPERTIES (
"iceberg.database"="iceberg_db_name",
"iceberg.table"="icberg_table_name",
"iceberg.hive.metastore.uris"="thrift://192.168.0.1:9083",
"iceberg.catalog.type"="HIVE_CATALOG"
);
  1. Create an Iceberg database and automatically create all the tables under that db.
CREATEDATABASEdb_name [COMMENT "comment"]
PROPERTIES (
"iceberg.database"="iceberg_db_name",
"iceberg.hive.metastore.uris"="thrift://192.168.0.1:9083",
"iceberg.catalog.type"="HIVE_CATALOG"
);

Show table creation

  1. For individual tables you can view them with help show create table.
mysql> show create table iceberg_db.logs_1;
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| logs_1 | CREATE TABLE `logs_1` (
`level`varchar(-1) NOT NULL COMMENT "null",
`event_time` datetime NOT NULL COMMENT "null",
`message`varchar(-1) NOT NULL COMMENT "null"
) ENGINE=ICEBERG
COMMENT "ICEBERG"
PROPERTIES (
"iceberg.database"="doris",
"iceberg.table"="logs_1",
"iceberg.hive.metastore.uris"="thrift://10.10.10.10:9087",
"iceberg.catalog.type"="HIVE_CATALOG"
) |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  1. For Iceberg database, you can view it with help show table creation.
mysql> show table creation from iceberg_db;
+--------+---------+---------------------+---------------------------------------------------------+
| Table | Status | Create Time | Error Msg |
+--------+---------+---------------------+---------------------------------------------------------+
| logs | fail | 2021-12-1413:50:10 | Cannot convert unknown type to Doris type: list<string> |
| logs_1 | success | 2021-12-1413:50:10 | |
+--------+---------+---------------------+---------------------------------------------------------+2 rows inset (0.00 sec)

This is a new syntax.

Show table creation records in Iceberg database:

Syntax:

 SHOW TABLE CREATION [FROM db] [LIKE mask]

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Code refactor (Modify the code structure, format the code, etc...)
  • Optimization. Including functional usability improvements and performance improvements.
  • Dependency. Such as changes related to third-party components.
  • Other.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have created an issue on (Fix #ISSUE) and described the bug/feature there in detail
  • Compiling and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • If these changes need document changes, I have updated the document
  • Any dependent changes have been merged

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

Comment threadfe/fe-core/src/main/java/org/apache/doris/analysis/CreateDbStmt.java Outdated
Comment threadfe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java Outdated
Comment threadfe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java Outdated
Comment threadfe/fe-core/src/main/java/org/apache/doris/catalog/IcebergDatabase.java Outdated
Comment threadfe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java Outdated
Comment threadfe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java Outdated
@morningmanmorningman self-assigned this Dec 24, 2021
@morningmanmorningman added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 24, 2021
@morningmanmorningman changed the title [Iceberg] Support create Iceberg external table[feature-wip](iceberg) Step1: Support create Iceberg external tableDec 24, 2021
if (db.getDbProperties().getIcebergProperty().isExist()) {
IcebergProperty icebergProperty = db.getDbProperties().getIcebergProperty();
IcebergCatalog icebergCatalog = IcebergCatalogMgr.getCatalog(icebergProperty);
List<TableIdentifier> icebergTables = icebergCatalog.listTables(icebergProperty.getDatabase());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if the listTables throw exception?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not resolved?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added a new DorisIcebergException which is a RuntimeException in IcebergCatalog.listTable.

Comment threadfe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java Outdated
if (db.getDbProperties().getIcebergProperty().isExist()) {
IcebergProperty icebergProperty = db.getDbProperties().getIcebergProperty();
IcebergCatalog icebergCatalog = IcebergCatalogMgr.getCatalog(icebergProperty);
List<TableIdentifier> icebergTables = icebergCatalog.listTables(icebergProperty.getDatabase());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not resolved?

Database db = new Database(id, fullDbName);
db.setClusterName(clusterName);
// check and analyze database properties before create database
db.getDbProperties().putAll(properties);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

merge these 2 methods:

db.getDbProperties().putAll(properties);
db.getDbProperties().checkAndBuildProperties();

to

db.addAndBuildProperties(properties);

@morningmanmorningman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actionsgithub-actionsBot added the approved Indicates a PR has been approved by one committer. label Jan 26, 2022
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@morningman
morningman merged commit 3b8d48f into apache:masterJan 27, 2022
@qidaye
qidaye deleted the iceberg_sp branch January 27, 2022 02:28
caiconghui added a commit that referenced this pull request Jan 29, 2022
…t instead of admin (#7914)
* [improvement](show) Support that user can use show data skew statement instead of admin
This PR mainly do two things:
1. Support that user can use show data skew statement instead of admin
2. Fix fe ut failed caused by pr [improvement](rewrite) Make RewriteDateLiteralRule to be compatible with mysql #7876 and pr [feature-wip](iceberg) Step1: Support create Iceberg external table #7391
Co-authored-by: caiconghui1 <caiconghui1@jd.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.area/icebergkind/featureCategorizes issue or PR as related to a new feature.reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@qidaye@morningman