This is an automated email from the ASF dual-hosted git repository.
abstractdog pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 1a574783afe HIVE-28078: TestTxnDbUtil should generate csv files when
we query the metastore database (#5085) (Zsolt Miskolczi reviewed by Laszlo
Bodor)
1a574783afe is described below
commit 1a574783afee13e33ecf3ed6fc60bdc94fe47bb1
Author: InvisibleProgrammer <[email protected]>
AuthorDate: Thu Feb 22 17:32:59 2024 +0100
HIVE-28078: TestTxnDbUtil should generate csv files when we query the
metastore database (#5085) (Zsolt Miskolczi reviewed by Laszlo Bodor)
---
.../hadoop/hive/metastore/utils/TestTxnDbUtil.java | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestTxnDbUtil.java
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestTxnDbUtil.java
index 6d7fe31b719..d369e3d65e6 100644
---
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestTxnDbUtil.java
+++
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestTxnDbUtil.java
@@ -338,10 +338,24 @@ public final class TestTxnDbUtil {
closeResources(conn, stmt, rs);
}
}
+
public static String queryToString(Configuration conf, String query) throws
Exception {
return queryToString(conf, query, true);
}
- public static String queryToString(Configuration conf, String query, boolean
includeHeader)
+
+ public static String queryToString(Configuration conf, String query, boolean
includeHeader) throws Exception {
+ return queryToString(conf, query, includeHeader, " ");
+ }
+
+ public static String queryToCsv(Configuration conf, String query) throws
Exception {
+ return queryToString(conf, query, true, ",");
+ }
+
+ public static String queryToCsv(Configuration conf, String query, boolean
includeHeader) throws Exception {
+ return queryToString(conf, query, includeHeader, ",");
+ }
+
+ public static String queryToString(Configuration conf, String query, boolean
includeHeader, String columnSeparator)
throws Exception {
Connection conn = null;
Statement stmt = null;
@@ -354,13 +368,13 @@ public final class TestTxnDbUtil {
ResultSetMetaData rsmd = rs.getMetaData();
if(includeHeader) {
for (int colPos = 1; colPos <= rsmd.getColumnCount(); colPos++) {
- sb.append(rsmd.getColumnName(colPos)).append(" ");
+ sb.append(rsmd.getColumnName(colPos)).append(columnSeparator);
}
sb.append('\n');
}
while(rs.next()) {
for (int colPos = 1; colPos <= rsmd.getColumnCount(); colPos++) {
- sb.append(rs.getObject(colPos)).append(" ");
+ sb.append(rs.getObject(colPos)).append(columnSeparator);
}
sb.append('\n');
}
@@ -369,7 +383,7 @@ public final class TestTxnDbUtil {
}
return sb.toString();
}
-
+
/**
* This is only for testing, it does not use the connectionPool from
TxnHandler!
* @param conf