ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/3] incubator-ignite git commit: ignite-437: fix loading of bigQuery
Date Tue, 07 Apr 2015 15:02:25 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-437-sqltests-p2 b1d596ae3 -> 5a9a3f55f


ignite-437: fix loading of bigQuery


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e705ac0b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e705ac0b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e705ac0b

Branch: refs/heads/ignite-437-sqltests-p2
Commit: e705ac0b1bbaa864f3773dc6a2d42eb1c5b1459b
Parents: c0e1434
Author: Artem Shutak <ashutak@gridgain.com>
Authored: Tue Apr 7 18:00:27 2015 +0300
Committer: Artem Shutak <ashutak@gridgain.com>
Committed: Tue Apr 7 18:00:27 2015 +0300

----------------------------------------------------------------------
 .../query/h2/sql/H2CompareBigQueryTest.java     | 41 ++++++++-------
 .../processors/query/h2/sql/bigQuery.sql        | 55 ++++++++++++++++++++
 2 files changed, 76 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e705ac0b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java
index 03983a8..51d600d 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/H2CompareBigQueryTest.java
@@ -39,7 +39,7 @@ import java.util.concurrent.atomic.*;
  *  |  ------------------            --part.ReplaceOrder--           |                  
  |
  *  |  --part.CustOrder--            ---------------------           |                  
  |
  *  |  ------------------            -  id  PK           -           |                  
  |
- *  |  -  orderId  PK   - <--  <---> -  orderId  PK      -           |         
           |
+ *  |  -  orderId  PK   - <--  <---> -  orderId          -           |         
           |
  *  -- -  rootOrderId   -   |        -  rootOrderId      - -----------                  
  |
  *     -  origOrderId   -   |        -  refOrderId       -   // = origOrderId           
  |
  *     -  date          -   |        -  date             -                              
  |
@@ -67,26 +67,27 @@ public class H2CompareBigQueryTest extends AbstractH2CompareQueryTest
{
     private static final int DATES_CNT = 5;
     
     /** Full the big query. */
-    private static final String BIG_QUERY;
-    
-    static {
-//        String res = "";
-//
-//        String file = "src/test/java/org/apache/ignite/internal/processors/query/h2/sql/Bigquery.sql";
-//
-//        try(BufferedReader reader = new BufferedReader(new FileReader(file))) {
-//            for(String line; (line = reader.readLine()) != null; )
-//                res += line + '\n';
-//        }
-//        catch (IOException e) {
-//            e.printStackTrace();
-//
-//            System.exit(1);
-//        }
+    private String bigQry = getBigQry();
+
+    private String getBigQry() {
+        String res = "";
+
+        Reader isr = new InputStreamReader(getClass().getResourceAsStream("bigQuery.sql"));
         
-        BIG_QUERY = "Select 10";
+        try(BufferedReader reader = new BufferedReader(isr)) {
+            for(String line; (line = reader.readLine()) != null; )
+                if (!line.startsWith("--")) // Skip commented lines.
+                    res += line + '\n';
+        }
+        catch (Throwable e) {
+            e.printStackTrace();
+            
+            fail();
+        }
+
+        return res;
     }
-        
+
     /** {@inheritDoc} */
     @Override protected void setIndexedTypes(CacheConfiguration<?, ?> cc, CacheMode
mode) {
         if (mode == CacheMode.PARTITIONED)
@@ -245,7 +246,7 @@ public class H2CompareBigQueryTest extends AbstractH2CompareQueryTest
{
      * @throws Exception If failed.
      */
     public void testBigQuery() throws Exception {
-        List<List<?>> res = compareQueryRes0(BIG_QUERY);
+        List<List<?>> res = compareQueryRes0(bigQry);
         
         assertTrue(!res.isEmpty()); // Ensure we set good testing data at database.
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e705ac0b/modules/indexing/src/test/resources/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/resources/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
b/modules/indexing/src/test/resources/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
new file mode 100644
index 0000000..93b62eb
--- /dev/null
+++ b/modules/indexing/src/test/resources/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
@@ -0,0 +1,55 @@
+--
+-- 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.
+--
+
+select *
+from (
+  select rootOrderId as custOrderId, co.date, co.orderId, replace(co.alias,'_ALGO','') as
alias, op.parentAlgo
+  from (
+	select  date, orderId, rootOrderId, origOrderId, archSeq, alias 
+	from "part".CustOrder where alias='CUSTOM'
+	
+	union all
+	
+	select  date, orderId, refOrderId as origOrderId, rootOrderId, archSeq, alias 
+	from "part".ReplaceOrder where alias='CUSTOM'
+  ) co, "part".OrderParams op
+  where co.date = op.date and co.orderId = op.orderId and co.archSeq = -- TODO: replace with
'dateToLong(co.date)+archSeq'.
+	(
+	  select max(archSeq) -- TODO: replace with 'dateToLong(co.date)+archSeq'.
+	  from (
+		  select  date, orderId, rootOrderId, origOrderId, archSeq, alias 
+		  from "part".CustOrder where alias='CUSTOM'
+		  
+		  union all
+		  
+		  select  date, orderId, refOrderId as origOrderId, rootOrderId, archSeq, alias 
+		  from "part".ReplaceOrder where alias='CUSTOM'
+	  ) 
+	  where origOrderId = co.origOrderId and date = co.date
+	) and co.alias='CUSTOM'
+) cop 
+inner join (
+  select e.date, e.rootOrderId as eRootOrderId, e.rootOrderId, sum(e.execShares) as execShares,

+	sum(e.execShares*e.price)/sum(e.execShares) as price,
+	case when min(e.lastMkt) = max(e.lastMkt) then min(e.lastMkt) else min('XOFF') end as execMeet
+  from "repl".Exec e
+  group by e.date, e.rootOrderId
+) oep on (cop.date = oep.date and cop.custOrderId = oep.eRootOrderId)
+left outer join (
+  select top 1 refOrderId, date from "part".Cancel
+) cc on (cc.refOrderId = cop.orderId and cc.date = cop.date)
+where cop.alias='CUSTOM'


Mime
View raw message