abhishekbafna commented on code in PR #15515:
URL: https://github.com/apache/pinot/pull/15515#discussion_r2038951541


##########
pinot-common/src/main/java/org/apache/pinot/common/utils/LogicalTableUtils.java:
##########
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.common.utils;
+
+import java.io.IOException;
+import javax.annotation.Nonnull;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.pinot.spi.data.LogicalTable;
+
+
+/**
+ * Utility class which contains {@link LogicalTable} related operations.
+ */
+public class LogicalTableUtils {
+
+  private LogicalTableUtils() {
+  }
+
+  /**
+   * Fetch {@link LogicalTable} from a {@link ZNRecord}.
+   */
+  public static LogicalTable fromZNRecord(@Nonnull ZNRecord record)
+      throws IOException {
+    String tableJSON = record.getSimpleField("tableJSON");
+    return LogicalTable.fromString(tableJSON);
+  }
+
+  /**
+   * Wrap {@link LogicalTable} into a {@link ZNRecord}.
+   */
+  public static ZNRecord toZNRecord(@Nonnull LogicalTable table) {
+    ZNRecord record = new ZNRecord(table.getTableName());
+    record.setSimpleField("tableJSON", table.toSingleLineJsonString());

Review Comment:
   Schemas uses `schemaJSON` to store the JSON. Tables store the JSON form of 
the TableConfig. 
[Link](https://github.com/apache/pinot/blob/8dab53ae4efd4475cbd23b7b808fb684018a4cb0/pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java#L199)
   
   We can choose the table config approach as I found it more readable.
   
   Table Config:
   <img width="634" alt="Screenshot 2025-04-11 at 12 48 47 PM" 
src="https://github.com/user-attachments/assets/f919e979-e484-495f-8c4b-09fc88420463";
 />
   
   Schema Config:
   <img width="860" alt="Screenshot 2025-04-11 at 12 48 57 PM" 
src="https://github.com/user-attachments/assets/0011839f-6adc-4fb8-94fe-bc19144d67b5";
 />
   



-- 
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: commits-unsubscr...@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to