Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions assembly/dependencies-apache-ignite-lgpl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<includes>
<include>${project.groupId}:ignite-spring</include>
<include>${project.groupId}:ignite-calcite</include>
<include>${project.groupId}:ignite-indexing</include>
<include>${project.groupId}:ignite-control-utility</include>
</includes>
<sources>
Expand Down Expand Up @@ -130,6 +131,7 @@
<exclude>${project.groupId}:ignite-extdata-pluggable</exclude>
<exclude>${project.groupId}:ignite-examples</exclude>
<exclude>${project.groupId}:ignite-calcite</exclude>
<exclude>${project.groupId}:ignite-indexing</exclude>
<exclude>${project.groupId}:ignite-codegen</exclude>
<exclude>${project.groupId}:ignite-appserver-test</exclude>
<exclude>${project.groupId}:ignite-websphere-test</exclude>
Expand Down
2 changes: 2 additions & 0 deletions assembly/dependencies-apache-ignite-slim.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<includes>
<include>${project.groupId}:ignite-spring</include>
<include>${project.groupId}:ignite-calcite</include>
<include>${project.groupId}:ignite-indexing</include>
<include>${project.groupId}:ignite-control-utility</include>
</includes>
<sources>
Expand Down Expand Up @@ -130,6 +131,7 @@
<exclude>${project.groupId}:ignite-extdata-pluggable</exclude>
<exclude>${project.groupId}:ignite-examples</exclude>
<exclude>${project.groupId}:ignite-calcite</exclude>
<exclude>${project.groupId}:ignite-indexing</exclude>
<exclude>${project.groupId}:ignite-codegen</exclude>
<exclude>${project.groupId}:ignite-schedule</exclude>
<exclude>${project.groupId}:ignite-appserver-test</exclude>
Expand Down
2 changes: 2 additions & 0 deletions assembly/dependencies-apache-ignite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<includes>
<include>${project.groupId}:ignite-spring</include>
<include>${project.groupId}:ignite-calcite</include>
<include>${project.groupId}:ignite-indexing</include>
<include>${project.groupId}:ignite-control-utility</include>
</includes>
<sources>
Expand Down Expand Up @@ -131,6 +132,7 @@
<exclude>${project.groupId}:ignite-extdata-pluggable</exclude>
<exclude>${project.groupId}:ignite-examples</exclude>
<exclude>${project.groupId}:ignite-calcite</exclude>
<exclude>${project.groupId}:ignite-indexing</exclude>
<exclude>${project.groupId}:ignite-codegen</exclude>
<exclude>${project.groupId}:ignite-schedule</exclude>
<exclude>${project.groupId}:ignite-appserver-test</exclude>
Expand Down
4 changes: 2 additions & 2 deletions docs/_docs/setup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ Ignite ships with a number of modules and have a lot of extensions that provide
You can enable modules or extensions one by one, as required.

All modules are included in the binary distribution, but by default they
are disabled (except for the `ignite-core`, `ignite-spring`, `ignite-control-utility` and
`ignite-indexing` modules). Modules can be found in the `libs/optional`
are disabled (except for the `ignite-core`, `ignite-spring`, `ignite-control-utility`,
`ignite-calcite` and `ignite-indexing` modules). Modules can be found in the `libs/optional`
directory of the distribution package (each module is located in a
separate sub-directory).

Expand Down
6 changes: 6 additions & 0 deletions modules/calcite-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ignite-spring</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ignite-calcite</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>

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

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="clientMode" value="true"/>
<property name="localHost" value="127.0.0.1"/>
<property name="peerClassLoadingEnabled" value="true"/>

<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>127.0.0.1:47500..47509</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</beans>
57 changes: 57 additions & 0 deletions modules/calcite-testing/src/test/config/jdbc-client-driver-h2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>

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

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="clientMode" value="true"/>
<property name="localHost" value="127.0.0.1"/>
<property name="peerClassLoadingEnabled" value="true"/>

<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>127.0.0.1:47500..47509</value>
</list>
</property>
</bean>
</property>
</bean>
</property>

