ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject ignite git commit: IGNITE-5308 .NET: Add "schema" property to SqlFieldsQuery
Date Mon, 05 Jun 2017 14:52:16 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 776cc6e70 -> 3642d6c0d


IGNITE-5308 .NET: Add "schema" property to SqlFieldsQuery


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

Branch: refs/heads/master
Commit: 3642d6c0de956cf8556eb9b31bea4e5b6cf738d1
Parents: 776cc6e
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Mon Jun 5 17:52:10 2017 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Mon Jun 5 17:52:10 2017 +0300

----------------------------------------------------------------------
 .../Cache/Query/CacheLinqTest.cs                | 12 ++++----
 .../Cache/Query/CacheQueriesTest.cs             | 32 ++++++++++++++++++++
 .../Cache/Query/SqlFieldsQuery.cs               | 12 ++++++--
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  2 +-
 4 files changed, 49 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3642d6c0/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
index 04ce965..5d52467 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
@@ -1325,12 +1325,12 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
                   "[Sql=select _T0._KEY, _T0._VAL from \"person_org\".\"Person\" as _T0 where
" +
                   "(_T0.\"_KEY\" > ?), Arguments=[10], " +
                   "Local=True, PageSize=999, EnableDistributedJoins=False, EnforceJoinOrder=True,
" +
-                  "Timeout=00:00:02.5000000, ReplicatedOnly=True, Colocated=True]]"
+                  "Timeout=00:00:02.5000000, ReplicatedOnly=True, Colocated=True, Schema=]]"
                 : "CacheQueryable [CacheName=person_org, TableName=Person, Query=SqlFieldsQuery
" +
                   "[Sql=select _T0._KEY, _T0._VAL from \"person_org\".Person as _T0 where
" +
                   "(_T0._KEY > ?), Arguments=[10], " +
                   "Local=True, PageSize=999, EnableDistributedJoins=False, EnforceJoinOrder=True,
" +
-                  "Timeout=00:00:02.5000000, ReplicatedOnly=True, Colocated=True]]", str);
+                  "Timeout=00:00:02.5000000, ReplicatedOnly=True, Colocated=True, Schema=]]",
str);
 
             // Check fields query
             var fieldsQuery = (ICacheQueryable) cache.AsCacheQueryable().Select(x => x.Value.Name);
@@ -1354,11 +1354,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
                 ? "CacheQueryable [CacheName=person_org, TableName=Person, Query=SqlFieldsQuery
" +
                   "[Sql=select _T0.\"Name\" from \"person_org\".\"Person\" as _T0, Arguments=[],
Local=False, " +
                   "PageSize=1024, EnableDistributedJoins=False, EnforceJoinOrder=False, "
+
-                  "Timeout=00:00:00, ReplicatedOnly=False, Colocated=False]]"
+                  "Timeout=00:00:00, ReplicatedOnly=False, Colocated=False, Schema=]]"
                 : "CacheQueryable [CacheName=person_org, TableName=Person, Query=SqlFieldsQuery
" +
                   "[Sql=select _T0.NAME from \"person_org\".Person as _T0, Arguments=[],
Local=False, " +
                   "PageSize=1024, EnableDistributedJoins=False, EnforceJoinOrder=False, "
+
-                  "Timeout=00:00:00, ReplicatedOnly=False, Colocated=False]]", str);
+                  "Timeout=00:00:00, ReplicatedOnly=False, Colocated=False, Schema=]]", str);
             
             // Check distributed joins flag propagation
             var distrQuery = cache.AsCacheQueryable(new QueryOptions {EnableDistributedJoins
= true})
@@ -1375,13 +1375,13 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
                   "(((_T0.\"_KEY\" > ?) and (_T0.\"age1\" > ?)) " +
                   "and (_T0.\"Name\" like \'%\' || ? || \'%\') ), Arguments=[10, 20, x],
Local=False, " +
                   "PageSize=1024, EnableDistributedJoins=True, EnforceJoinOrder=False, "
