Skip to content

Commit

Permalink
fix apache#3738 DuckDB: ALTER COLUMN statement not working
Browse files Browse the repository at this point in the history
  • Loading branch information
sramazzina committed Mar 19, 2024
1 parent bdc3d64 commit e8eead3
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public class DuckDBDatabaseMeta extends BaseDatabaseMeta implements IDatabase {

private static final Class<?> PKG = DuckDBDatabaseMeta.class; // For Translator

@Override
public String getCreateTableStatement() {
return super.getCreateTableStatement();
}

@Override
public String getFieldDefinition(IValueMeta v, String tk, String pk, boolean useAutoIncrement, boolean addFieldName, boolean addCr) {
// https://duckdb.org/docs/sql/data_types/overview.html
Expand All @@ -47,9 +52,11 @@ public String getFieldDefinition(IValueMeta v, String tk, String pk, boolean use
int length = v.getLength();
int precision = v.getPrecision();

if (addFieldName) {
retval += fieldname + " ";
}
if (addFieldName) {
retval += fieldname + " ";
} else {
retval += fieldname + " TYPE ";
}

int type = v.getType();
switch (type) {
Expand Down Expand Up @@ -142,7 +149,7 @@ public boolean isDuckDbVariant() {

@Override
public String getURL(String hostname, String port, String databaseName) throws HopDatabaseException {
return "jdbc:duckdb:" + databaseName;
return "jdbc:duckdb:" + (databaseName.equals("memory") ? "" : databaseName);
}

@Override
Expand All @@ -158,7 +165,7 @@ public String getModifyColumnStatement(String tableName, IValueMeta v, String tk
return "ALTER TABLE "
+ tableName
+ " ALTER COLUMN "
+ getFieldDefinition(v, tk, pk, useAutoIncrement,true, false);
+ getFieldDefinition(v, tk, pk, useAutoIncrement,false, false);
}

@Override
Expand Down

0 comments on commit e8eead3

Please sign in to comment.