Skip to content

Commit 39d67f9

Browse files
committed
v1
1 parent da94af7 commit 39d67f9

File tree

33 files changed

+158
-48
lines changed

33 files changed

+158
-48
lines changed

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

Lines changed: 23 additions & 8 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 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,40 @@ 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, 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);
8189
}
8290

8391
public static CatalogContext create(
84-
Options options, FileIOLoader preferIOLoader, FileIOLoader fallbackIOLoader) {
85-
return new CatalogContext(options, null, preferIOLoader, fallbackIOLoader);
92+
Options options, FileIOLoader fallbackIOLoader, String catalogName) {
93+
return new CatalogContext(options, null, null, fallbackIOLoader, catalogName);
8694
}
8795

8896
public static CatalogContext create(
8997
Options options,
9098
Configuration hadoopConf,
9199
FileIOLoader preferIOLoader,
92-
FileIOLoader fallbackIOLoader) {
93-
return new CatalogContext(options, hadoopConf, preferIOLoader, fallbackIOLoader);
100+
FileIOLoader fallbackIOLoader,
101+
String catalogName) {
102+
return new CatalogContext(
103+
options, hadoopConf, preferIOLoader, fallbackIOLoader, catalogName);
104+
}
105+
106+
@Nullable
107+
public String catalogName() {
108+
return catalogName;
94109
}
95110

96111
public Options options() {

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
@@ -176,7 +176,8 @@ public FileIO fileIO() throws IOException {
176176
options,
177177
catalogContext.hadoopConf(),
178178
catalogContext.preferIO(),
179-
catalogContext.fallbackIO());
179+
catalogContext.fallbackIO(),
180+
catalogContext.catalogName());
180181
try {
181182
fileIO = FileIO.get(path, context);
182183
} catch (IOException e) {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,25 @@ public abstract class AbstractCatalog implements Catalog {
8181
protected final FileIO fileIO;
8282
protected final Map<String, String> tableDefaultOptions;
8383
protected final Options catalogOptions;
84+
@Nullable protected final String name;
8485

8586
protected AbstractCatalog(FileIO fileIO) {
8687
this.fileIO = fileIO;
8788
this.tableDefaultOptions = new HashMap<>();
8889
this.catalogOptions = new Options();
90+
this.name = null;
8991
}
9092

91-
protected AbstractCatalog(FileIO fileIO, Options options) {
93+
protected AbstractCatalog(FileIO fileIO, Options options, @Nullable String name) {
9294
this.fileIO = fileIO;
9395
this.tableDefaultOptions = CatalogUtils.tableDefaultOptions(options.toMap());
9496
this.catalogOptions = options;
97+
this.name = name;
98+
}
99+
100+
@Override
101+
public String name() {
102+
return name;
95103
}
96104

97105
@Override

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
@Public
5252
public interface Catalog extends AutoCloseable {
5353

54+
/**
55+
* Return the name of this catalog.
56+
*
57+
* @return this catalog's name
58+
*/
59+
@Nullable
60+
default String name() {
61+
return null;
62+
}
63+
5464
// ======================= database methods ===============================
5565

5666
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ static Path warehouse(CatalogContext context) {
6363
* If the ClassLoader is not specified, using the context ClassLoader of current thread as
6464
* default.
6565
*/
66-
static Catalog createCatalog(CatalogContext options) {
67-
return createCatalog(options, CatalogFactory.class.getClassLoader());
66+
static Catalog createCatalog(CatalogContext context) {
67+
return createCatalog(context, CatalogFactory.class.getClassLoader());
6868
}
6969

7070
static Catalog createCatalog(CatalogContext context, ClassLoader classLoader) {

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
@@ -237,6 +237,7 @@ public static Table loadTable(
237237

238238
CatalogEnvironment catalogEnv =
239239
new CatalogEnvironment(
240+
catalog.name(),
240241
tableIdentifier,
241242
metadata.uuid(),
242243
catalog.catalogLoader(),

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public Catalog wrapped() {
5151
return wrapped;
5252
}
5353

54+
@Override
55+
public String name() {
56+
return wrapped.name();
57+
}
58+
5459
@Override
5560
public boolean caseSensitive() {
5661
return wrapped.caseSensitive();

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ public FileSystemCatalog(FileIO fileIO, Path warehouse) {
5050
}
5151

5252
public FileSystemCatalog(FileIO fileIO, Path warehouse, Options options) {
53-
super(fileIO, options);
53+
this(fileIO, warehouse, options, null);
54+
}
55+
56+
public FileSystemCatalog(FileIO fileIO, Path warehouse, Options options, String name) {
57+
super(fileIO, options, name);
5458
this.warehouse = warehouse;
5559
}
5660

@@ -198,7 +202,7 @@ public String warehouse() {
198202

199203
@Override
200204
public CatalogLoader catalogLoader() {
201-
return new FileSystemCatalogLoader(fileIO, warehouse, catalogOptions);
205+
return new FileSystemCatalogLoader(fileIO, warehouse, catalogOptions, name);
202206
}
203207

204208
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public Catalog create(FileIO fileIO, Path warehouse, CatalogContext context) {
4141
"Only managed table is supported in File system catalog.");
4242
}
4343

44-
return new FileSystemCatalog(fileIO, warehouse, context.options());
44+
return new FileSystemCatalog(fileIO, warehouse, context.options(), context.catalogName());
4545
}
4646
}

0 commit comments

Comments
 (0)