ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: ignite-437: bigquery.sql
Date Tue, 07 Apr 2015 10:00:44 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-437-sqltests-p2 dd6d11102 -> 6b327fb51


ignite-437: bigquery.sql


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

Branch: refs/heads/ignite-437-sqltests-p2
Commit: 6b327fb51cbc722f7313b4c00452487180dcead2
Parents: dd6d111
Author: Artem Shutak <ashutak@gridgain.com>
Authored: Tue Apr 7 13:00:38 2015 +0300
Committer: Artem Shutak <ashutak@gridgain.com>
Committed: Tue Apr 7 13:00:38 2015 +0300

----------------------------------------------------------------------
 .../query/h2/sql/H2CompareBigQueryTest.java     | 136 +++----------------
 .../processors/query/h2/sql/bigQuery.sql        |  38 ++++++
 2 files changed, 56 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6b327fb5/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 93a11cc..afa97ce 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,99 +39,27 @@ public class H2CompareBigQueryTest extends AbstractH2CompareQueryTest
{
     /** Dates count. */
     private static final int DATES_CNT = 5;
     
-    /** Big repitable select of the big query. */
-    private static final String BSELECT =
-        "  select  date, orderId, rootOrderId, origOrderId, archSeq, alias \n" +
-        "  from \"part\".CustOrder where alias='CUSTOM'\n" +
-        "  union all\n" +
-        "  select  date, orderId, refOrderId as origOrderId, rootOrderId, archSeq, alias
\n" +
-        "  from \"part\".ReplaceOrder where alias='CUSTOM'";
-
-    /** Big query "cop" part. */
-    private static final String BQ_COP = 
-        "  select rootOrderId as custOrderId, co.date, co.orderId, replace(co.alias,'_ALGO','')
as alias, \n" +
-        "         op.parentAlgo\n" +
-        "  from (\n" +
-             indent1(BSELECT) +
-        "  ) co, \"part\".OrderParams op\n" +
-        "  where co.date = op.date and co.orderId = op.orderId and " +
-//             "dateToLong(co.date)+" +
-        "      co.archSeq =\n" +
-        "    (\n" +
-        "      select max(" +
-//               "dateToLong(date)+" +
-        "        archSeq) \n" +
-        "      from (\n" +
-                 indent4(BSELECT) +
-        "      ) \n" +
-        "      where origOrderId = co.origOrderId and date = co.date\n" +
-        "    ) and co.alias='CUSTOM'";
-    
-    /** Big query "oep" part. */
-    private static final String BQ_OEP = 
-        "  select e.date, e.rootOrderId as eRootOrderId, e.rootOrderId, sum(e.execShares)
as execShares, \n" +
-        "    sum(e.execShares*e.price)/sum(e.execShares) as price,\n" +
-//        "    max(e.execDatetime) as execTime, min(e.execDatetime) as ordTime, max(e.status)
as status,\n" +
-        "    case when min(e.lastMkt) = max(e.lastMkt) then min(e.lastMkt) else min('XOFF')
end as execMeet\n" +
-        "  from \"repl\".Exec e\n" +
-        "  group by e.date, e.rootOrderId";
-
-    /** Big query "cc" part. */
-    private static final String BQ_CC = 
-        "  select top 1 refOrderId, date from \"part\".Cancel";
-    
     /** Full the big query. */
-    private static final String BIG_QUERY = 
-        "  select * \n" +
-        "  from (\n" +
-             indent2(BQ_COP) +
-        "  ) cop \n" +
-        "  inner join (\n" +
-             indent2(BQ_OEP) +
-        "  ) oep on (cop.date = oep.date and cop.custOrderId = oep.eRootOrderId)\n" +
-        "  left outer join (\n" +
-             indent2(BQ_CC) +
-        "  ) cc on (cc.refOrderId = cop.orderId and cc.date = cop.date)\n" +
-        "  where cop.alias='CUSTOM'";
-
-    /**
-     * @param st String to format.
-     * @return Formatted string.
-     * @see H2CompareBigQueryTest#indent(String, String)
-     */
-    private static String indent1(String st) {
-        return indent(st, "  ");
-    }
+    private static final String BIG_QUERY;
+    
+    static {
+        String res = "";
 
-    /**
-     * @param st String to format.
-     * @return Formatted string.
-     * @see H2CompareBigQueryTest#indent(String, String)
-     */
-    private static String indent2(String st) {
-        return indent(st, "    ");
-    }
+        String file = "src/test/java/org/apache/ignite/internal/processors/query/h2/sql/Bigquery.sql";
 
-    /**
-     * @param st String to format.
-     * @return Formatted string.
-     * @see H2CompareBigQueryTest#indent(String, String)  
-     */
-    private static String indent4(String st) {
-        return indent(st, "        ");
-    }
-
-    /**
-     * Formats string to adding an indent befor each line.
-     *  
-     * @param st String to format.
-     * @param indent Indent.
-     * @return Formatted string. 
-     */
-    private static String indent(String st, String indent) {
-        return indent + st.replace("\n", "\n" + indent) + '\n';
+        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);
+        }
+        
+        BIG_QUERY = res;
     }
-
+        
     /** {@inheritDoc} */
     @Override protected void setIndexedTypes(CacheConfiguration<?, ?> cc, CacheMode
mode) {
         if (mode == CacheMode.PARTITIONED)
@@ -294,35 +222,7 @@ public class H2CompareBigQueryTest extends AbstractH2CompareQueryTest
{
         
         assertTrue(!res.isEmpty()); // Ensure we set good testing data at database.
     }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBigSelect() throws Exception {
-        compareQueryRes0(BSELECT);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBigQueryPart1() throws Exception {
-        compareQueryRes0(BQ_COP);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBigQueryPart2() throws Exception {
-        compareQueryRes0(BQ_OEP);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBigQueryPart3() throws Exception {
-        compareQueryRes0(BQ_CC);
-    }
-
+    
     /** {@inheritDoc} */
     @Override protected void initializeH2Schema() throws SQLException {
         Statement st = conn.createStatement();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6b327fb5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
new file mode 100644
index 0000000..b3f14a5
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/bigQuery.sql
@@ -0,0 +1,38 @@
+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