Github user JamesRTaylor commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/104#discussion_r36440666
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java ---
@@ -114,6 +116,7 @@ public static Expression
pushKeyExpressionsToScan(StatementContext context, Filt
boolean isMultiTenant = tenantId != null &&
table.isMultiTenant();
if (isMultiTenant) {
tenantId = ScanUtil.padTenantIdIfNecessary(schema,
isSalted, tenantId);
--- End diff --
Take a look at ScanUtil.padTenantIdIfNecessary(), as it assumes tenantId is
a string:
public static PName padTenantIdIfNecessary(RowKeySchema schema, boolean
isSalted, PName tenantId) {
int pkPos = isSalted ? 1 : 0;
String tenantIdStr = tenantId.getString();
Field field = schema.getField(pkPos);
PDataType dataType = field.getDataType();
boolean isFixedWidth = dataType.isFixedWidth();
Integer maxLength = field.getMaxLength();
if (isFixedWidth && maxLength != null) {
if (tenantIdStr.length() < maxLength) {
tenantIdStr = (String)dataType.pad(tenantIdStr, maxLength);
return PNameFactory.newName(tenantIdStr);
}
}
return tenantId;
}
Probably best if your ScanUtil.getTenantIdBytes() function takes into
account padding as well and we can get rid of this util function (see comment
below on that).
---
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 [email protected] or file a JIRA ticket
with INFRA.
---