You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/04/02 17:49:47 UTC

[GitHub] [ignite] x-kreator opened a new pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateExcepti…

x-kreator opened a new pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateExcepti…
URL: https://github.com/apache/ignite/pull/7615
 
 
   …on if function is used

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] nizhikov merged pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used

Posted by GitBox <gi...@apache.org>.
nizhikov merged pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used
URL: https://github.com/apache/ignite/pull/7615
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] nizhikov commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used
URL: https://github.com/apache/ignite/pull/7615#discussion_r405503487
 
 

 ##########
 File path: modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
 ##########
 @@ -691,36 +691,58 @@ private long streamQuery0(String qry, String schemaName, IgniteDataStreamer stre
         try {
             UpdatePlan plan = dml.plan();
 
-            List<List<?>> planRows = plan.createRows(args != null ? args : X.EMPTY_OBJECT_ARRAY);
+            Object[] params = args != null ? args : X.EMPTY_OBJECT_ARRAY;
+
+            Iterator<List<?>> iter0;
+
+            if (!F.isEmpty(plan.selectQuery())) {
+                SqlFieldsQuery selectQry = new SqlFieldsQuery(plan.selectQuery())
+                    .setArgs(params)
+                    .setLocal(true);
 
 Review comment:
   Why do you think that changes in 6c9a17b is wrong?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] x-kreator commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used

Posted by GitBox <gi...@apache.org>.
x-kreator commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used
URL: https://github.com/apache/ignite/pull/7615#discussion_r405521240
 
 

 ##########
 File path: modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
 ##########
 @@ -691,36 +691,58 @@ private long streamQuery0(String qry, String schemaName, IgniteDataStreamer stre
         try {
             UpdatePlan plan = dml.plan();
 
-            List<List<?>> planRows = plan.createRows(args != null ? args : X.EMPTY_OBJECT_ARRAY);
+            Object[] params = args != null ? args : X.EMPTY_OBJECT_ARRAY;
+
+            Iterator<List<?>> iter0;
+
+            if (!F.isEmpty(plan.selectQuery())) {
+                SqlFieldsQuery selectQry = new SqlFieldsQuery(plan.selectQuery())
+                    .setArgs(params)
+                    .setLocal(true);
 
 Review comment:
   Not all but condition removed from line 816 and assertion added to line 814.
   That assertion was also removed at 1619dd56 (pr #6112).
   Assume that adding of assertion is right, then it's logical to expect that we should meet the changes which fix that assertion failures happening when we use expressions at streaming inserts. But all further changes keep the bug described above till 1619dd56. After 1619dd56 we became to meet the bug described in our issue instead of assertion error.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] nizhikov commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used
URL: https://github.com/apache/ignite/pull/7615#discussion_r403952497
 
 

 ##########
 File path: modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
 ##########
 @@ -691,36 +691,58 @@ private long streamQuery0(String qry, String schemaName, IgniteDataStreamer stre
         try {
             UpdatePlan plan = dml.plan();
 
-            List<List<?>> planRows = plan.createRows(args != null ? args : X.EMPTY_OBJECT_ARRAY);
+            Object[] params = args != null ? args : X.EMPTY_OBJECT_ARRAY;
+
+            Iterator<List<?>> iter0;
+
+            if (!F.isEmpty(plan.selectQuery())) {
+                SqlFieldsQuery selectQry = new SqlFieldsQuery(plan.selectQuery())
+                    .setArgs(params)
+                    .setLocal(true);
 
 Review comment:
   Why this query is always `true`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] x-kreator commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used

Posted by GitBox <gi...@apache.org>.
x-kreator commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used
URL: https://github.com/apache/ignite/pull/7615#discussion_r405371302
 
 

 ##########
 File path: modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
 ##########
 @@ -691,36 +691,58 @@ private long streamQuery0(String qry, String schemaName, IgniteDataStreamer stre
         try {
             UpdatePlan plan = dml.plan();
 
-            List<List<?>> planRows = plan.createRows(args != null ? args : X.EMPTY_OBJECT_ARRAY);
+            Object[] params = args != null ? args : X.EMPTY_OBJECT_ARRAY;
 
 Review comment:
   Done. I had same idea about updateQueryRows method, but I refrained from implementing it earlier due to the fact that some reviewers don't like methods used only once.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] x-kreator commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used

Posted by GitBox <gi...@apache.org>.
x-kreator commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used
URL: https://github.com/apache/ignite/pull/7615#discussion_r405379033
 
 

 ##########
 File path: modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
 ##########
 @@ -691,36 +691,58 @@ private long streamQuery0(String qry, String schemaName, IgniteDataStreamer stre
         try {
             UpdatePlan plan = dml.plan();
 
-            List<List<?>> planRows = plan.createRows(args != null ? args : X.EMPTY_OBJECT_ARRAY);
+            Object[] params = args != null ? args : X.EMPTY_OBJECT_ARRAY;
+
+            Iterator<List<?>> iter0;
+
+            if (!F.isEmpty(plan.selectQuery())) {
+                SqlFieldsQuery selectQry = new SqlFieldsQuery(plan.selectQuery())
+                    .setArgs(params)
+                    .setLocal(true);
 
 Review comment:
   That behavior was implemented before was dropped at commit 6c9a17b4 (pr #6096 by vozerov), so I decided to return it with minimal differences.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] x-kreator commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used

Posted by GitBox <gi...@apache.org>.
x-kreator commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used
URL: https://github.com/apache/ignite/pull/7615#discussion_r405356040
 
 

 ##########
 File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/JdbcSqlStreamingTest.java
 ##########
 @@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.internal.processors.query;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Properties;
+import java.util.UUID;
+import org.apache.ignite.IgniteJdbcThinDriver;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class JdbcSqlStreamingTest extends AbstractIndexingCommonTest {
+    /** */
+    private static final int ROW_NUM = 1600;
+
+    /**
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testStreamingWithFunctionValues() throws Exception {
 
 Review comment:
   Done.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] nizhikov commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used
URL: https://github.com/apache/ignite/pull/7615#discussion_r404003938
 
 

 ##########
 File path: modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
 ##########
 @@ -691,36 +691,58 @@ private long streamQuery0(String qry, String schemaName, IgniteDataStreamer stre
         try {
             UpdatePlan plan = dml.plan();
 
-            List<List<?>> planRows = plan.createRows(args != null ? args : X.EMPTY_OBJECT_ARRAY);
+            Object[] params = args != null ? args : X.EMPTY_OBJECT_ARRAY;
 
 Review comment:
   It seems this piece of code should be rewritten as follows to minimize changes in the code and improve readability:
   
   ```
       private long streamQuery0(String qry, String schemaName, IgniteDataStreamer streamer, QueryParserResultDml dml,
           final Object[] args) throws IgniteCheckedException {
           Long qryId = runningQryMgr.register(qry, GridCacheQueryType.SQL_FIELDS, schemaName, true, null);
   
           Exception failReason = null;
   
           try {
               UpdatePlan plan = dml.plan();
   
               Iterator<List<?>> iter = updateQueryRows(schemaName, plan, args);
   
               if (!iter.hasNext())
                   return 0;
   
               IgniteBiTuple t = plan.processRow(iter.next());
   
               if (!iter.hasNext()) {
                   streamer.addData(t.getKey(), t.getValue());
   
                   return 1;
               }
               else {
                   Map<Object, Object> rows = new LinkedHashMap<>(plan.rowCount());
   
                   rows.put(t.getKey(), t.getValue());
   
                   while (iter.hasNext()) {
                       List<?> row = iter.next();
   
                       t = plan.processRow(row);
   
                       rows.put(t.getKey(), t.getValue());
                   }
   
                   streamer.addData(rows);
   
                   return rows.size();
               }
           }
           catch (IgniteException | IgniteCheckedException e) {
               failReason = e;
   
               throw e;
           }
           finally {
               runningQryMgr.unregister(qryId, failReason);
           }
       }
   
       /**
        * Calculates rows for update query.
        *
        * @param schemaName Schema name.
        * @param plan Update plan.
        * @param args Statement arguments.
        * @return Rows for update.
        * @throws IgniteCheckedException If failed.
        */
       Iterator<List<?>> updateQueryRows(String schemaName, UpdatePlan plan, Object[] args) throws IgniteCheckedException {
           Object[] params = args != null ? args : X.EMPTY_OBJECT_ARRAY;
   
           if (!F.isEmpty(plan.selectQuery())) {
               SqlFieldsQuery selectQry = new SqlFieldsQuery(plan.selectQuery())
                   .setArgs(params)
                   .setLocal(true);
   
               QueryParserResult selectParseRes = parser.parse(schemaName, selectQry, false);
   
               GridQueryFieldsResult res = executeSelectLocal(
                   selectParseRes.queryDescriptor(),
                   selectParseRes.queryParameters(),
                   selectParseRes.select(),
                   null,
                   null,
                   null,
                   false,
                   0
               );
   
               return res.iterator();
           } else
               return plan.createRows(params).iterator();
       }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] nizhikov commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used
URL: https://github.com/apache/ignite/pull/7615#discussion_r403933045
 
 

 ##########
 File path: modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/JdbcSqlStreamingTest.java
 ##########
 @@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.internal.processors.query;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Properties;
+import java.util.UUID;
+import org.apache.ignite.IgniteJdbcThinDriver;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class JdbcSqlStreamingTest extends AbstractIndexingCommonTest {
+    /** */
+    private static final int ROW_NUM = 1600;
+
+    /**
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testStreamingWithFunctionValues() throws Exception {
 
 Review comment:
   Can you, please, rewrite this test using Ignite code style?
   
   https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [ignite] nizhikov commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #7615: IGNITE-12764 Regression: Thin JDBC streaming fails/BatchUpdateException if function is used
URL: https://github.com/apache/ignite/pull/7615#discussion_r403952497
 
 

 ##########
 File path: modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
 ##########
 @@ -691,36 +691,58 @@ private long streamQuery0(String qry, String schemaName, IgniteDataStreamer stre
         try {
             UpdatePlan plan = dml.plan();
 
-            List<List<?>> planRows = plan.createRows(args != null ? args : X.EMPTY_OBJECT_ARRAY);
+            Object[] params = args != null ? args : X.EMPTY_OBJECT_ARRAY;
+
+            Iterator<List<?>> iter0;
+
+            if (!F.isEmpty(plan.selectQuery())) {
+                SqlFieldsQuery selectQry = new SqlFieldsQuery(plan.selectQuery())
+                    .setArgs(params)
+                    .setLocal(true);
 
 Review comment:
   Why this query is always local?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services