Skip to content

Commit

Permalink
fix: duckdb extension debug; classload cannot work from static !
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolife999 committed Mar 22, 2024
1 parent 5c6fd0d commit f14813e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void exportParquetTestOnExecutor() throws SQLException, IOException, ArcE
// create a test table on executor 1
createTestTable(InitializeQueryTest.e2, testTable);

ParquetDao.exportToParquet(Arrays.asList(new TableToRetrieve(ArcDatabase.COORDINATOR, testTable),
new ParquetDao().exportToParquet(Arrays.asList(new TableToRetrieve(ArcDatabase.COORDINATOR, testTable),
new TableToRetrieve(ArcDatabase.EXECUTOR, testTable)), repertoire, null);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ParquetDao {
// directory where extension will be unzip and used by duckdb
private static final String DUCKDB_EXTENSION_INSTALLATION_DIRECTORY = "./duckdb/";

public static void exportToParquet(List<TableToRetrieve> tables, String outputDirectory,
public void exportToParquet(List<TableToRetrieve> tables, String outputDirectory,
ParquetEncryptionKey encryptionKey) throws ArcException {

loadDuckdb();
Expand All @@ -66,7 +66,7 @@ public static void exportToParquet(List<TableToRetrieve> tables, String outputDi

}

private static void exportTableToParquet(Connection connection, TableToRetrieve table, String outputDirectory)
private void exportTableToParquet(Connection connection, TableToRetrieve table, String outputDirectory)
throws SQLException {

PropertiesHandler properties = PropertiesHandler.getInstance();
Expand Down Expand Up @@ -100,14 +100,14 @@ private static void exportTableToParquet(Connection connection, TableToRetrieve

}

private static void executeCopy(Connection connection, GenericPreparedStatementBuilder selectQuery, String output)
private void executeCopy(Connection connection, GenericPreparedStatementBuilder selectQuery, String output)
throws SQLException {
GenericPreparedStatementBuilder query = new GenericPreparedStatementBuilder();
query.append("COPY (").append(selectQuery).append(") TO " + query.quoteText(output) + "; ");
executeQuery(connection, query);
}

private static void attachPostgresDatabasesToDuckdb(Connection connection, ParquetEncryptionKey encryptionKey)
private void attachPostgresDatabasesToDuckdb(Connection connection, ParquetEncryptionKey encryptionKey)
throws SQLException, IOException {

PropertiesHandler properties = PropertiesHandler.getInstance();
Expand Down Expand Up @@ -140,7 +140,7 @@ private static void attachPostgresDatabasesToDuckdb(Connection connection, Parqu

}

private static void unzipDuckdbPostgresExtensions() throws IOException {
private void unzipDuckdbPostgresExtensions() throws IOException {
System.out.println("§§§§");
System.out.println(ParquetDao.class.getClassLoader());
System.out.println(ParquetDao.class.getClassLoader().getResource(DUCKDB_EXTENSION_PROVIDED_FILE));
Expand Down Expand Up @@ -173,7 +173,7 @@ private static void unzipDuckdbPostgresExtensions() throws IOException {
}
}

private static void executeQuery(Connection connection, GenericPreparedStatementBuilder query) throws SQLException {
private void executeQuery(Connection connection, GenericPreparedStatementBuilder query) throws SQLException {
try (PreparedStatement stmt = connection.prepareStatement(query.getQueryWithParameters())) {
stmt.execute();
}
Expand All @@ -184,7 +184,7 @@ private static void executeQuery(Connection connection, GenericPreparedStatement
*
* @throws ArcException
*/
private static void loadDuckdb() throws ArcException {
private void loadDuckdb() throws ArcException {
try {
Class.forName("org.duckdb.DuckDBDriver");
} catch (ClassNotFoundException e) {
Expand All @@ -200,7 +200,7 @@ private static void loadDuckdb() throws ArcException {
* @param connectionIndex
* @return
*/
protected static String attachedTableName(int connectionIndex, String tablename) {
protected String attachedTableName(int connectionIndex, String tablename) {
return attachmentName(connectionIndex) + Delimiters.SQL_SCHEMA_DELIMITER + tablename;
}

Expand All @@ -212,7 +212,7 @@ protected static String attachedTableName(int connectionIndex, String tablename)
* @param connectionIndex
* @return
*/
protected static String attachmentName(int connectionIndex) {
protected String attachmentName(int connectionIndex) {
return ATTACHMENT_NAME_PREFIX + Delimiters.SQL_TOKEN_DELIMITER + connectionIndex;
}

Expand Down

0 comments on commit f14813e

Please sign in to comment.