Merge branch 'cassandra-3.11' into trunk

This commit is contained in:
Paulo Motta 2017-08-31 05:18:46 -05:00
commit adf025bd46
5 changed files with 46 additions and 0 deletions

View File

@ -126,6 +126,7 @@
3.11.1
* Revert CASSANDRA-10368 of supporting non-pk column filtering due to correctness (CASSANDRA-13798)
* Add a skip read validation flag to cassandra-stress (CASSANDRA-13772)
* Fix cassandra-stress hang issues when an error during cluster connection happens (CASSANDRA-12938)
* Better bootstrap failure message when blocked by (potential) range movement (CASSANDRA-13744)

View File

@ -73,6 +73,12 @@ Upgrading
Upgrading
---------
- Creating Materialized View with filtering on non-primary-key base column
(added in CASSANDRA-10368) is disabled, because the liveness of view row
is depending on multiple filtered base non-key columns and base non-key
column used in view primary-key. This semantic cannot be supported without
storage format change, see CASSANDRA-13826. For append-only use case, you
may still use this feature with a startup flag: "-Dcassandra.mv.allow_filtering_nonkey_columns_unsafe=true"
- The NativeAccessMBean isAvailable method will only return true if the
native library has been successfully linked. Previously it was returning
true if JNA could be found but was not taking into account link failures.

View File

@ -19,6 +19,7 @@
package org.apache.cassandra.cql3.statements;
import java.util.*;
import java.util.stream.Collectors;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
@ -213,6 +214,20 @@ public class CreateViewStatement extends SchemaAlteringStatement
if (!prepared.boundNames.isEmpty())
throw new InvalidRequestException("Cannot use query parameters in CREATE MATERIALIZED VIEW statements");
// SEE CASSANDRA-13798, use it if the use case is append-only.
final boolean allowFilteringNonKeyColumns = Boolean.parseBoolean(System.getProperty("cassandra.mv.allow_filtering_nonkey_columns_unsafe",
"false"));
if (!restrictions.nonPKRestrictedColumns(false).isEmpty() && !allowFilteringNonKeyColumns)
{
throw new InvalidRequestException(
String.format("Non-primary key columns cannot be restricted in the SELECT statement used"
+ " for materialized view creation (got restrictions on: %s)",
restrictions.nonPKRestrictedColumns(false)
.stream()
.map(def -> def.name.toString())
.collect(Collectors.joining(", "))));
}
String whereClauseText = View.relationsToWhereClause(whereClause.relations);
Set<ColumnIdentifier> basePrimaryKeyCols = new HashSet<>();

View File

@ -21,6 +21,7 @@ package org.apache.cassandra.cql3;
import java.util.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -45,7 +46,15 @@ public class ViewFilteringTest extends CQLTester
public static void startup()
{
requireNetwork();
System.setProperty("cassandra.mv.allow_filtering_nonkey_columns_unsafe", "true");
}
@AfterClass
public static void TearDown()
{
System.setProperty("cassandra.mv.allow_filtering_nonkey_columns_unsafe", "false");
}
@Before
public void begin()
{

View File

@ -684,4 +684,19 @@ public class ViewSchemaTest extends CQLTester
Assert.assertEquals("Cannot use DROP TABLE on Materialized View", e.getMessage());
}
}
@Test
public void testCreateMVWithFilteringOnNonPkColumn() throws Throwable
{
// SEE CASSANDRA-13798, we cannot properly support non-pk base column filtering for mv without huge storage
// format changes.
createTable("CREATE TABLE %s ( a int, b int, c int, d int, PRIMARY KEY (a, b, c))");
executeNet(protocolVersion, "USE " + keyspace());
assertInvalidMessage("Non-primary key columns cannot be restricted in the SELECT statement used for materialized view creation",
"CREATE MATERIALIZED VIEW " + keyspace() + ".mv AS SELECT * FROM %s "
+ "WHERE b IS NOT NULL AND c IS NOT NULL AND a IS NOT NULL "
+ "AND d = 1 PRIMARY KEY (c, b, a)");
}
}