Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHOENIX-5104: breaks client backwards compatibility #544

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -352,6 +352,8 @@ public interface QueryServices extends SQLCloseable {
public static final String GLOBAL_INDEX_ROW_REPAIR_COUNT_ATTRIB = "phoenix.global.index.row.repair.count.ms";
// Enable the IndexRegionObserver Coprocessor
public static final String INDEX_REGION_OBSERVER_ENABLED_ATTRIB = "phoenix.index.region.observer.enabled";
// Enable support for long view index(default is false for clients below version 4)
public static final String LONG_VIEW_INDEX_ENABLED_ATTRIB = "phoenix.index.longViewIndex.enabled";


// Before 4.15 when we created a view we included the parent table column metadata in the view
Expand Down
Expand Up @@ -395,6 +395,7 @@ public class QueryServicesOptions {

public static final String DEFAULT_GUIDE_POSTS_CACHE_FACTORY_CLASS = "org.apache.phoenix.query.DefaultGuidePostsCacheFactory";

public static final boolean DEFAULT_LONG_VIEW_INDEX_ENABLED = false;
private final Configuration config;

private QueryServicesOptions(Configuration config) {
Expand Down
Expand Up @@ -97,6 +97,7 @@
import static org.apache.phoenix.query.QueryConstants.DEFAULT_COLUMN_FAMILY;
import static org.apache.phoenix.query.QueryConstants.ENCODED_CQ_COUNTER_INITIAL_VALUE;
import static org.apache.phoenix.query.QueryServices.DROP_METADATA_ATTRIB;
import static org.apache.phoenix.query.QueryServices.LONG_VIEW_INDEX_ENABLED_ATTRIB;
import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA;
import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_RUN_UPDATE_STATS_ASYNC;
import static org.apache.phoenix.schema.PTable.EncodedCQCounter.NULL_COUNTER;
Expand Down Expand Up @@ -1425,6 +1426,18 @@ public MutationState close(CloseStatement statement) throws SQLException {
return new MutationState(0, 0, connection);
}

/**
* Supprort long viewIndexId only if client has explicitly set
* the QueryServices.LONG_VIEW_INDEX_ENABLED_ATTRIB connection property to 'true'.
* @return
*/
private PDataType getViewIndexDataType() throws SQLException {
boolean supportsLongViewIndexId = connection.getQueryServices().getProps().getBoolean(
QueryServices.LONG_VIEW_INDEX_ENABLED_ATTRIB,
QueryServicesOptions.DEFAULT_LONG_VIEW_INDEX_ENABLED);
return supportsLongViewIndexId ? MetaDataUtil.getViewIndexIdDataType() : MetaDataUtil.getLegacyViewIndexIdDataType();
}

/**
* Create an index table by morphing the CreateIndexStatement into a CreateTableStatement and calling
* MetaDataClient.createTable. In doing so, we perform the following translations:
Expand Down Expand Up @@ -1523,7 +1536,7 @@ public MutationState createIndex(CreateIndexStatement statement, byte[][] splits
*/
if (isLocalIndex || (dataTable.getType() == PTableType.VIEW && dataTable.getViewType() != ViewType.MAPPED)) {
allocateIndexId = true;
PDataType dataType = MetaDataUtil.getViewIndexIdDataType();
PDataType dataType = getViewIndexDataType();
ColumnName colName = ColumnName.caseSensitiveColumnName(MetaDataUtil.getViewIndexIdColumnName());
allPkColumns.add(new ColumnDefInPkConstraint(colName, SortOrder.getDefault(), false));
columnDefs.add(FACTORY.columnDef(colName, dataType.getSqlTypeName(), false, null, null, false, SortOrder.getDefault(), null, false));
Expand Down