Github user JamesRTaylor commented on a diff in the pull request: https://github.com/apache/phoenix/pull/127#discussion_r44852801 --- Diff: phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java --- @@ -1607,42 +1680,105 @@ private PTable createTableInternal(CreateTableStatement statement, byte[][] spli addSaltColumn = (saltBucketNum != null); } - boolean removedProp = false; // Can't set MULTI_TENANT or DEFAULT_COLUMN_FAMILY_NAME on an INDEX or a non mapped VIEW if (tableType != PTableType.INDEX && (tableType != PTableType.VIEW || viewType == ViewType.MAPPED)) { - Boolean multiTenantProp = (Boolean) tableProps.remove(PhoenixDatabaseMetaData.MULTI_TENANT); + Boolean multiTenantProp = (Boolean) tableProps.get(PhoenixDatabaseMetaData.MULTI_TENANT); multiTenant = Boolean.TRUE.equals(multiTenantProp); - defaultFamilyName = (String)tableProps.remove(PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME); - removedProp = (defaultFamilyName != null); + defaultFamilyName = (String)tableProps.get(PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME); } boolean disableWAL = false; - Boolean disableWALProp = (Boolean) tableProps.remove(PhoenixDatabaseMetaData.DISABLE_WAL); + Boolean disableWALProp = (Boolean) tableProps.get(PhoenixDatabaseMetaData.DISABLE_WAL); if (disableWALProp != null) { disableWAL = disableWALProp; } - Boolean storeNullsProp = (Boolean) tableProps.remove(PhoenixDatabaseMetaData.STORE_NULLS); - storeNulls = storeNullsProp == null - ? connection.getQueryServices().getProps().getBoolean( - QueryServices.DEFAULT_STORE_NULLS_ATTRIB, - QueryServicesOptions.DEFAULT_STORE_NULLS) - : storeNullsProp; + Boolean storeNullsProp = (Boolean) tableProps.get(PhoenixDatabaseMetaData.STORE_NULLS); + if (storeNullsProp == null) { + if (parent == null) { + storeNulls = connection.getQueryServices().getProps().getBoolean( + QueryServices.DEFAULT_STORE_NULLS_ATTRIB, + QueryServicesOptions.DEFAULT_STORE_NULLS); + tableProps.put(PhoenixDatabaseMetaData.STORE_NULLS, Boolean.valueOf(storeNulls)); + } + } else { + storeNulls = storeNullsProp; + } + Boolean transactionalProp = (Boolean) tableProps.get(PhoenixDatabaseMetaData.TRANSACTIONAL); + if (transactionalProp != null && parent != null) { + throw new SQLExceptionInfo.Builder(SQLExceptionCode.ONLY_TABLE_MAY_BE_DECLARED_TRANSACTIONAL) + .setSchemaName(schemaName).setTableName(tableName) + .build().buildException(); + } + if (parent == null) { + if (transactionalProp == null) { + transactional = connection.getQueryServices().getProps().getBoolean( + QueryServices.DEFAULT_TRANSACTIONAL_ATTRIB, + QueryServicesOptions.DEFAULT_TRANSACTIONAL); + } else { + transactional = transactionalProp; + } + } + tableProps.put(PhoenixDatabaseMetaData.TRANSACTIONAL, transactional); + if (transactional) { + // If TTL set, use Tephra TTL property name instead + Object ttl = commonFamilyProps.remove(HColumnDescriptor.TTL); + if (ttl != null) { + commonFamilyProps.put(TxConstants.PROPERTY_TTL, ttl); + } + } + + boolean sharedTable = statement.getTableType() == PTableType.VIEW || indexId != null; + if (transactional) { + // FIXME: remove once Tephra handles storing multiple versions of a cell value, --- End diff -- Remove this FIXME and replace with this comment: // Tephra uses an empty value cell as its delete marker, so we need to turn on storeNulls for transactional tables. // If we use regular column delete markers (which is what non transactional tables use), then they get converted // on the server, but this can mess up our secondary index code as the changes get committed prior to the // maintenance code being able to see the prior state to update the rows correctly.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---