FrankChen021 commented on code in PR #19698:
URL: https://github.com/apache/druid/pull/19698#discussion_r3622006007


##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java:
##########
@@ -1038,6 +1045,73 @@ public void createAuditTable()
     }
   }
 
+  @Override
+  public void exportTable(
+      final String tableName,
+      final String outputPath
+  )
+  {
+    exportTableWithJdbc(tableName, outputPath);
+  }
+
+  /**
+   * Exports a table to a CSV file using generic JDBC.
+   * Binary columns are hex-encoded and booleans are written as true/false 
strings.
+   * Subclasses may override {@link #exportTable} with a database-specific 
implementation
+   * while this method remains available for testing or fallback.
+   */
+  protected void exportTableWithJdbc(
+      final String tableName,
+      final String outputPath
+  )
+  {
+    retryWithHandle(
+            (HandleCallback<Void>) handle -> {
+              try (Statement stmt = handle.getConnection().createStatement();

Review Comment:
   Confirmed: `retryTransaction` gives PostgreSQL an auto-commit-disabled 
connection, and `getStreamingFetchSize()` is applied before query execution, 
enabling cursor-based fetching. Reviewed 8 of 8 changed files.



##########
services/src/main/java/org/apache/druid/cli/ExportMetadata.java:
##########
@@ -245,12 +245,18 @@ private void exportTable(
     } else {
       pathFormatString = "%s/%s.csv";
     }
+    final String exportTableName = isDerby() ? 
StringUtils.toUpperCase(tableName) : tableName;
     dbConnector.exportTable(
-        StringUtils.toUpperCase(tableName),
+        exportTableName,

Review Comment:
   Thanks; the rewrite now preserves trailing values, but the documented 
PostgreSQL `COPY druid_segments(...)` command still names only the original 
nine columns. Current exports contain 12–14 fields, so `COPY` fails with extra 
data; upgraded source tables can also have added columns in a different 
physical order. Please export segments in an explicit stable column order and 
update the import column lists accordingly. Reviewed 8 of 8 changed files.



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