Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Functional Test Failures #24123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Duration;
Expand All @@ -50,6 +50,7 @@
import java.util.logging.Logger;

import static com.facebook.presto.testing.TestingSession.testSessionBuilder;
import static java.sql.DriverManager.getConnection;

public class ContainerQueryRunner
implements QueryRunner
Expand All @@ -72,7 +73,6 @@ public class ContainerQueryRunner
private final String schema;
private final int numberOfWorkers;
private Connection connection;
private Statement statement;

public ContainerQueryRunner()
throws InterruptedException, IOException
Expand Down Expand Up @@ -108,8 +108,7 @@ public ContainerQueryRunner(int coordinatorPort, String catalog, String schema,
"timeZoneId=UTC");

try {
Connection connection = DriverManager.getConnection(url, "test", null);
statement = connection.createStatement();
connection = getConnection(url, "test", null);
}
catch (SQLException e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -297,12 +296,12 @@ public Session getDefaultSession()
public MaterializedResult execute(Session session, String sql)
{
try {
return ContainerQueryRunnerUtils
.toMaterializedResult(
statement.executeQuery(sql));
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(sql);
return ContainerQueryRunnerUtils.toMaterializedResult(resultSet);
}
catch (SQLException e) {
throw new RuntimeException(e);
throw new RuntimeException("Error executing query: " + sql, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.facebook.presto.common.type.TimestampWithTimeZoneType;
import com.facebook.presto.common.type.TinyintType;
import com.facebook.presto.common.type.Type;
import com.facebook.presto.common.type.TypeSignature;
import com.facebook.presto.common.type.TypeSignatureParameter;
import com.facebook.presto.common.type.UnknownType;
import com.facebook.presto.common.type.VarbinaryType;
import com.facebook.presto.common.type.VarcharType;
Expand Down Expand Up @@ -204,10 +206,6 @@ public static void createPropertiesFile(String filePath, Properties properties)
parentDir.mkdirs();
}

if (file.exists()) {
throw new IOException("File exists: " + filePath);
}

try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
for (String key : properties.stringPropertyNames()) {
writer.write(key + "=" + properties.getProperty(key) + "\n");
Expand All @@ -224,10 +222,6 @@ public static void createScriptFile(String filePath, String scriptContent)
parentDir.mkdirs();
}

if (file.exists()) {
throw new IOException("File exists: " + filePath);
}

try (OutputStream output = new FileOutputStream(file);
OutputStreamWriter writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) {
writer.write(scriptContent);
Expand All @@ -251,10 +245,17 @@ public static MaterializedResult toMaterializedResult(ResultSet resultSet)
String typeName = metaData.getColumnTypeName(i);

if (sqlType == java.sql.Types.ARRAY) {
// Get the base type of the array elements
String arrayElementTypeName = metaData.getColumnTypeName(i);
Type elementType = mapSqlTypeNameToType(arrayElementTypeName);
types.add(new ArrayType(elementType));
TypeSignature typeSignature = TypeSignature.parseTypeSignature(typeName);
List<TypeSignatureParameter> parameters = typeSignature.getParameters();

if (parameters.size() == 1) {
TypeSignature baseTypeSignature = parameters.get(0).getTypeSignature();
Type elementType = mapSqlTypeNameToType(baseTypeSignature.toString());
types.add(new ArrayType(elementType));
}
else {
throw new UnsupportedOperationException("Unsupported ARRAY type with multiple parameters: " + typeName);
}
}
else if (sqlType == java.sql.Types.STRUCT) {
// Handle STRUCT types if necessary
Expand Down
Loading