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

[Enhancement] Unified Catalog support Paimon #47398

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

mxdzs0612
Copy link
Contributor

@mxdzs0612 mxdzs0612 commented Jun 24, 2024

Why I'm doing:

Make unified catalog support paimon data sources.

example:

CREATE EXTERNAL CATALOG unified
PROPERTIES
(
    "type" = "unified",
    "unified.metastore.type" = "hive",
    "hive.metastore.uris" = "thrift://localhost:9083",
    "paimon.catalog.warehouse" = "hdfs://127.0.0.1:9000/paimon",
);

What I'm doing:

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

}
return properties;
}

@Override
public List<String> getPartitionColumnNames() {
return partColumnNames;
Copy link

Choose a reason for hiding this comment

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

The most risky bug in this code is:
The getProperties() method may return a mutable reference to the internal properties map, potentially leading to unintended modifications from outside the class.

You can modify the code like this:

@Override
public Map<String, String> getProperties() {
    if (properties == null) {
        this.properties = new HashMap<>();
    }
    return new HashMap<>(properties); // Return a defensive copy of the properties map
}

@mxdzs0612 mxdzs0612 changed the title [Enhancement] Unified Catalog support Paimon table [Enhancement] Unified Catalog support Paimon Jun 24, 2024
@mxdzs0612 mxdzs0612 force-pushed the paimon-unified branch 4 times, most recently from 96da9ff to 0348d6b Compare June 27, 2024 08:28
DELTALAKE, new DeltaLakeConnector(derivedContext),
KUDU, new KuduConnector(derivedContext)
);
boolean shouldCreatePaimonConnector = null != context.getProperties().get(PAIMON_CATALOG_WAREHOUSE);
Copy link
Contributor

Choose a reason for hiding this comment

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

why you check this config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Paimon has multiple checks in its SDK. In the real usage of our customers, it may come to many validation problems when getting metadata in unified catalog even if there is no Paimon table in the catalog. So I add a judgement to filter out Paimon if its warehouse configure does not exist.

Copy link
Contributor

Choose a reason for hiding this comment

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

if this is necessary, we can move this line to a place just before line 77.

Copy link
Contributor

Choose a reason for hiding this comment

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

and contains would be better.

Copy link
Contributor

@letian-jiang letian-jiang left a comment

Choose a reason for hiding this comment

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

left some comments, overall LGTM.

DELTALAKE, new DeltaLakeConnector(derivedContext),
KUDU, new KuduConnector(derivedContext)
);
boolean shouldCreatePaimonConnector = null != context.getProperties().get(PAIMON_CATALOG_WAREHOUSE);
Copy link
Contributor

Choose a reason for hiding this comment

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

if this is necessary, we can move this line to a place just before line 77.

DELTALAKE, new DeltaLakeConnector(derivedContext),
KUDU, new KuduConnector(derivedContext)
);
boolean shouldCreatePaimonConnector = null != context.getProperties().get(PAIMON_CATALOG_WAREHOUSE);
Copy link
Contributor

Choose a reason for hiding this comment

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

and contains would be better.

Copy link

sonarcloud bot commented Jul 1, 2024

.put(HUDI, new HudiConnector(derivedContext))
.put(DELTALAKE, new DeltaLakeConnector(derivedContext))
.put(KUDU, new KuduConnector(derivedContext));
boolean containsPaimon = null != context.getProperties().get(PAIMON_CATALOG_WAREHOUSE);
Copy link
Contributor

@stephen-shelby stephen-shelby Jul 2, 2024

Choose a reason for hiding this comment

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

could you move this check to CatalogAnalyzer ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems hard cause it's for unified catalog only. Any ideas?

@stephen-shelby
Copy link
Contributor

please rebase main

Signed-off-by: Jiao Mingye <[email protected]>
Signed-off-by: Jiao Mingye <[email protected]>
Copy link

sonarcloud bot commented Aug 3, 2024

Copy link

github-actions bot commented Aug 3, 2024

[FE Incremental Coverage Report]