+
-                  "Timeout=00:00:00, ReplicatedOnly=False, Colocated=False]]"
+                  "Timeout=00:00:00, ReplicatedOnly=False, Colocated=False, Schema=]]"
                 : "CacheQueryable [CacheName=person_org, TableName=Person, Query=SqlFieldsQuery
" +
                   "[Sql=select _T0._KEY, _T0._VAL from \"person_org\".Person as _T0 where
" +
                   "(((_T0._KEY > ?) and (_T0.AGE1 > ?)) " +
                   "and (_T0.NAME like \'%\' || ? || \'%\') ), Arguments=[10, 20, x], Local=False,
" +
                   "PageSize=1024, EnableDistributedJoins=True, EnforceJoinOrder=False, "
+
-                  "Timeout=00:00:00, ReplicatedOnly=False, Colocated=False]]", str);
+                  "Timeout=00:00:00, ReplicatedOnly=False, Colocated=False, Schema=]]", str);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/3642d6c0/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 60d2fdf..852aa87 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -579,6 +579,38 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
         }
 
         /// <summary>
+        /// Tests custom schema name.
+        /// </summary>
+        [Test]
+        public void TestCustomSchema()
+        {
+            var doubles = GetIgnite().GetOrCreateCache<int, double>(new CacheConfiguration("doubles",
typeof(double)));
+            var strings = GetIgnite().GetOrCreateCache<int, string>(new CacheConfiguration("strings",
typeof(string)));
+
+            doubles[1] = 36.6;
+            strings[1] = "foo";
+
+            // Default schema.
+            var res = doubles.QueryFields(new SqlFieldsQuery(
+                    "select S._val from double as D join \"strings\".string as S on S._key
= D._key"))
+                .Select(x => (string) x[0])
+                .Single();
+
+            Assert.AreEqual("foo", res);
+
+            // Custom schema.
+            res = doubles.QueryFields(new SqlFieldsQuery(
+                    "select S._val from \"doubles\".double as D join string as S on S._key
= D._key")
+                {
+                    Schema = strings.Name
+                })
+                .Select(x => (string)x[0])
+                .Single();
+
+            Assert.AreEqual("foo", res);
+        }
+
+        /// <summary>
         /// Tests the distributed joins flag.
         /// </summary>
         [Test]

http://git-wip-us.apache.org/repos/asf/ignite/blob/3642d6c0/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
index 4809574..aa33415 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
@@ -128,6 +128,14 @@ namespace Apache.Ignite.Core.Cache.Query
         public bool Colocated { get; set; }
 
         /// <summary>
+        /// Gets or sets the default schema name for the query.
+        /// <para />
+        /// If not set, current cache name is used,
+        /// which means you can omit schema name for tables within the current cache.
+        /// </summary>
+        public string Schema { get; set; }
+
+        /// <summary>
         /// Returns a <see cref="string" /> that represents this instance.
         /// </summary>
         /// <returns>
@@ -139,9 +147,9 @@ namespace Apache.Ignite.Core.Cache.Query
 
             return string.Format("SqlFieldsQuery [Sql={0}, Arguments=[{1}], Local={2}, PageSize={3},
" +
                                  "EnableDistributedJoins={4}, EnforceJoinOrder={5}, Timeout={6},
ReplicatedOnly={7}" +
-                                 ", Colocated={8}]", Sql, args, Local,
+                                 ", Colocated={8}, Schema={9}]", Sql, args, Local,
                                  PageSize, EnableDistributedJoins, EnforceJoinOrder, Timeout,
ReplicatedOnly,
-                                 Colocated);
+                                 Colocated, Schema);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3642d6c0/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index e280a8f..b1bf5eb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -1089,7 +1089,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                 writer.WriteInt((int) qry.Timeout.TotalMilliseconds);
                 writer.WriteBoolean(qry.ReplicatedOnly);
                 writer.WriteBoolean(qry.Colocated);
-                writer.WriteString(null); // Schema
+                writer.WriteString(qry.Schema); // Schema
             });
         
             return new FieldsQueryCursor<T>(cursor, Marshaller, _flagKeepBinary, readerFunc);


Mime
View raw message