Skip to content

Commit

Permalink
Make SqlParser a test constant in AbstractTestQueryFramework
Browse files Browse the repository at this point in the history
We do so in some other test classes, so increases code consistency.
  • Loading branch information
findepi committed May 18, 2022
1 parent 42ed1bd commit 8565c9f
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@

public abstract class AbstractTestQueryFramework
{
private static final SqlParser SQL_PARSER = new SqlParser();

private QueryRunner queryRunner;
private H2QueryRunner h2QueryRunner;
private SqlParser sqlParser;
private final AutoCloseableCloser afterClassCloser = AutoCloseableCloser.create();
private io.trino.sql.query.QueryAssertions queryAssertions;

Expand All @@ -93,7 +94,6 @@ public void init()
{
queryRunner = afterClassCloser.register(createQueryRunner());
h2QueryRunner = afterClassCloser.register(new H2QueryRunner());
sqlParser = new SqlParser();
queryAssertions = new io.trino.sql.query.QueryAssertions(queryRunner);
}

Expand All @@ -110,7 +110,6 @@ public final void close()
finally {
queryRunner = null;
h2QueryRunner = null;
sqlParser = null;
queryAssertions = null;
}
}
Expand Down Expand Up @@ -493,7 +492,7 @@ protected void executeExclusively(Runnable executionBlock)

protected String formatSqlText(String sql)
{
return formatSql(sqlParser.createStatement(sql, createParsingOptions(getSession())));
return formatSql(SQL_PARSER.createStatement(sql, createParsingOptions(getSession())));
}

//TODO: should WarningCollector be added?
Expand All @@ -503,7 +502,7 @@ protected String getExplainPlan(String query, ExplainType.Type planType)
return newTransaction()
.singleStatement()
.execute(getSession(), session -> {
return explainer.getPlan(session, sqlParser.createStatement(query, createParsingOptions(session)), planType, emptyList(), WarningCollector.NOOP);
return explainer.getPlan(session, SQL_PARSER.createStatement(query, createParsingOptions(session)), planType, emptyList(), WarningCollector.NOOP);
});
}

Expand All @@ -513,7 +512,7 @@ protected String getGraphvizExplainPlan(String query, ExplainType.Type planType)
return newTransaction()
.singleStatement()
.execute(queryRunner.getDefaultSession(), session -> {
return explainer.getGraphvizPlan(session, sqlParser.createStatement(query, createParsingOptions(session)), planType, emptyList(), WarningCollector.NOOP);
return explainer.getGraphvizPlan(session, SQL_PARSER.createStatement(query, createParsingOptions(session)), planType, emptyList(), WarningCollector.NOOP);
});
}

Expand Down

0 comments on commit 8565c9f

Please sign in to comment.