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

PHOENIX-4981 Add tests for ORDER BY, GROUP BY and salted tables using… #402

Closed
wants to merge 1 commit into from
Closed
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
987 changes: 51 additions & 936 deletions phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java

Large diffs are not rendered by default.

1,022 changes: 1,022 additions & 0 deletions phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateIT.java

Large diffs are not rendered by default.

940 changes: 940 additions & 0 deletions phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOrderByIT.java

Large diffs are not rendered by default.

943 changes: 113 additions & 830 deletions phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,26 @@

package org.apache.phoenix.end2end;

import org.apache.commons.lang.StringUtils;
import org.apache.phoenix.query.BaseTest;
import org.apache.phoenix.util.QueryBuilder;
import org.apache.phoenix.util.QueryUtil;
import org.apache.phoenix.util.ReadOnlyProps;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.experimental.categories.Category;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;



/**
* Base class for tests whose methods run in parallel with statistics disabled.
* You must create unique names using {@link #generateUniqueName()} for each
Expand All @@ -41,4 +55,30 @@ public static final void doSetup() throws Exception {
public static void tearDownMiniCluster() throws Exception {
BaseTest.tearDownMiniClusterIfBeyondThreshold();
}

protected ResultSet executeQuery(Connection conn, QueryBuilder queryBuilder) throws SQLException {
PreparedStatement statement = conn.prepareStatement(queryBuilder.build());
ResultSet rs = statement.executeQuery();
return rs;
}

protected ResultSet executeQueryThrowsException(Connection conn, QueryBuilder queryBuilder,
String expectedPhoenixExceptionMsg, String expectedSparkExceptionMsg) {
ResultSet rs = null;
try {
rs = executeQuery(conn, queryBuilder);
fail();
}
catch(Exception e) {
assertTrue(e.getMessage().contains(expectedPhoenixExceptionMsg));
}
return rs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we ever want code to reach here? Or do we want to Assert.fail if the exception doesn't occur?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should fail if an exception is not thrown, I fixed this.

}

protected void validateQueryPlan(Connection conn, QueryBuilder queryBuilder, String expectedPhoenixPlan, String expectedSparkPlan) throws SQLException {
if (StringUtils.isNotBlank(expectedPhoenixPlan)) {
ResultSet rs = conn.createStatement().executeQuery("EXPLAIN " + queryBuilder.build());
assertEquals(expectedPhoenixPlan, QueryUtil.getExplainPlan(rs));
}
}
}
Loading