db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1378639 [2/2] - in /db/derby/code/trunk: java/engine/ java/engine/org/apache/derby/ java/engine/org/apache/derby/agg/ java/engine/org/apache/derby/catalog/types/ java/engine/org/apache/derby/iapi/reference/ java/engine/org/apache/derby/iap...
Date Wed, 29 Aug 2012 16:52:59 GMT
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UserDefinedAggregatesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UserDefinedAggregatesTest.java?rev=1378639&r1=1378638&r2=1378639&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UserDefinedAggregatesTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UserDefinedAggregatesTest.java
Wed Aug 29 16:52:58 2012
@@ -293,4 +293,128 @@ public class UserDefinedAggregatesTest  
         badAggregate( conn, ILLEGAL_AGGREGATE, "var_samp" );
     }
 
+    /**
+     * <p>
+     * Basic test for non-distinct aggregates.
+     * </p>
+     */
+    public void test_05_basicNonDistinct() throws Exception
+    {
+        Connection conn = getConnection();
+
+        goodStatement
+            ( conn, "create derby aggregate mode for int\n" +
+              "external name 'org.apache.derbyTesting.functionTests.tests.lang.ModeAggregate'"
);
+        goodStatement( conn, "create table mode_inputs( a int, b int )" );
+        goodStatement( conn, "insert into mode_inputs( a, b ) values ( 1, 1 ), ( 1, 2 ),
( 1, 2 ), ( 1, 2 ), ( 2, 3 ), ( 2, 3 ), ( 2, 4 )" );
+
+        // scalar aggregate
+        assertResults
+            (
+             conn,
+             "select mode( b ) from mode_inputs",
+             new String[][]
+             {
+                 { "2" },
+             },
+             false
+             );
+
+        // grouped aggregate
+        assertResults
+            (
+             conn,
+             "select a, mode( b ) from mode_inputs group by a",
+             new String[][]
+             {
+                 { "1", "2" },
+                 { "2", "3" },
+             },
+             false
+             );
+    }
+
+    /**
+     * <p>
+     * Test for parameterized aggregates.
+     * </p>
+     */
+    public void test_06_parameterizedAggregates() throws Exception
+    {
+        Connection conn = getConnection();
+
+        vetParameterizedAggregate
+            (
+             conn,
+             "intMode",
+             "int",
+             "IntMode",
+             "( 1, 1 ), ( 1, 2 ), ( 1, 2 ), ( 1, 2 ), ( 2, 3 ), ( 2, 3 ), ( 2, 4 )",
+             new String[][]
+             {
+                 { "2" },
+             },
+             new String[][]
+             {
+                 { "1", "2" },
+                 { "2", "3" },
+             }
+             );
+
+        vetParameterizedAggregate
+            (
+             conn,
+             "varcharMode",
+             "varchar( 5 )",
+             "StringMode",
+             "( 1, 'a' ), ( 1, 'ab' ), ( 1, 'ab' ), ( 1, 'ab' ), ( 2, 'abc' ), ( 2, 'abc'
), ( 2, 'abcd' )",
+             new String[][]
+             {
+                 { "ab" },
+             },
+             new String[][]
+             {
+                 { "1", "ab" },
+                 { "2", "abc" },
+             }
+             );
+
+    }
+    private void    vetParameterizedAggregate
+        (
+         Connection conn,
+         String aggName,
+         String sqlType,
+         String nestedClassName,
+         String values,
+         String[][] scalarResult,
+         String[][] groupedResult
+         )
+        throws Exception
+    {
+        String  tableName = aggName + "_mode_inputs";
+        
+        goodStatement
+            ( conn, "create derby aggregate " + aggName + " for " + sqlType + "\n" +
+              "external name 'org.apache.derbyTesting.functionTests.tests.lang.GenericMode$"
+ nestedClassName + "'" );
+        goodStatement( conn, "create table " + tableName + "( a int, b " + sqlType + " )"
);
+        goodStatement( conn, "insert into " + tableName + "( a, b ) values " + values );
+
+        assertResults
+            (
+             conn,
+             "select " + aggName + "( b ) from " + tableName,
+             scalarResult,
+             false
+             );
+
+        assertResults
+            (
+             conn,
+             "select a, " + aggName + "( b ) from " + tableName + " group by a",
+             groupedResult,
+             false
+             );
+    }
+
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=1378639&r1=1378638&r2=1378639&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Wed Aug 29 16:52:58 2012
@@ -191,6 +191,9 @@ public class _Suite extends BaseTestCase
             
             // test uses PooledConnections and Savepoints
             suite.addTest(DeclareGlobalTempTableJavaJDBC30Test.suite());
