jerryshao commented on code in PR #6752:
URL: https://github.com/apache/gravitino/pull/6752#discussion_r2019462111


##########
core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/TableColumnBaseSQLProvider.java:
##########
@@ -132,4 +132,37 @@ public String selectColumnPOById(@Param("columnId") Long 
columnId) {
         + " WHERE column_id = #{columnId} AND deleted_at = 0"
         + " ORDER BY table_version DESC LIMIT 1";
   }
+
+  public String listColumnPOsByTableIds(@Param("columnIds") List<Long> 
columnIds) {
+    return "<script>"
+        + " SELECT c.column_id AS columnId, c.column_name AS columnName,"
+        + " c.column_position AS columnPosition, c.metalake_id AS metalakeId, 
c.catalog_id AS catalogId,"
+        + " c.schema_id AS schemaId, c.table_id AS tableId,"
+        + " c.table_version AS tableVersion, c.column_type AS columnType,"
+        + " c.column_comment AS columnComment, c.column_nullable AS nullable,"
+        + " c.column_auto_increment AS autoIncrement,"
+        + " c.column_default_value AS defaultValue, c.column_op_type AS 
columnOpType,"
+        + " c.deleted_at AS deletedAt, c.audit_info AS auditInfo"
+        + " FROM "
+        + TableColumnMapper.COLUMN_TABLE_NAME
+        + " c "
+        + "JOIN ("
+        + "    SELECT column_id, MAX(table_version) AS max_version"
+        + "    FROM "
+        + TableColumnMapper.COLUMN_TABLE_NAME
+        + "    WHERE column_id IN ("
+        + "        <foreach collection='columnIds' item='columnId' 
separator=','>"
+        + "          #{columnId}"
+        + "        </foreach>"
+        + "    ) AND deleted_at = 0 GROUP BY column_id"
+        + ") latest "
+        + "ON c.column_id = latest.column_id AND c.table_version = 
latest.max_version"
+        + " WHERE c.column_id IN ("
+        + "<foreach collection='columnIds' item='columnId' separator=','>"
+        + "#{columnId}"
+        + "</foreach>"
+        + ") "
+        + " AND c.deleted_at = 0"
+        + "</script>";
+  }

Review Comment:
   Can you add a test to cover this?



-- 
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...@gravitino.apache.org

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

Reply via email to