Skip to content

Commit

Permalink
PHOENIX-3433 Local or view indexes cannot be created after PHOENIX-3254
Browse files Browse the repository at this point in the history
… if namespaces enabled(Rajeshbabu)
  • Loading branch information
chrajeshbabu committed Nov 2, 2016
1 parent effb095 commit 8a44cc0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Expand Up @@ -22,18 +22,23 @@
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.Properties;

import org.apache.phoenix.end2end.ParallelStatsDisabledIT;
import org.apache.phoenix.query.BaseTest;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.util.PropertiesUtil;
import org.apache.phoenix.util.ReadOnlyProps;
import org.apache.phoenix.util.TestUtil;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import com.google.common.collect.Maps;

@RunWith(Parameterized.class)
public abstract class BaseLocalIndexIT extends ParallelStatsDisabledIT {
protected boolean isNamespaceMapped;
Expand All @@ -48,6 +53,15 @@ public void setup() {
schemaName = BaseTest.generateUniqueName();
}

@BeforeClass
public static void doSetup() throws Exception {
Map<String, String> serverProps = Maps.newHashMapWithExpectedSize(7);
serverProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true");
Map<String, String> clientProps = Maps.newHashMapWithExpectedSize(1);
clientProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true");
setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator()));
}

protected Connection getConnection() throws SQLException{
Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES);
props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped));
Expand Down
Expand Up @@ -1436,8 +1436,7 @@ public void createTable(RpcController controller, CreateTableRequest request,
if (parentTable!=null && parentTable.getAutoPartitionSeqName()!=null) {
long autoPartitionNum = 1;
final Properties props = new Properties();
UpgradeUtil.doNotUpgradeOnFirstConnection(props);
try (PhoenixConnection connection = DriverManager.getConnection(MetaDataUtil.getJdbcUrl(env), props).unwrap(PhoenixConnection.class);
try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class);
Statement stmt = connection.createStatement()) {
String seqName = parentTable.getAutoPartitionSeqName();
// Not going through the standard route of using statement.execute() as that code path
Expand Down Expand Up @@ -1504,9 +1503,7 @@ public void createTable(RpcController controller, CreateTableRequest request,
Short indexId = null;
if (request.hasAllocateIndexId() && request.getAllocateIndexId()) {
String tenantIdStr = tenantIdBytes.length == 0 ? null : Bytes.toString(tenantIdBytes);
final Properties props = new Properties();
UpgradeUtil.doNotUpgradeOnFirstConnection(props);
try (PhoenixConnection connection = DriverManager.getConnection(MetaDataUtil.getJdbcUrl(env), props).unwrap(PhoenixConnection.class)){
try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class)){
PName physicalName = parentTable.getPhysicalName();
int nSequenceSaltBuckets = connection.getQueryServices().getSequenceSaltBuckets();
SequenceKey key = MetaDataUtil.getViewIndexSequenceKey(tenantIdStr, physicalName,
Expand Down

0 comments on commit 8a44cc0

Please sign in to comment.