This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 2d60312 Improve code coverage for pinot-common (#5986)
2d60312 is described below
commit 2d603122bbce5074423461f893ad7de585e8dafc
Author: Braden Groom <[email protected]>
AuthorDate: Tue Sep 8 14:52:35 2020 -0700
Improve code coverage for pinot-common (#5986)
---
.codecov.yml | 14 ++------------
.../pinot/common/function/AggregationFunctionType.java | 11 +----------
.../pinot/common/function/FunctionDefinitionRegistry.java | 4 ++--
.../pinot/common/function/AggregationFunctionTypeTest.java | 7 +++++++
.../common/function/FunctionDefinitionRegistryTest.java | 8 +++++++-
5 files changed, 19 insertions(+), 25 deletions(-)
diff --git a/.codecov.yml b/.codecov.yml
index ee708be..e66155e 100644
--- a/.codecov.yml
+++ b/.codecov.yml
@@ -5,15 +5,5 @@ coverage:
- pinot-perf/.*
- pinot-hadoop/.*
# Ignore all the auto generated files.
- -
pinot-common/src/main/java/com/linkedin/pinot/common/request/AggregationInfo.java
- -
pinot-common/src/main/java/com/linkedin/pinot/common/request/BrokerRequest.java
- -
pinot-common/src/main/java/com/linkedin/pinot/common/request/FilterOperator.java
- -
pinot-common/src/main/java/com/linkedin/pinot/common/request/FilterQuery.java
- -
pinot-common/src/main/java/com/linkedin/pinot/common/request/FilterQueryMap.java
- - pinot-common/src/main/java/com/linkedin/pinot/common/request/GroupBy.java
- -
pinot-common/src/main/java/com/linkedin/pinot/common/request/InstanceRequest.java
- -
pinot-common/src/main/java/com/linkedin/pinot/common/request/QuerySource.java
- -
pinot-common/src/main/java/com/linkedin/pinot/common/request/QueryType.java
- -
pinot-common/src/main/java/com/linkedin/pinot/common/request/Selection.java
- -
pinot-common/src/main/java/com/linkedin/pinot/common/request/SelectionSort.java
- -
pinot-common/src/main/java/com/linkedin/pinot/common/response/ProcessingException.java
+ - pinot-common/src/main/java/org/apache/pinot/common/request/*.java
+ -
pinot-common/src/main/java/org/apache/pinot/common/response/ProcessingException.java
diff --git
a/pinot-common/src/main/java/org/apache/pinot/common/function/AggregationFunctionType.java
b/pinot-common/src/main/java/org/apache/pinot/common/function/AggregationFunctionType.java
index 5f96e53..20f9761 100644
---
a/pinot-common/src/main/java/org/apache/pinot/common/function/AggregationFunctionType.java
+++
b/pinot-common/src/main/java/org/apache/pinot/common/function/AggregationFunctionType.java
@@ -75,15 +75,6 @@ public enum AggregationFunctionType {
return _name;
}
- public boolean isOfType(AggregationFunctionType... aggregationFunctionTypes)
{
- for (AggregationFunctionType aggregationFunctionType :
aggregationFunctionTypes) {
- if (this == aggregationFunctionType) {
- return true;
- }
- }
- return false;
- }
-
/**
* Returns the corresponding aggregation function type for the given
function name.
* <p>NOTE: Underscores in the function name are ignored.
@@ -110,7 +101,7 @@ public enum AggregationFunctionType {
} else {
try {
return AggregationFunctionType.valueOf(upperCaseFunctionName);
- } catch (Exception e) {
+ } catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid aggregation function name:
" + functionName);
}
}
diff --git
a/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionDefinitionRegistry.java
b/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionDefinitionRegistry.java
index 8e70a20..5031845 100644
---
a/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionDefinitionRegistry.java
+++
b/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionDefinitionRegistry.java
@@ -27,7 +27,7 @@ public class FunctionDefinitionRegistry {
try {
AggregationFunctionType.getAggregationFunctionType(functionName);
return true;
- } catch (Exception e) {
+ } catch (IllegalArgumentException e) {
return false;
}
}
@@ -36,7 +36,7 @@ public class FunctionDefinitionRegistry {
try {
TransformFunctionType.getTransformFunctionType(functionName);
return true;
- } catch (Exception e) {
+ } catch (IllegalArgumentException e) {
return false;
}
}
diff --git
a/pinot-common/src/test/java/org/apache/pinot/common/function/AggregationFunctionTypeTest.java
b/pinot-common/src/test/java/org/apache/pinot/common/function/AggregationFunctionTypeTest.java
index a8edbb2..c606678 100644
---
a/pinot-common/src/test/java/org/apache/pinot/common/function/AggregationFunctionTypeTest.java
+++
b/pinot-common/src/test/java/org/apache/pinot/common/function/AggregationFunctionTypeTest.java
@@ -20,6 +20,8 @@ package org.apache.pinot.common.function;
import org.testng.Assert;
import org.testng.annotations.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
public class AggregationFunctionTypeTest {
@@ -66,4 +68,9 @@ public class AggregationFunctionTypeTest {
Assert.assertEquals(AggregationFunctionType.getAggregationFunctionType("PeRcEnTiLeTdIgEsT95mV"),
AggregationFunctionType.PERCENTILETDIGESTMV);
}
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testInvalidGetAggregationFunctionType() {
+ AggregationFunctionType.getAggregationFunctionType("PERCENTILEFOO");
+ }
}
diff --git
a/pinot-common/src/test/java/org/apache/pinot/common/function/FunctionDefinitionRegistryTest.java
b/pinot-common/src/test/java/org/apache/pinot/common/function/FunctionDefinitionRegistryTest.java
index d81be19..e91175e 100644
---
a/pinot-common/src/test/java/org/apache/pinot/common/function/FunctionDefinitionRegistryTest.java
+++
b/pinot-common/src/test/java/org/apache/pinot/common/function/FunctionDefinitionRegistryTest.java
@@ -27,8 +27,14 @@ import static org.testng.Assert.assertTrue;
public class FunctionDefinitionRegistryTest {
@Test
- public void testScalarFunction() {
+ public void testIsAggFunc() {
+ assertTrue(FunctionDefinitionRegistry.isAggFunc("count"));
assertFalse(FunctionDefinitionRegistry.isAggFunc("toEpochSeconds"));
+ }
+
+ @Test
+ public void testIsTransformFunc() {
assertTrue(FunctionDefinitionRegistry.isTransformFunc("toEpochSeconds"));
+ assertFalse(FunctionDefinitionRegistry.isTransformFunc("foo_bar"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]