From 219641e9bab52f9e02bca877fb919f6ffa191f37 Mon Sep 17 00:00:00 2001 From: Heng Qin Date: Wed, 5 Jun 2024 22:06:25 +0800 Subject: [PATCH] check schema --- .../gravitino/catalog/TableOperationDispatcher.java | 9 +++++++-- .../gravitino/catalog/TopicOperationDispatcher.java | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/datastrato/gravitino/catalog/TableOperationDispatcher.java b/core/src/main/java/com/datastrato/gravitino/catalog/TableOperationDispatcher.java index 52650303f33..d6f0a082c1f 100644 --- a/core/src/main/java/com/datastrato/gravitino/catalog/TableOperationDispatcher.java +++ b/core/src/main/java/com/datastrato/gravitino/catalog/TableOperationDispatcher.java @@ -10,6 +10,7 @@ import static com.datastrato.gravitino.rel.expressions.transforms.Transforms.EMPTY_TRANSFORM; import com.datastrato.gravitino.EntityStore; +import com.datastrato.gravitino.GravitinoEnv; import com.datastrato.gravitino.NameIdentifier; import com.datastrato.gravitino.Namespace; import com.datastrato.gravitino.StringIdentifier; @@ -88,8 +89,12 @@ public Table loadTable(NameIdentifier ident) throws NoSuchTableException { return table; } - TreeLockUtils.doWithTreeLock( - NameIdentifier.of(ident.namespace().levels()), LockType.WRITE, () -> importTable(ident)); + if (GravitinoEnv.getInstance() + .schemaDispatcher() + .schemaExists(NameIdentifier.of(ident.namespace().levels()))) { + TreeLockUtils.doWithTreeLock( + NameIdentifier.of(ident.namespace().levels()), LockType.WRITE, () -> importTable(ident)); + } return table; } diff --git a/core/src/main/java/com/datastrato/gravitino/catalog/TopicOperationDispatcher.java b/core/src/main/java/com/datastrato/gravitino/catalog/TopicOperationDispatcher.java index c0a43f73fe0..9afe6dc24e5 100644 --- a/core/src/main/java/com/datastrato/gravitino/catalog/TopicOperationDispatcher.java +++ b/core/src/main/java/com/datastrato/gravitino/catalog/TopicOperationDispatcher.java @@ -9,6 +9,7 @@ import static com.datastrato.gravitino.catalog.PropertiesMetadataHelpers.validatePropertyForCreate; import com.datastrato.gravitino.EntityStore; +import com.datastrato.gravitino.GravitinoEnv; import com.datastrato.gravitino.NameIdentifier; import com.datastrato.gravitino.Namespace; import com.datastrato.gravitino.StringIdentifier; @@ -79,8 +80,12 @@ public Topic loadTopic(NameIdentifier ident) throws NoSuchTopicException { return topic; } - TreeLockUtils.doWithTreeLock( - NameIdentifier.of(ident.namespace().levels()), LockType.WRITE, () -> importTopic(ident)); + if (GravitinoEnv.getInstance() + .schemaDispatcher() + .schemaExists(NameIdentifier.of(ident.namespace().levels()))) { + TreeLockUtils.doWithTreeLock( + NameIdentifier.of(ident.namespace().levels()), LockType.WRITE, () -> importTopic(ident)); + } return topic; }