mchades commented on code in PR #4935:
URL: https://github.com/apache/gravitino/pull/4935#discussion_r1774320926


##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/DefaultCatalogConnectorFactory.java:
##########
@@ -35,25 +36,49 @@
 public class DefaultCatalogConnectorFactory implements CatalogConnectorFactory 
{
   private static final Logger LOG = 
LoggerFactory.getLogger(DefaultCatalogConnectorFactory.class);
 
+  private static final String HIVE_CONNECTOR_PROVIDER_NAME = "hive";
+  private static final String ICEBERG_CONNECTOR_PROVIDER_NAME = 
"lakehouse-iceberg";
+  private static final String MEMORY_CONNECTOR_PROVIDER_NAME = "memory";
+  private static final String MYSQL_CONNECTOR_PROVIDER_NAME = "jdbc-mysql";
+  private static final String POSTGRESQL_CONNECTOR_PROVIDER_NAME = 
"jdbc-postgresql";
+  private static final String TRINO_CLUSTER_CONNECTOR_PROVIDER_NAME = 
"trino-cluster";
+
   protected final HashMap<String, CatalogConnectorContext.Builder> 
catalogBuilders =
       new HashMap<>();
+  protected final String region;
 
   public DefaultCatalogConnectorFactory(GravitinoConfig config) {
-    catalogBuilders.put("hive", new CatalogConnectorContext.Builder(new 
HiveConnectorAdapter()));
+    this.region = config.getRegion();
+
+    catalogBuilders.put(
+        HIVE_CONNECTOR_PROVIDER_NAME,
+        new CatalogConnectorContext.Builder(new HiveConnectorAdapter()));
+    catalogBuilders.put(
+        MEMORY_CONNECTOR_PROVIDER_NAME,
+        new CatalogConnectorContext.Builder(new MemoryConnectorAdapter()));
     catalogBuilders.put(
-        "memory", new CatalogConnectorContext.Builder(new 
MemoryConnectorAdapter()));
+        ICEBERG_CONNECTOR_PROVIDER_NAME,
+        new CatalogConnectorContext.Builder(new IcebergConnectorAdapter()));
     catalogBuilders.put(
-        "lakehouse-iceberg", new CatalogConnectorContext.Builder(new 
IcebergConnectorAdapter()));
+        MYSQL_CONNECTOR_PROVIDER_NAME,
+        new CatalogConnectorContext.Builder(new MySQLConnectorAdapter()));
     catalogBuilders.put(
-        "jdbc-mysql", new CatalogConnectorContext.Builder(new 
MySQLConnectorAdapter()));
+        POSTGRESQL_CONNECTOR_PROVIDER_NAME,
+        new CatalogConnectorContext.Builder(new PostgreSQLConnectorAdapter()));
     catalogBuilders.put(
-        "jdbc-postgresql", new CatalogConnectorContext.Builder(new 
PostgreSQLConnectorAdapter()));
+        TRINO_CLUSTER_CONNECTOR_PROVIDER_NAME,
+        new CatalogConnectorContext.Builder(new 
TrinoClusterConnectorAdapter()));
     LOG.info("Start the DefaultCatalogConnectorFactory");
   }
 
   public CatalogConnectorContext.Builder createCatalogConnectorContextBuilder(
       GravitinoCatalog catalog) {
     String catalogProvider = catalog.getProvider();
+
+    if (!catalog.isSameRegion(region)) {
+      catalogProvider = "trino-cluster";

Review Comment:
   use `TRINO_CLUSTER_CONNECTOR_PROVIDER_NAME`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to