Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hantmac committed Nov 28, 2024
1 parent 3c1b351 commit d74492c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.LocalDate;
import java.util.List;
import java.util.OptionalInt;
Expand Down Expand Up @@ -339,7 +341,7 @@ public void testNativeQueryInsertStatementTableDoesNotExist()
// override because Databend succeeds in preparing query, and then fails because of no metadata available
assertThat(getQueryRunner().tableExists(getSession(), "non_existent_table")).isFalse();
assertThat(query("SELECT * FROM TABLE(system.query(query => 'INSERT INTO non_existent_table VALUES (1)'))"))
.failure().hasMessageContaining("Unknown table");
.failure().hasMessageContaining("Query not supported: ResultSetMetaData not available for query: INSERT INTO non_existent_table VALUES (1)");
}

private String getLongInClause(int start, int length)
Expand Down Expand Up @@ -376,8 +378,11 @@ public void verifyDatabendJdbcDriverNegativeDateHandling()
throws Exception
{
LocalDate negativeDate = LocalDate.of(-1, 1, 1);
if (!databendSupportsNegativeDates()) {
System.out.println("Databend does not support negative dates. Skipping this test.");
return;
}
try (TestTable table = new TestTable(onRemoteDatabase(), "tpch.verify_negative_date", "(dt DATE)")) {
// Insert via prepared statement succeeds but writes incorrect value due to bug in driver
try (Connection connection = databendServer.createConnection();
PreparedStatement insert = connection.prepareStatement("INSERT INTO " + table.getName() + " VALUES (?)")) {
insert.setObject(1, negativeDate);
Expand All @@ -395,4 +400,17 @@ public void verifyDatabendJdbcDriverNegativeDateHandling()
}
}
}

// check databend support for negative dates
private boolean databendSupportsNegativeDates()
{
try (Connection connection = databendServer.createConnection();
Statement statement = connection.createStatement()) {
statement.execute("SELECT DATE '-0001-01-01'");
return true;
}
catch (SQLException e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void execute(String sql)

public String getJdbcUrl()
{
return format("jdbc:databend://databend:databend@%s:%s/", dockerContainer.getHost(),
return format("jdbc:databend://databend:databend@%s:%s?presigned_url_disabled=true", dockerContainer.getHost(),
dockerContainer.getMappedPort(8000));
}

Expand Down

0 comments on commit d74492c

Please sign in to comment.