<property name="sqlConfiguration">
<bean class="org.apache.ignite.configuration.SqlConfiguration">
<property name="queryEnginesConfiguration">
<list>
<bean class="org.apache.ignite.indexing.IndexingQueryEngineConfiguration">
<property name="default" value="true"/>
</bean>
<bean class="org.apache.ignite.calcite.CalciteQueryEngineConfiguration"/>
</list>
</property>
</bean>
</property>
</bean>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void testInvalidConfiguration() {
/** */
@Test
public void testDefaultEngineConfiguration() throws Exception {
checkDefaultEngine(INDEXING_ENGINE);
checkDefaultEngine(CALCITE_ENGINE);

checkDefaultEngine(INDEXING_ENGINE, new IndexingQueryEngineConfiguration(),
new CalciteQueryEngineConfiguration());
Expand Down Expand Up @@ -149,22 +149,28 @@ public void testEngineByHint() throws Exception {
}
}

/** */
/** Without an explicit configuration both engines on the classpath can be selected by name. */
@Test
@SuppressWarnings("ThrowableNotThrown")
public void testEngineWithoutConfiguration() throws Exception {
try (Ignite ignite = startGrid(createConfiguration())) {
IgniteCache<?, ?> cache = ignite.createCache("test");

// Hint can't be used when engines is not configured.
checkEngine(cache, CALCITE_ENGINE, "SELECT QUERY_ENGINE()");
checkEngine(cache, INDEXING_ENGINE, "SELECT /*+ QUERY_ENGINE('" + INDEXING_ENGINE + "') */ QUERY_ENGINE()");
checkEngine(cache, CALCITE_ENGINE, "SELECT /*+ QUERY_ENGINE('" + CALCITE_ENGINE + "') */ QUERY_ENGINE()");

checkJdbcEngine(CALCITE_ENGINE, jdbcUrl, "SELECT QUERY_ENGINE()");
checkJdbcEngine(INDEXING_ENGINE, jdbcUrl + "?queryEngine=" + INDEXING_ENGINE, "SELECT QUERY_ENGINE()");
checkJdbcEngine(CALCITE_ENGINE, jdbcUrl + "?queryEngine=" + CALCITE_ENGINE, "SELECT QUERY_ENGINE()");

// Unknown engine.
GridTestUtils.assertThrowsWithCause(
() -> cache.query(new SqlFieldsQuery(
"SELECT /*+ QUERY_ENGINE('" + INDEXING_ENGINE + "') */ QUERY_ENGINE()")).getAll(),
() -> cache.query(new SqlFieldsQuery("SELECT /*+ QUERY_ENGINE('noop') */ QUERY_ENGINE()")).getAll(),
IgniteException.class);

// JDBC connection property can't be used when engines is not configured.
GridTestUtils.assertThrowsWithCause(
() -> DriverManager.getConnection(jdbcUrl + "?queryEngine=" + INDEXING_ENGINE),
() -> DriverManager.getConnection(jdbcUrl + "?queryEngine=noop"),
SQLException.class);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,25 +480,25 @@ public void testResetPlanHistoryMetrics() throws Exception {
}

/**
* Checks that the actual SQL plan history remains empty and its size in {@link SqlConfiguration} equals {@code -1}
* when SQL is not explicitly configured. In such cases, H2 is used as the default engine.
* Checks that the SQL plan history is enabled with the default size when SQL is not explicitly configured. In such
* cases, both engines are on the classpath and Calcite is used as the default engine.
*/
@Test
public void testNoSqlConfiguration() throws Exception {
isSqlConfigured = false;

checkDefaultHistorySize(true, -1, 0, 1);
checkDefaultHistorySize(true, DFLT_SQL_PLAN_HISTORY_SIZE, DFLT_SQL_PLAN_HISTORY_SIZE, DFLT_SQL_PLAN_HISTORY_SIZE);
}

/**
* Checks that the actual SQL plan history remains empty and its size in {@link SqlConfiguration} equals {@code -1}
* when the SQL engine is not configured. In such cases, H2 is used as the default engine.
* Checks that the SQL plan history is enabled with the default size when the SQL engine is not configured. In such
* cases, both engines are on the classpath and Calcite is used as the default engine.
*/
@Test
public void testNoSqlEngineConfiguration() throws Exception {
isSqlEngineConfigured = false;

checkDefaultHistorySize(true, -1, 0, 1);
checkDefaultHistorySize(true, DFLT_SQL_PLAN_HISTORY_SIZE, DFLT_SQL_PLAN_HISTORY_SIZE, DFLT_SQL_PLAN_HISTORY_SIZE);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* 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.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.calcite.CalciteQueryEngineConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.SqlConfiguration;
import org.apache.ignite.indexing.IndexingQueryEngineConfiguration;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.Parameter;
import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.provider.ValueSource;

/** Checks that the JDBC Client Driver ({@code jdbc:ignite:cfg://}) works with any default SQL engine of the client node it starts. */
@ParameterizedClass(name = "engine={0}")
@ValueSource(strings = {IndexingQueryEngineConfiguration.ENGINE_NAME, CalciteQueryEngineConfiguration.ENGINE_NAME})
public class JdbcClientDriverDefaultEngineTest extends AbstractJdbcTest {
/** Directory with the Spring XML configurations of the client node started by the driver. */
private static final String CFG_DIR = "modules/calcite-testing/src/test/config/";

/** Name of the default engine. */
@Parameter(0)
private String dfltEngine;

/** */
private Connection conn;

/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

if (dfltEngine.equals(IndexingQueryEngineConfiguration.ENGINE_NAME)) {
cfg.setSqlConfiguration(new SqlConfiguration().setQueryEnginesConfiguration(
new IndexingQueryEngineConfiguration().setDefault(true),
new CalciteQueryEngineConfiguration()));
}

return cfg;
}

/** {@inheritDoc} */
@BeforeEach
@Override protected void beforeTest() throws Exception {
startGrid(0);

serverSql("CREATE TABLE test (id INT PRIMARY KEY, val VARCHAR)");
serverSql("INSERT INTO test VALUES (1, 'val1'), (2, 'val2')");

conn = DriverManager.getConnection("jdbc:ignite:cfg://" + CFG_DIR + "jdbc-client-driver-" + dfltEngine + ".xml");

conn.setSchema("PUBLIC");
}

/** {@inheritDoc} */
@AfterEach
@Override protected void afterTest() throws Exception {
U.closeQuiet(conn);

stopAllGrids();
}

/** */
@Test
public void testSelect() throws Exception {
checkEngine();

List<List<Object>> res = executeQuery(conn, "SELECT id, val FROM test ORDER BY id");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also ensure that query_engine is dfltEngine?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check added.


assertEquals(2, res.size());
assertEquals(1, res.get(0).get(0));
assertEquals("val1", res.get(0).get(1));
assertEquals(2, res.get(1).get(0));
assertEquals("val2", res.get(1).get(1));
}

/** */
@Test
public void testDml() throws Exception {
try (Statement stmt = conn.createStatement()) {
assertEquals(1, stmt.executeUpdate("INSERT INTO test VALUES (3, 'val3')"));
}

assertEquals(3L, serverSql("SELECT COUNT(*) FROM test").get(0).get(0));
}

/** Executes a query on the server node with its default engine. */
private List<List<?>> serverSql(String sql) {
return grid(0).context().query().querySqlFields(new SqlFieldsQuery(sql), false).getAll();
}

/** */
private void checkEngine() throws SQLException {
List<List<Object>> res = executeQuery(conn, "SELECT QUERY_ENGINE()");

assertEquals(1, res.size());
assertEquals(dfltEngine, res.get(0).get(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.ignite.internal.processors.query.calcite.integration.SqlPlanHistoryIntegrationTest;
import org.apache.ignite.internal.processors.query.calcite.integration.TimeoutIntegrationTest;
import org.apache.ignite.internal.processors.query.calcite.integration.ViewsIntegrationTest;
import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcClientDriverDefaultEngineTest;
import org.apache.ignite.internal.processors.query.calcite.jdbc.JdbcCrossEngineTest;
import org.apache.ignite.internal.processors.query.calcite.thin.MultiLineQueryTest;
import org.apache.ignite.internal.processors.tx.TxWithExceptionalInterceptorTest;
Expand All @@ -36,6 +37,7 @@
@Suite
@SelectClasses({
JdbcCrossEngineTest.class,
JdbcClientDriverDefaultEngineTest.class,
MultiLineQueryTest.class,
TimeoutIntegrationTest.class,
TxWithExceptionalInterceptorTest.class,
Expand Down
Loading
Loading