Skip to content

Commit

Permalink
DRILL-6426: Refactor TestFunctionsWithTypeExpoQueries test to be inde…
Browse files Browse the repository at this point in the history
…pendent on limit 0 optimization option

closes #1273
  • Loading branch information
arina-ielchiieva committed May 18, 2018
1 parent bdbd93f commit 55f2599
Showing 1 changed file with 25 additions and 9 deletions.
Expand Up @@ -22,7 +22,10 @@
import org.apache.drill.categories.SqlFunctionTest;
import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.common.types.TypeProtos;
import org.apache.drill.common.types.Types;
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.test.BaseTestQuery;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
Expand All @@ -32,9 +35,16 @@

@Category(SqlFunctionTest.class)
public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery {

@BeforeClass
public static void setupFiles() {
public static void setup() {
dirTestWatcher.copyResourceToRoot(Paths.get("typeExposure"));
alterSession(ExecConstants.EARLY_LIMIT0_OPT_KEY, true);
}

@AfterClass
public static void tearDown() {
resetSessionOption(ExecConstants.EARLY_LIMIT0_OPT_KEY);
}

@Test
Expand All @@ -44,9 +54,10 @@ public void testConcatWithMoreThanTwoArgs() throws Exception {

List<Pair<SchemaPath, TypeProtos.MajorType>> expectedSchema = Lists.newArrayList();
TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder()
.setMinorType(TypeProtos.MinorType.VARCHAR)
.setMode(TypeProtos.DataMode.REQUIRED)
.build();
.setMinorType(TypeProtos.MinorType.VARCHAR)
.setMode(TypeProtos.DataMode.REQUIRED)
.setPrecision(Types.MAX_VARCHAR_LENGTH)
.build();
expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col"), majorType));

testBuilder()
Expand Down Expand Up @@ -95,6 +106,7 @@ public void testLRBTrimOneArg() throws Exception {
TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder()
.setMinorType(TypeProtos.MinorType.VARCHAR)
.setMode(TypeProtos.DataMode.REQUIRED)
.setPrecision(Types.MAX_VARCHAR_LENGTH)
.build();
expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col"), majorType));

Expand Down Expand Up @@ -125,9 +137,10 @@ public void testTrim() throws Exception {

List<Pair<SchemaPath, TypeProtos.MajorType>> expectedSchema = Lists.newArrayList();
TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder()
.setMinorType(TypeProtos.MinorType.VARCHAR)
.setMode(TypeProtos.DataMode.REQUIRED)
.build();
.setMinorType(TypeProtos.MinorType.VARCHAR)
.setMode(TypeProtos.DataMode.REQUIRED)
.setPrecision(Types.MAX_VARCHAR_LENGTH)
.build();
expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col"), majorType));

testBuilder()
Expand Down Expand Up @@ -159,6 +172,7 @@ public void testTrimOneArg() throws Exception {
TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder()
.setMinorType(TypeProtos.MinorType.VARCHAR)
.setMode(TypeProtos.DataMode.REQUIRED)
.setPrecision(Types.MAX_VARCHAR_LENGTH)
.build();
expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col"), majorType));

Expand Down Expand Up @@ -191,6 +205,7 @@ public void testTrimTwoArg() throws Exception {
TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder()
.setMinorType(TypeProtos.MinorType.VARCHAR)
.setMode(TypeProtos.DataMode.REQUIRED)
.setPrecision(Types.MAX_VARCHAR_LENGTH)
.build();
expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col"), majorType));

Expand All @@ -214,12 +229,12 @@ public void testTrimTwoArg() throws Exception {
}

@Test
public void tesIsNull() throws Exception {
public void testIsNull() throws Exception {
final String query = "select r_name is null as col from cp.`tpch/region.parquet` limit 0";
List<Pair<SchemaPath, TypeProtos.MajorType>> expectedSchema = Lists.newArrayList();
TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder()
.setMinorType(TypeProtos.MinorType.BIT)
.setMode(TypeProtos.DataMode.REQUIRED)
.setMode(TypeProtos.DataMode.OPTIONAL)
.build();
expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col"), majorType));

Expand Down Expand Up @@ -501,6 +516,7 @@ public void testUDFInGroupBy() throws Exception {
final TypeProtos.MajorType majorType2 = TypeProtos.MajorType.newBuilder()
.setMinorType(TypeProtos.MinorType.VARCHAR)
.setMode(TypeProtos.DataMode.OPTIONAL)
.setPrecision(Types.MAX_VARCHAR_LENGTH)
.build();

final TypeProtos.MajorType majorType3 = TypeProtos.MajorType.newBuilder()
Expand Down

0 comments on commit 55f2599

Please sign in to comment.