pass : 17 / 20 (85.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/connector/unified/UnifiedMetadata.java 1 2 50.00% [103]
🔵 com/starrocks/catalog/PaimonTable.java 3 5 60.00% [47, 48]
🔵 com/starrocks/connector/paimon/PaimonConnector.java 2 2 100.00% []
🔵 com/starrocks/connector/unified/UnifiedConnector.java 11 11 100.00% []

Copy link

github-actions bot commented Aug 3, 2024

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@gengjun-git gengjun-git merged commit 2e50513 into StarRocks:main Nov 8, 2024
50 checks passed
Copy link

github-actions bot commented Nov 8, 2024

@Mergifyio backport branch-3.3

@github-actions github-actions bot removed the 3.3 label Nov 8, 2024
Copy link

github-actions bot commented Nov 8, 2024

@Mergifyio backport branch-3.2

@github-actions github-actions bot removed the 3.2 label Nov 8, 2024
Copy link
Contributor

mergify bot commented Nov 8, 2024

backport branch-3.3

✅ Backports have been created

Copy link
Contributor

mergify bot commented Nov 8, 2024

backport branch-3.2

✅ Backports have been created

@mxdzs0612 mxdzs0612 deleted the paimon-unified branch November 8, 2024 09:14
mergify bot pushed a commit that referenced this pull request Nov 8, 2024
## Why I'm doing:
Make unified catalog support paimon data sources.

example:
```sql
CREATE EXTERNAL CATALOG unified
PROPERTIES
(
    "type" = "unified",
    "unified.metastore.type" = "hive",
    "hive.metastore.uris" = "thrift://localhost:9083",
    "paimon.catalog.warehouse" = "hdfs://127.0.0.1:9000/paimon",
);
```

Signed-off-by: Jiao Mingye <[email protected]>
(cherry picked from commit 2e50513)

# Conflicts:
#	fe/fe-core/src/test/java/com/starrocks/connector/unified/UnifiedMetadataTest.java
mergify bot pushed a commit that referenced this pull request Nov 8, 2024
## Why I'm doing:
Make unified catalog support paimon data sources.

example:
```sql
CREATE EXTERNAL CATALOG unified
PROPERTIES
(
    "type" = "unified",
    "unified.metastore.type" = "hive",
    "hive.metastore.uris" = "thrift://localhost:9083",
    "paimon.catalog.warehouse" = "hdfs://127.0.0.1:9000/paimon",
);
```

Signed-off-by: Jiao Mingye <[email protected]>
(cherry picked from commit 2e50513)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/catalog/PaimonTable.java
#	fe/fe-core/src/main/java/com/starrocks/connector/unified/UnifiedConnector.java
#	fe/fe-core/src/main/java/com/starrocks/connector/unified/UnifiedMetadata.java
#	fe/fe-core/src/test/java/com/starrocks/connector/unified/UnifiedConnectorTest.java
#	fe/fe-core/src/test/java/com/starrocks/connector/unified/UnifiedMetadataTest.java
mxdzs0612 added a commit to mxdzs0612/starrocks that referenced this pull request Nov 8, 2024
Make unified catalog support paimon data sources.

example:
```sql
CREATE EXTERNAL CATALOG unified
PROPERTIES
(
    "type" = "unified",
    "unified.metastore.type" = "hive",
    "hive.metastore.uris" = "thrift://localhost:9083",
    "paimon.catalog.warehouse" = "hdfs://127.0.0.1:9000/paimon",
);
```

Signed-off-by: Jiao Mingye <[email protected]>

(cherry picked from commit 2e50513)
mxdzs0612 added a commit to mxdzs0612/starrocks that referenced this pull request Nov 8, 2024
Make unified catalog support paimon data sources.

example:
```sql
CREATE EXTERNAL CATALOG unified
PROPERTIES
(
    "type" = "unified",
    "unified.metastore.type" = "hive",
    "hive.metastore.uris" = "thrift://localhost:9083",
    "paimon.catalog.warehouse" = "hdfs://127.0.0.1:9000/paimon",
);
```

Signed-off-by: Jiao Mingye <[email protected]>

(cherry picked from commit 2e50513)
@wangsimo0
Copy link
Contributor

ignore backport check: 3.3.6

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.

5 participants