Skip to content

Commit 473e9e5

Browse files
committed
v1
1 parent 974b725 commit 473e9e5

25 files changed

Lines changed: 124 additions & 33 deletions

File tree

paimon-api/src/main/java/org/apache/paimon/catalog/Identifier.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,18 @@ public static Identifier fromString(String fullName) {
204204
checkArgument(
205205
!StringUtils.isNullOrWhitespaceOnly(fullName), "fullName cannot be null or empty");
206206

207-
String[] paths = fullName.split("\\.", 2);
207+
String[] paths = fullName.split("\\.");
208208

209-
if (paths.length != 2) {
209+
if (paths.length == 3) {
210+
// catalog.database.object, ignore the catalog part
211+
return new Identifier(paths[1], paths[2]);
212+
} else if (paths.length == 2) {
213+
return new Identifier(paths[0], paths[1]);
214+
} else {
210215
throw new IllegalArgumentException(
211216
String.format(
212217
"Cannot get splits from '%s' to get database and object", fullName));
213218
}
214-
215-
return new Identifier(paths[0], paths[1]);
216219
}
217220

218221
@Override

paimon-common/src/main/java/org/apache/paimon/catalog/CatalogContext.java

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,21 @@ public class CatalogContext implements Serializable {
4848
private final SerializableConfiguration hadoopConf;
4949
@Nullable private final FileIOLoader preferIOLoader;
5050
@Nullable private final FileIOLoader fallbackIOLoader;
51+
@Nullable private final String catalogName;
5152

5253
private CatalogContext(
5354
Options options,
5455
@Nullable Configuration hadoopConf,
5556
@Nullable FileIOLoader preferIOLoader,
56-
@Nullable FileIOLoader fallbackIOLoader) {
57+
@Nullable FileIOLoader fallbackIOLoader,
58+
@Nullable String catalogName) {
5759
this.options = checkNotNull(options);
5860
this.hadoopConf =
5961
new SerializableConfiguration(
6062
hadoopConf == null ? getHadoopConfiguration(options) : hadoopConf);
6163
this.preferIOLoader = preferIOLoader;
6264
this.fallbackIOLoader = fallbackIOLoader;
65+
this.catalogName = catalogName;
6366
}
6467

6568
public static CatalogContext create(Path warehouse) {
@@ -69,28 +72,48 @@ public static CatalogContext create(Path warehouse) {
6972
}
7073

7174
public static CatalogContext create(Options options) {
72-
return new CatalogContext(options, null, null, null);
75+
return new CatalogContext(options, null, null, null, null);
7376
}
7477

7578
public static CatalogContext create(Options options, Configuration hadoopConf) {
76-
return new CatalogContext(options, hadoopConf, null, null);
79+
return new CatalogContext(options, hadoopConf, null, null, null);
80+
}
81+
82+
public static CatalogContext create(
83+
Options options, Configuration hadoopConf, @Nullable String catalogName) {
84+
return new CatalogContext(options, hadoopConf, null, null, catalogName);
7785
}
7886

7987
public static CatalogContext create(Options options, FileIOLoader fallbackIOLoader) {
80-
return new CatalogContext(options, null, null, fallbackIOLoader);
88+
return new CatalogContext(options, null, null, fallbackIOLoader, null);
89+
}
90+
91+
public static CatalogContext create(
92+
Options options, FileIOLoader fallbackIOLoader, @Nullable String catalogName) {
93+
return new CatalogContext(options, null, null, fallbackIOLoader, catalogName);
8194
}
8295

8396
public static CatalogContext create(
8497
Options options, FileIOLoader preferIOLoader, FileIOLoader fallbackIOLoader) {
85-
return new CatalogContext(options, null, preferIOLoader, fallbackIOLoader);
98+
return new CatalogContext(options, null, preferIOLoader, fallbackIOLoader, null);
99+
}
100+
101+
public static CatalogContext create(
102+
Options options,
103+
FileIOLoader preferIOLoader,
104+
FileIOLoader fallbackIOLoader,
105+
@Nullable String catalogName) {
106+
return new CatalogContext(options, null, preferIOLoader, fallbackIOLoader, catalogName);
86107
}
87108

88109
public static CatalogContext create(
89110
Options options,
90111
Configuration hadoopConf,
91112
FileIOLoader preferIOLoader,
92-
FileIOLoader fallbackIOLoader) {
93-
return new CatalogContext(options, hadoopConf, preferIOLoader, fallbackIOLoader);
113+
FileIOLoader fallbackIOLoader,
114+
@Nullable String catalogName) {
115+
return new CatalogContext(
116+
options, hadoopConf, preferIOLoader, fallbackIOLoader, catalogName);
94117
}
95118

96119
public Options options() {
@@ -111,4 +134,9 @@ public FileIOLoader preferIO() {
111134
public FileIOLoader fallbackIO() {
112135
return fallbackIOLoader;
113136
}
137+
138+
@Nullable
139+
public String catalogName() {
140+
return catalogName;
141+
}
114142
}

paimon-common/src/main/java/org/apache/paimon/fs/ResolvingFileIO.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ public void configure(CatalogContext context) {
6464
options.set(RESOLVING_FILE_IO_ENABLED, false);
6565
this.context =
6666
CatalogContext.create(
67-
options, context.hadoopConf(), context.preferIO(), context.fallbackIO());
67+
options,
68+
context.hadoopConf(),
69+
context.preferIO(),
70+
context.fallbackIO(),
71+
context.catalogName());
6872
}
6973

7074
@Override

paimon-common/src/main/java/org/apache/paimon/rest/RESTTokenFileIO.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ public FileIO fileIO() throws IOException {
181181
options,
182182
catalogContext.hadoopConf(),
183183
catalogContext.preferIO(),
184-
catalogContext.fallbackIO());
184+
catalogContext.fallbackIO(),
185+
catalogContext.catalogName());
185186
try {
186187
fileIO = FileIO.get(path, context);
187188
} catch (IOException e) {

paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ protected AbstractCatalog(FileIO fileIO, CatalogContext context) {
9595
this.context = context;
9696
}
9797

98+
@Nullable
99+
@Override
100+
public String name() {
101+
return context.catalogName();
102+
}
103+
98104
@Override
99105
public Map<String, String> options() {
100106
return context.options().toMap();

paimon-core/src/main/java/org/apache/paimon/catalog/Catalog.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,12 @@ TableQueryAuthResult authTableQuery(Identifier identifier, @Nullable List<String
11661166

11671167
// ==================== Catalog Information ==========================
11681168

1169+
/** The name of this catalog. */
1170+
@Nullable
1171+
default String name() {
1172+
return null;
1173+
}
1174+
11691175
/** Catalog options for re-creating this catalog. */
11701176
Map<String, String> options();
11711177

paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ public static Table loadTable(
292292

293293
CatalogEnvironment catalogEnv =
294294
new CatalogEnvironment(
295+
catalog.name(),
295296
tableIdentifier,
296297
metadata.uuid(),
297298
isRestCatalog && metadata.isExternal() ? null : catalog.catalogLoader(),

paimon-core/src/main/java/org/apache/paimon/catalog/DelegateCatalog.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public Catalog wrapped() {
5353
return wrapped;
5454
}
5555

56+
@Nullable
57+
@Override
58+
public String name() {
59+
return wrapped.name();
60+
}
61+
5662
@Override
5763
public boolean caseSensitive() {
5864
return wrapped.caseSensitive();

paimon-core/src/main/java/org/apache/paimon/partition/actions/HttpReportMarkDoneAction.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ public void open(FileStoreTable fileStoreTable, CoreOptions options) {
6565

6666
this.params = options.httpReportMarkDoneActionParams();
6767
this.url = options.httpReportMarkDoneActionUrl();
68-
this.tableName = fileStoreTable.fullName();
68+
// just for compatibility with the old behavior
69+
String fullName = fileStoreTable.fullName();
70+
String[] parts = fullName.split("\\.");
71+
this.tableName = parts.length == 3 ? parts[1] + "." + parts[2] : fullName;
6972
this.location = fileStoreTable.location().toString();
7073

7174
this.mapper = new ObjectMapper();

paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ public RESTCatalog(CatalogContext context, boolean configRequired) {
113113
api.options(),
114114
context.hadoopConf(),
115115
context.preferIO(),
116-
context.fallbackIO());
116+
context.fallbackIO(),
117+
context.catalogName());
117118
this.dataTokenEnabled = api.options().get(RESTTokenFileIO.DATA_TOKEN_ENABLED);
118119
this.tableDefaultOptions = CatalogUtils.tableDefaultOptions(this.context.options().toMap());
119120
}

0 commit comments

Comments
 (0)