* CREATE TABLE: Added NOT NULL support.
* CREATE TABLE: Ability to specify cache, key type and value type names.
* CREATE TABLE: Added "WRAP_KEY" and "WRAP_VALUE" options to CREATE TABLE command.
+* CREATE TABLE: Added DATA_REGION option.
* CREATE TABLE: Added WRITE_SYNCHRONIZATION_MODE option.
* ALTER TABLE: ADD COLUMN support.
* Added lazy query execution mode (SqlFieldsQuery.setLazy).
* @param templateName Template name.
* @param cacheName Cache name.
* @param cacheGroup Cache group name.
+ * @param dataRegion Data region name.
* @param affinityKey Affinity key column name.
* @param atomicityMode Atomicity mode.
* @param writeSyncMode Write synchronization mode.
*/
@SuppressWarnings("unchecked")
public void dynamicTableCreate(String schemaName, QueryEntity entity, String templateName, String cacheName,
- String cacheGroup, String affinityKey, @Nullable CacheAtomicityMode atomicityMode,
+ String cacheGroup, @Nullable String dataRegion, String affinityKey, @Nullable CacheAtomicityMode atomicityMode,
@Nullable CacheWriteSynchronizationMode writeSyncMode, int backups, boolean ifNotExists)
throws IgniteCheckedException {
assert !F.isEmpty(templateName);
if (!F.isEmpty(cacheGroup))
ccfg.setGroupName(cacheGroup);
+ if (!F.isEmpty(dataRegion))
+ ccfg.setDataRegionName(dataRegion);
+
if (atomicityMode != null)
ccfg.setAtomicityMode(atomicityMode);
throw err;
ctx.query().dynamicTableCreate(cmd.schemaName(), e, cmd.templateName(), cmd.cacheName(),
- cmd.cacheGroup(),cmd.affinityKey(), cmd.atomicityMode(),
+ cmd.cacheGroup(), cmd.dataRegionName(), cmd.affinityKey(), cmd.atomicityMode(),
cmd.writeSynchronizationMode(), cmd.backups(), cmd.ifNotExists());
}
}
/** Forcefully turn single column value into an Object. */
private Boolean wrapVal;
+ /** Data region. */
+ private String dataRegionName;
+
/** Extra WITH-params. */
private List<String> params;
}
/**
+ * @return Data region name.
+ */
+ public String dataRegionName() {
+ return dataRegionName;
+ }
+
+ /**
+ * @param dataRegionName Data region name.
+ */
+ public void dataRegionName(String dataRegionName) {
+ this.dataRegionName = dataRegionName;
+ }
+
+ /**
* @return Extra WITH-params.
*/
public List<String> params() {
/** */
public static final String PARAM_WRAP_VALUE = "WRAP_VALUE";
+ /** Data region name. */
+ public static final String PARAM_DATA_REGION = "DATA_REGION";
+
/** */
private final IdentityHashMap<Object, Object> h2ObjToGridObj = new IdentityHashMap<>();
break;
+ case PARAM_DATA_REGION:
+ ensureNotEmpty(name, val);
+
+ res.dataRegionName(val);
+
+ break;
+
default:
throw new IgniteSQLException("Unsupported parameter: " + name, IgniteQueryErrorCode.PARSING);
}
import org.apache.ignite.cache.QueryIndex;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.binary.BinaryMarshaller;
/** */
private final static String INDEXED_CACHE_NAME_2 = INDEXED_CACHE_NAME + "_2";
+ /** Data region name. */
+ public static final String DATA_REGION_NAME = "my_data_region";
+
+ /** Bad data region name. */
+ public static final String DATA_REGION_NAME_BAD = "my_data_region_bad";
+
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
super.beforeTestsStarted();
e.setKeyType("CityKey");
e.setValueType("City");
- queryProcessor(client()).dynamicTableCreate("PUBLIC", e, CacheMode.PARTITIONED.name(), null, null,
+ queryProcessor(client()).dynamicTableCreate("PUBLIC", e, CacheMode.PARTITIONED.name(), null, null, null,
null, CacheAtomicityMode.ATOMIC, null, 10, false);
return null;
}
/**
+ * Test data region.
+ *
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings({"ThrowableNotThrown", "unchecked"})
+ public void testDataRegion() throws Exception {
+ // Empty region name.
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ execute("CREATE TABLE TEST_DATA_REGION (name varchar primary key, code int) WITH \"data_region=\"");
+
+ return null;
+ }
+ }, IgniteSQLException.class, "Parameter value cannot be empty: DATA_REGION");
+
+ // Valid region name.
+ execute("CREATE TABLE TEST_DATA_REGION (name varchar primary key, code int) WITH \"data_region=" +
+ DATA_REGION_NAME + "\"");
+
+ CacheConfiguration ccfg =
+ client().cache("SQL_PUBLIC_TEST_DATA_REGION").getConfiguration(CacheConfiguration.class);
+
+ assertEquals(DATA_REGION_NAME, ccfg.getDataRegionName());
+ }
+
+
+ /**
* Test various cases of affinity key column specification.
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
private IgniteConfiguration commonConfiguration(int idx) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(getTestIgniteInstanceName(idx));
+ DataRegionConfiguration dataRegionCfg = new DataRegionConfiguration().setName(DATA_REGION_NAME);
+
cfg.setMarshaller(new BinaryMarshaller());
+ cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDataRegionConfigurations(dataRegionCfg));
return optimize(cfg);
}