JAkutenshi commented on code in PR #6200:
URL: https://github.com/apache/ignite-3/pull/6200#discussion_r2204027561


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java:
##########
@@ -162,10 +165,13 @@ public class DdlSqlToCommandConverter {
     /** Zone options set. */
     private final Set<String> knownZoneOptionNames;
 
+    /** Logical topology service for cluster wide storage profiles resolution. 
*/
+    private final LogicalTopologyService logicalTopologyService;

Review Comment:
   The interface was introduced as well as its implementation 
`ClusterWideStorageProfileValidator` where previous validation logic from 
`DdlSqlToCommandConverter` was removed to.



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java:
##########
@@ -723,11 +731,56 @@ private CatalogCommand 
convertCreateZone(IgniteSqlCreateZone createZoneNode, Pla
 
         List<StorageProfileParams> profiles = 
extractProfiles(createZoneNode.storageProfiles());
 
+        checkStorageProfilesArePresentedAmongCluster(profiles);
+
         builder.storageProfilesParams(profiles);
 
         return builder.build();
     }
 
+    private void 
checkStorageProfilesArePresentedAmongCluster(List<StorageProfileParams> 
storageProfiles) {
+        LogicalTopologySnapshot localLogicalTopologySnapshot = 
logicalTopologyService.localLogicalTopology();
+
+        String notPresentedStorageProfileName = 
findStorageProfileNotPresentedInLogicalTopologySnapshot(
+                storageProfiles,
+                localLogicalTopologySnapshot
+        );
+
+        if (notPresentedStorageProfileName != null) {
+            throw new SqlException(STMT_VALIDATION_ERR, "Storage profile [" + 
notPresentedStorageProfileName + "] doesn't exist.");
+        }
+    }
+
+    private static @Nullable String 
findStorageProfileNotPresentedInLogicalTopologySnapshot(
+            List<StorageProfileParams> storageProfiles,
+            LogicalTopologySnapshot snapshot
+    ) {
+        Set<String> topologyWideProfiles = 
extractStorageProfileNamesFromLogicalTopologySnapshot(snapshot);
+
+        for (StorageProfileParams profile : storageProfiles) {
+            String storageProfileName = profile.storageProfile();
+
+            if (!topologyWideProfiles.contains(storageProfileName)) {

Review Comment:
   Now we will collect all of them as set.



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to