aboutsummaryrefslogtreecommitdiff
path: root/common/src/test
diff options
context:
space:
mode:
authorJacques Nadeau <jacques@apache.org>2015-11-08 09:35:45 -0800
committerJacques Nadeau <jacques@apache.org>2015-11-12 17:00:49 -0800
commit44dea433395f00126021e72eb581e0f07e481d0a (patch)
treec32b3af62fc92bd6fab3a91a002e6ad47acbe9af /common/src/test
parenta289fd941a33833524516dea1a3f75ea853aa055 (diff)
DRILL-3987: (MOVE) Move logical expressions and operators out of common. Move to new drill-logical model.
Diffstat (limited to 'common/src/test')
-rw-r--r--common/src/test/java/org/apache/drill/common/expression/PathSegmentTests.java46
-rw-r--r--common/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java118
-rw-r--r--common/src/test/java/org/apache/drill/common/logical/data/OrderTest.java93
-rw-r--r--common/src/test/java/org/apache/drill/storage/CheckStorageConfig.java51
4 files changed, 0 insertions, 308 deletions
diff --git a/common/src/test/java/org/apache/drill/common/expression/PathSegmentTests.java b/common/src/test/java/org/apache/drill/common/expression/PathSegmentTests.java
deleted file mode 100644
index 97cd578c9..000000000
--- a/common/src/test/java/org/apache/drill/common/expression/PathSegmentTests.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.drill.common.expression;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.drill.test.DrillTest;
-import org.junit.Test;
-
-public class PathSegmentTests extends DrillTest {
- protected PathSegment makeArraySegment(final int len, final PathSegment tail) {
- PathSegment node = tail;
- for (int i = 0; i < len; i++) {
- node = new PathSegment.ArraySegment(node);
- }
- return node;
- }
-
- @Test
- public void testIfMultiLevelCloneWorks() {
- final int levels = 10;
- final PathSegment segment = new PathSegment.NameSegment("test", makeArraySegment(levels, null));
- final PathSegment clone = segment.clone();
- assertEquals("result of clone & original segments must be identical", segment, clone);
-
- final PathSegment tail = new PathSegment.NameSegment("tail");
- final PathSegment newSegment = new PathSegment.NameSegment("test", makeArraySegment(levels, tail));
- final PathSegment newClone = segment.cloneWithNewChild(tail);
- assertEquals("result of cloneWithChild & original segment must be identical", newSegment, newClone);
- }
-}
diff --git a/common/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java b/common/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java
deleted file mode 100644
index 7cf147778..000000000
--- a/common/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.drill.common.expression.parser;
-
-import java.io.IOException;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.RecognitionException;
-import org.apache.drill.common.expression.ExpressionStringBuilder;
-import org.apache.drill.common.expression.LogicalExpression;
-import org.apache.drill.common.expression.parser.ExprParser.parse_return;
-import org.apache.drill.test.DrillTest;
-import org.junit.Test;
-
-public class TreeTest extends DrillTest {
-
- @Test
- public void testIfWithCase() throws Exception{
- testExpressionParsing("if ($F1) then case when (_MAP.R_NAME = 'AFRICA') then 2 else 4 end else if(4==3) then 1 else if(x==3) then 7 else (if(2==1) then 6 else 4 end) end");
- }
-
- @Test
- public void testAdd() throws Exception{
- testExpressionParsing("2+2");
- }
-
- @Test
- public void testIf() throws Exception{
- testExpressionParsing("if ('blue.red') then 'orange' else if (false) then 1 else 0 end");
- }
-
- @Test
- public void testQuotedIdentifier() throws Exception{
- testExpressionParsing("`hello friend`.`goodbye`");
- }
-
- @Test
- public void testSpecialQuoted() throws Exception{
- testExpressionParsing("`*0` + `*` ");
- }
-
- @Test
- public void testQuotedIdentifier2() throws Exception{
- testExpressionParsing("`hello friend`.goodbye");
- }
-
- @Test
- public void testComplexIdentifier() throws Exception{
- testExpressionParsing("goodbye[4].`hello`");
- }
-
- @Test // DRILL-2606
- public void testCastToBooleanExpr() throws Exception{
- testExpressionParsing("cast( (cast( (`bool_col` ) as VARCHAR(100) ) ) as BIT )");
- }
-
- private LogicalExpression parseExpression(String expr) throws RecognitionException, IOException{
-
- ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
- CommonTokenStream tokens = new CommonTokenStream(lexer);
-
-// tokens.fill();
-// for(Token t : (List<Token>) tokens.getTokens()){
-// System.out.println(t + "" + t.getType());
-// }
-// tokens.rewind();
-
- ExprParser parser = new ExprParser(tokens);
- parse_return ret = parser.parse();
-
- return ret.e;
-
- }
-
- private String serializeExpression(LogicalExpression expr){
-
- ExpressionStringBuilder b = new ExpressionStringBuilder();
- StringBuilder sb = new StringBuilder();
- expr.accept(b, sb);
- return sb.toString();
- }
-
- /**
- * Attempt to parse an expression. Once parsed, convert it to a string and then parse it again to make sure serialization works.
- * @param expr
- * @throws RecognitionException
- * @throws IOException
- */
- private void testExpressionParsing(String expr) throws RecognitionException, IOException{
- System.out.println("-----" + expr + "-----");
- LogicalExpression e = parseExpression(expr);
-
- String newStringExpr = serializeExpression(e);
- System.out.println(newStringExpr);
- LogicalExpression e2 = parseExpression(newStringExpr);
- //Assert.assertEquals(e, e2);
-
- }
-
-
-
-}
diff --git a/common/src/test/java/org/apache/drill/common/logical/data/OrderTest.java b/common/src/test/java/org/apache/drill/common/logical/data/OrderTest.java
deleted file mode 100644
index 80b4e3c78..000000000
--- a/common/src/test/java/org/apache/drill/common/logical/data/OrderTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.drill.common.logical.data;
-
-import static org.junit.Assert.*;
-
-import java.sql.SQLException;
-
-import org.apache.drill.common.exceptions.DrillRuntimeException;
-import org.apache.drill.common.expression.LogicalExpression;
-import org.apache.drill.common.logical.data.Order.Ordering;
-import org.apache.calcite.rel.RelFieldCollation;
-import org.apache.calcite.rel.RelFieldCollation.Direction;
-import org.apache.calcite.rel.RelFieldCollation.NullDirection;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.*;
-
-public class OrderTest {
-
- //////////
- // Order.Ordering tests:
-
- // "Round trip" tests that strings from output work as input:
-
- @Test
- public void test_Ordering_roundTripAscAndNullsFirst() {
- Ordering src = new Ordering( Direction.ASCENDING, null, NullDirection.FIRST);
- Ordering reconstituted =
- new Ordering( (LogicalExpression) null, src.getOrder(), src.getNullDirection().toString() );
- assertThat( reconstituted.getDirection(), equalTo( RelFieldCollation.Direction.ASCENDING ) );
- assertThat( reconstituted.getNullDirection(), equalTo( NullDirection.FIRST ) );
- }
-
- @Test
- public void test_Ordering_roundTripDescAndNullsLast() {
- Ordering src = new Ordering( Direction.DESCENDING, null, NullDirection.LAST);
- Ordering reconstituted =
- new Ordering( (LogicalExpression) null, src.getOrder(), src.getNullDirection().toString() );
- assertThat( reconstituted.getDirection(), equalTo( RelFieldCollation.Direction.DESCENDING ) );
- assertThat( reconstituted.getNullDirection(), equalTo( NullDirection.LAST ) );
- }
-
- @Test
- public void test_Ordering_roundTripDescAndNullsUnspecified() {
- Ordering src = new Ordering( Direction.DESCENDING, null, NullDirection.UNSPECIFIED);
- Ordering reconstituted =
- new Ordering( (LogicalExpression) null, src.getOrder(), src.getNullDirection().toString() );
- assertThat( reconstituted.getDirection(), equalTo( RelFieldCollation.Direction.DESCENDING ) );
- assertThat( reconstituted.getNullDirection(), equalTo( NullDirection.UNSPECIFIED ) );
- }
-
-
- // Basic input validation:
-
- @Test( expected = DrillRuntimeException.class ) // (Currently.)
- public void test_Ordering_garbageOrderRejected() {
- new Ordering( (LogicalExpression) null, "AS CE ND IN G", (String) null );
- }
-
- @Test( expected = DrillRuntimeException.class ) // (Currently.)
- public void test_Ordering_garbageNullOrderingRejected() {
- new Ordering( (LogicalExpression) null, (String) null, "HIGH" );
- }
-
-
- // Defaults-value/null-strings test:
-
- @Test
- public void testOrdering_nullStrings() {
- Ordering ordering = new Ordering( (LogicalExpression) null, null, null );
- assertThat( ordering.getDirection(), equalTo( RelFieldCollation.Direction.ASCENDING ) );
- assertThat( ordering.getNullDirection(), equalTo( RelFieldCollation.NullDirection.UNSPECIFIED ) );
- assertThat( ordering.getOrder(), equalTo( "ASC" ) );
- }
-
-
-}
diff --git a/common/src/test/java/org/apache/drill/storage/CheckStorageConfig.java b/common/src/test/java/org/apache/drill/storage/CheckStorageConfig.java
deleted file mode 100644
index 090b8f45f..000000000
--- a/common/src/test/java/org/apache/drill/storage/CheckStorageConfig.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.drill.storage;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Collection;
-
-import org.apache.drill.common.config.DrillConfig;
-import org.apache.drill.common.config.LogicalPlanPersistence;
-import org.apache.drill.common.logical.LogicalPlan;
-import org.apache.drill.common.logical.StoragePluginConfig;
-import org.apache.drill.common.scanner.ClassPathScanner;
-import org.apache.drill.common.scanner.persistence.ScanResult;
-import org.apache.drill.common.util.FileUtils;
-import org.apache.drill.test.DrillTest;
-import org.junit.Test;
-
-public class CheckStorageConfig extends DrillTest {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CheckStorageConfig.class);
-
- @Test
- public void ensureStorageEnginePickup() {
- DrillConfig config = DrillConfig.create();
- ScanResult scan = ClassPathScanner.fromPrescan(config);
- Collection<?> engines = scan.getImplementations(StoragePluginConfig.class);
- assertEquals(engines.size(), 1);
- }
-
- @Test
- public void checkPlanParsing() throws Exception{
- DrillConfig config = DrillConfig.create();
- ScanResult scan = ClassPathScanner.fromPrescan(config);
- LogicalPlan plan = LogicalPlan.parse(new LogicalPlanPersistence(config, scan), FileUtils.getResourceAsString("/storage_engine_plan.json"));
- }
-}