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 2021/01/22 08:53:25 UTC

[GitHub] [ignite] korlov42 commented on a change in pull request #8678: IGNITE-13566

korlov42 commented on a change in pull request #8678:
URL: https://github.com/apache/ignite/pull/8678#discussion_r562028910



##########
File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/TableDescriptorImpl.java
##########
@@ -678,4 +678,11 @@ private FieldDescriptor(GridQueryProperty desc, int fieldIdx) {
             desc.setValue(key0, val0, val);
         }
     }
+
+    /**
+     * @return Type description.
+     */
+    @Override public GridQueryTypeDescriptor typeDescription() {

Review comment:
       ```suggestion
       /** {@inheritDoc} */
       @Override public GridQueryTypeDescriptor typeDescription() {
   ```

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
##########
@@ -2871,6 +2871,10 @@ private void checkxEnabled() throws IgniteException {
         });
     }
 
+    public boolean useExperimentalEngine() {
+        return experimentalQueryEngine != null/* && useExperimentalSqlEngine*/;

Review comment:
       commented code

##########
File path: modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/SqlFieldsQueryUsageTest.java
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.calcite;
+
+import java.util.List;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.AfterClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static java.util.Collections.singletonList;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_EXPERIMENTAL_SQL_ENGINE;
+
+/** */
+@WithSystemProperty(key = IGNITE_EXPERIMENTAL_SQL_ENGINE, value = "true")
+public class SqlFieldsQueryUsageTest extends GridCommonAbstractTest {
+    /** */
+    private static IgniteEx client;
+
+    /** */
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrids(1);
+
+        client = startClientGrid();
+    }
+
+    /** */
+    @AfterClass
+    public static void tearDown() {
+        G.stopAll(false);
+    }
+
+    /**
+     * Temporary redirects create|drop|alter commands into h2 engine.
+     */
+    @Test
+    public void testUseH2Functionality() {
+        execute(grid(0), "CREATE TABLE IF NOT EXISTS Person(\"id\" INT, PRIMARY KEY(\"id\"), \"name\" VARCHAR)");
+
+        execute(grid(0), "alter table Person add column age int");
+        execute(grid(0),"drop table Person");

Review comment:
       ```suggestion
           execute(grid(0), "drop table Person");
   ```

##########
File path: modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/SqlFieldsQueryUsageTest.java
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.calcite;
+
+import java.util.List;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.testframework.junits.WithSystemProperty;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.AfterClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static java.util.Collections.singletonList;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_EXPERIMENTAL_SQL_ENGINE;
+
+/** */
+@WithSystemProperty(key = IGNITE_EXPERIMENTAL_SQL_ENGINE, value = "true")
+public class SqlFieldsQueryUsageTest extends GridCommonAbstractTest {
+    /** */
+    private static IgniteEx client;
+
+    /** */
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrids(1);
+
+        client = startClientGrid();
+    }
+
+    /** */
+    @AfterClass
+    public static void tearDown() {
+        G.stopAll(false);
+    }
+
+    /**
+     * Temporary redirects create|drop|alter commands into h2 engine.
+     */
+    @Test
+    public void testUseH2Functionality() {
+        execute(grid(0), "CREATE TABLE IF NOT EXISTS Person(\"id\" INT, PRIMARY KEY(\"id\"), \"name\" VARCHAR)");
+
+        execute(grid(0), "alter table Person add column age int");
+        execute(grid(0),"drop table Person");
+    }
+
+    /** */
+    @Ignore("https://issues.apache.org/jira/browse/IGNITE-14019")
+    @Test
+    public void createCacheOnSrvCallOnCli() {
+        QueryEntity projEntity = new QueryEntity();
+        projEntity.setKeyType(Integer.class.getName());
+        projEntity.setKeyFieldName("id");
+        projEntity.setValueType(Integer.class.getName());
+        projEntity.addQueryField("id", Integer.class.getName(), null);
+        projEntity.addQueryField("depId", Integer.class.getName(), null);
+
+        projEntity.setTableName("Developer");
+
+        CacheConfiguration<Integer, Integer> projCfg =
+            new CacheConfiguration<Integer, Integer>(projEntity.getTableName())
+                .setQueryEntities(singletonList(projEntity))
+                .setSqlSchema("PUBLIC");
+
+        IgniteCache<Integer, Integer> devCache = grid(0).createCache(projCfg);
+
+        assertFalse(grid(0).configuration().isClientMode());
+
+        devCache.put(1, 2);
+
+        assertEquals(1, execute(client,"SELECT * FROM Developer").size());;

Review comment:
       ```suggestion
           assertEquals(1, execute(client, "SELECT * FROM Developer").size());;
   ```

##########
File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rel/AbstractIndexScan.java
##########
@@ -132,15 +132,15 @@ public String indexName() {
             cost = 0;
 
             if (lowerCondition() != null) {
-                double selectivity0 = mq.getSelectivity(this, RexUtil.composeDisjunction(builder, lowerCondition()));
+                double selectivity0 = mq.getSelectivity(this, RexUtil.composeConjunction(builder, lowerCondition()));
 
                 selectivity -= 1 - selectivity0;
 
                 cost += Math.log(rows);
             }
 
-            if (upperCondition() != null) {
-                double selectivity0 = mq.getSelectivity(this, RexUtil.composeDisjunction(builder, upperCondition()));
+            if (upperCondition() != null && lowerCondition() != null && !lowerCondition().equals(upperCondition())) {

Review comment:
       > !lowerCondition().equals(upperCondition())
   this doesn't work with condition, only with bounds. I think it's be better to leave it as is for now and fix it under https://issues.apache.org/jira/browse/IGNITE-14034




----------------------------------------------------------------
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