+
+            // requires Java 5 (generics)
+            suite.addTest(UserDefinedAggregatesTest.suite());
         }
         
         suite.addTest(BigDataTest.suite());
@@ -207,7 +210,6 @@ public class _Suite extends BaseTestCase
         suite.addTest(RestrictedVTITest.suite());
         suite.addTest(UDTTest.suite());
         suite.addTest(UDTPermsTest.suite());
-        suite.addTest(UserDefinedAggregatesTest.suite());
         suite.addTest(BooleanValuesTest.suite());
         suite.addTest(AlterColumnTest.suite());
         suite.addTest(UserLobTest.suite());

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml?rev=1378639&r1=1378638&r2=1378639&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml
Wed Aug 29 16:52:58 2012
@@ -85,6 +85,8 @@
       	<pathelement path="${junit}"/>
       </classpath>
       <include name="${this.dir}/*.java"/>
+      <exclude name="${this.dir}/GenericMode.java"/>
+      <exclude name="${this.dir}/ModeAggregate.java"/>
       <exclude name="${this.dir}/declareGlobalTempTableJavaJDBC30.java"/>
       <exclude name="${this.dir}/UpdatableResultSetTest.java"/>
       <exclude name="${this.dir}/holdCursorJavaReflection.java"/>
@@ -123,6 +125,7 @@
       <include name="${this.dir}/unaryArithmeticDynamicParameter.java"/>
     </javac>
   </target>
+
   <target name="compilet3" depends="compilet2">
     <javac
       source="1.4"
@@ -143,10 +146,33 @@
       <include name="${this.dir}/declareGlobalTempTableJavaJDBC30.java"/>
     </javac>
   </target> 
+
+  <target name="compilet3.1" depends="compilet3">
+    <javac
+      source="1.5"
+      target="1.5"
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="true"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}"
+      srcdir="${derby.testing.src.dir}"
+      destdir="${out.dir}">
+      <classpath>
+        <pathelement path="${java15compile.classpath}"/>
+      </classpath>
+      <include name="${this.dir}/GenericMode.java"/>
+      <include name="${this.dir}/ModeAggregate.java"/>
+    </javac>
+  </target> 
+
 	<!-- Compile _Suite last as it needs to include all other JUnit classes 
 	which may be compiled using a higher compiler level, but it needs to be at
 	base level -->
-	<target name="compilett4" depends="compilet3" >
+	<target name="compilett4" depends="compilet3.1" >
     <javac
       source="1.4"
       target="1.4"

Modified: db/derby/code/trunk/tools/jar/extraDBMSclasses.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/jar/extraDBMSclasses.properties?rev=1378639&r1=1378638&r2=1378639&view=diff
==============================================================================
--- db/derby/code/trunk/tools/jar/extraDBMSclasses.properties (original)
+++ db/derby/code/trunk/tools/jar/extraDBMSclasses.properties Wed Aug 29 16:52:58 2012
@@ -26,6 +26,7 @@ derby.module.database.Factory=org.apache
 derby.module.database.ConnectionInfo=org.apache.derby.iapi.db.ConnectionInfo
 derby.module.aggs.MaxMinAggDef=org.apache.derby.impl.sql.compile.MaxMinAggregateDefinition
 derby.module.aggs.SumAvgAggDef=org.apache.derby.impl.sql.compile.SumAvgAggregateDefinition
+derby.module.aggs.SumAvgAggDef=org.apache.derby.impl.sql.execute.UserDefinedAggregator
 derby.module.jndi.basicSchemaBase=org.apache.derby.impl.jdbc.authentication.JNDIAuthenticationSchemeBase
 derby.module.jndi.basicService=org.apache.derby.impl.jdbc.authentication.JNDIAuthenticationService
 derby.module.jndi.LDAPSchemeImpl=org.apache.derby.impl.jdbc.authentication.LDAPAuthenticationSchemeImpl

Modified: db/derby/code/trunk/tools/javadoc/publishedapi.ant
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/javadoc/publishedapi.ant?rev=1378639&r1=1378638&r2=1378639&view=diff
==============================================================================
--- db/derby/code/trunk/tools/javadoc/publishedapi.ant (original)
+++ db/derby/code/trunk/tools/javadoc/publishedapi.ant Wed Aug 29 16:52:58 2012
@@ -61,6 +61,10 @@ org/apache/derby/vti/VTICosting.java
 org/apache/derby/vti/VTIEnvironment.java
 org/apache/derby/vti/VTITemplate.java
 
+# package: org.apache.derby.agg
+
+org/apache/derby/agg/Aggregator.java
+
 # package: org.apache.derby.mbeans (all)
 
 org/apache/derby/mbeans/*.java



Mime
View raw message