korlov42 commented on code in PR #6191:
URL: https://github.com/apache/ignite-3/pull/6191#discussion_r2191662396


##########
modules/client/src/main/java/org/apache/ignite/internal/client/sql/ClientSql.java:
##########
@@ -295,12 +312,39 @@ public <T> CompletableFuture<AsyncResultSet<T>> 
executeAsync(
         };
 
         PayloadReader<AsyncResultSet<T>> payloadReader = r -> {
-            ClientAsyncResultSet<T> rs = new 
ClientAsyncResultSet<>(r.clientChannel(), marshallers, r.in(), mapper);
+            boolean tryUnpackPaMeta = partitionAwarenessEnabled 
+                    && 
r.clientChannel().protocolContext().isFeatureSupported(SQL_PARTITION_AWARENESS);
+
+            ClientAsyncResultSet<T> rs = new ClientAsyncResultSet<>(
+                    r.clientChannel(), marshallers, r.in(), mapper, 
tryUnpackPaMeta
+            );
 
             ClientPartitionAwarenessMetadata partitionAwarenessMetadata = 
rs.partitionAwarenessMetadata();
 
-            if (partitionAwarenessMetadata != null) {
-                cache.put(new PaCacheKey(statement.defaultSchema(), 
statement.query()), partitionAwarenessMetadata);
+            if (partitionAwarenessEnabled && partitionAwarenessMetadata != 
null) {
+                int tableId = partitionAwarenessMetadata.tableId();
+
+                // The table being created is fake and used only to reuse code 
to derive table's schema and partition assignment.
+                // Yet the name of the table may appear in error messages 
and/or logs, therefore let's put some meaning
+                // in the fake name.
+                QualifiedName tableName = 
QualifiedNameHelper.fromNormalized("DUMMY", String.valueOf(tableId));
+
+                ClientTable table = tableCache.get(tableId, id -> new 
ClientTable(

Review Comment:
   Currently we always request metadata from server, hence recreate metadata 
object on every response. ClientTable on the other hand serves like a cache 
itself for Schema object and partition assignments. If we recreate table after 
every response, PA will never work since assignments most like won't be ready.
   
   I don't like this approach either, but it simple yet good enough to be 
initial implementation.



-- 
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