Vamsi-klu commented on code in PR #19085:
URL: https://github.com/apache/pinot/pull/19085#discussion_r3725702584


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentUploadDownloadRestletResource.java:
##########
@@ -1313,6 +1311,38 @@ private FileUploadType getUploadType(String 
uploadTypeStr) {
     }
   }
 
+  /**
+   * Resolve the raw table name for a segment upload.
+   * <p>
+   * The request {@code tableName} query parameter (also set by admin {@code 
-tableName} and batch
+   * {@code tableSpec.tableName}) is authoritative. Segment metadata {@code 
segment.table.name} is only
+   * used when the request omits the parameter. Callers may therefore build a 
segment for table A and
+   * upload it to table B without rewriting the tar.
+   *
+   * @param requestTableName table name from the upload request (may be 
null/empty or typed)
+   * @param segmentMetadata metadata read from the uploaded segment
+   * @return raw (untyped) table name used for ZK / deep-store routing
+   */
+  @VisibleForTesting
+  static String resolveRawTableNameForUpload(@Nullable String 
requestTableName, SegmentMetadata segmentMetadata) {
+    String metadataTableName = segmentMetadata.getTableName();
+    if (StringUtils.isNotEmpty(requestTableName)) {
+      String rawTableName = 
TableNameBuilder.extractRawTableName(requestTableName);
+      if (StringUtils.isNotEmpty(metadataTableName)) {
+        String metadataRawTableName = 
TableNameBuilder.extractRawTableName(metadataTableName);
+        if (!rawTableName.equals(metadataRawTableName)) {

Review Comment:
   Thanks for the review, that makes sense. The extracted helper reads 
segmentMetadata.getTableName() even when the request param is present (to log a 
mismatch), which adds a new dependency on the metadata table name and works 
against the decoupling goal. I will revert this hunk to the original inline 
logic so the metadata table name is only read in the fallback path when the 
query param is absent, and drop the extra comparison and info log. The PR will 
then keep only the documentation updates on the upload endpoints' tableName 
ApiParam and the UploadSegmentCommand -tableName option, plus test coverage for 
the override behavior, which I will rework so it no longer depends on the 
extracted helper.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to