mchades commented on code in PR #10998:
URL: https://github.com/apache/gravitino/pull/10998#discussion_r3245645031


##########
catalogs/hive-metastore-common/src/test/java/org/apache/gravitino/hive/converter/TestHiveTableConverter.java:
##########
@@ -154,4 +163,72 @@ public void testGetColumnsWithEmptyPartitionKeys() {
     assertEquals("id", columns[0].name());
     assertEquals("name", columns[1].name());
   }
+
+  @Test
+  public void testToHiveTablePreservesVirtualViewColumnsInStorageDescriptor() {
+    Column[] columns = {
+      Column.of("id", Types.IntegerType.get(), "ID column"),
+      Column.of("name", Types.StringType.get(), "Name column")
+    };
+    HiveTable hiveTable =
+        HiveTable.builder()
+            .withName("v_orders")
+            .withDatabaseName("db")
+            .withColumns(columns)
+            .withProperties(
+                new HashMap<>(java.util.Map.of(TABLE_TYPE, 
TableType.VIRTUAL_VIEW.name())))
+            .withAuditInfo(
+                
AuditInfo.builder().withCreator("tester").withCreateTime(Instant.now()).build())
+            .withViewOriginalText("SELECT id, name FROM t")
+            .build();

Review Comment:
   Addressed. Replaced fully-qualified java.util.Map.of usage with imported 
Map.of for consistency with project style.



##########
catalogs/hive-metastore-common/src/test/java/org/apache/gravitino/hive/converter/TestHiveTableConverter.java:
##########
@@ -154,4 +163,72 @@ public void testGetColumnsWithEmptyPartitionKeys() {
     assertEquals("id", columns[0].name());
     assertEquals("name", columns[1].name());
   }
+
+  @Test
+  public void testToHiveTablePreservesVirtualViewColumnsInStorageDescriptor() {
+    Column[] columns = {
+      Column.of("id", Types.IntegerType.get(), "ID column"),
+      Column.of("name", Types.StringType.get(), "Name column")
+    };
+    HiveTable hiveTable =
+        HiveTable.builder()
+            .withName("v_orders")
+            .withDatabaseName("db")
+            .withColumns(columns)
+            .withProperties(
+                new HashMap<>(java.util.Map.of(TABLE_TYPE, 
TableType.VIRTUAL_VIEW.name())))
+            .withAuditInfo(
+                
AuditInfo.builder().withCreator("tester").withCreateTime(Instant.now()).build())
+            .withViewOriginalText("SELECT id, name FROM t")
+            .build();
+
+    Table table = HiveTableConverter.toHiveTable(hiveTable);
+
+    assertNotNull(table.getSd());
+    assertEquals(2, table.getSd().getColsSize());
+    assertEquals("id", table.getSd().getCols().get(0).getName());
+    assertEquals("name", table.getSd().getCols().get(1).getName());
+    assertEquals("SELECT id, name FROM t", table.getViewOriginalText());
+    assertEquals("SELECT id, name FROM t", table.getViewExpandedText());
+  }
+
+  @Test
+  public void testToHiveTableMirrorsOriginalTextToExpandedText() {
+    Column[] columns = {Column.of("id", Types.IntegerType.get(), "ID column")};
+    HiveTable hiveTable =
+        HiveTable.builder()
+            .withName("v_orders")
+            .withDatabaseName("db")
+            .withColumns(columns)
+            .withProperties(
+                new HashMap<>(java.util.Map.of(TABLE_TYPE, 
TableType.VIRTUAL_VIEW.name())))
+            .withAuditInfo(
+                
AuditInfo.builder().withCreator("tester").withCreateTime(Instant.now()).build())
+            .withViewOriginalText("SELECT `db`.`t`.`id` FROM `db`.`t`")
+            .build();

Review Comment:
   Addressed. Replaced fully-qualified java.util.Map.of usage with imported 
Map.of for consistency with project style.



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

Reply via email to