Skip to content

Commit

Permalink
PHOENIX-4981 Add tests for ORDER BY, GROUP BY and salted tables using…
Browse files Browse the repository at this point in the history
… phoenix-spark
  • Loading branch information
twdsilva committed Nov 1, 2018
1 parent 527098e commit 57ac77e
Show file tree
Hide file tree
Showing 18 changed files with 4,641 additions and 2,259 deletions.
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;
}

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

0 comments on commit 57ac77e

Please sign in to comment.