Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public MutationPlan compile(CreateTableStatement create) throws SQLException {
}
if (viewTypeToBe == ViewType.MAPPED && parentToBe.getPKColumns().isEmpty()) {
validateCreateViewCompilation(connection, parentToBe, columnDefs, pkConstraint);
} else if (where != null && viewTypeToBe == ViewType.UPDATABLE) {
} else if (viewTypeToBe == ViewType.UPDATABLE) {
rowKeyMatcher =
WhereOptimizer.getRowKeyMatcher(context, create.getTableName(), parentToBe, where);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,28 @@ public static byte[] getRowKeyMatcher(final StatementContext context,
PName tenantId = context.getConnection().getTenantId();
boolean isMultiTenant = tenantId != null && parentTable.isMultiTenant();

byte[] tenantIdBytes = tenantId == null
? ByteUtil.EMPTY_BYTE_ARRAY
: ScanUtil.getTenantIdBytes(schema, isSalted, tenantId, isMultiTenant, false);
// Gracefully handle tenant-id encoding failures (e.g., tenant-id type mismatch)
// so that view creation is not blocked; the view will simply have no ROW_KEY_MATCHER.
byte[] tenantIdBytes;
try {
tenantIdBytes = tenantId == null
? ByteUtil.EMPTY_BYTE_ARRAY
: ScanUtil.getTenantIdBytes(schema, isSalted, tenantId, isMultiTenant, false);
} catch (SQLException e) {
tenantIdBytes = ByteUtil.EMPTY_BYTE_ARRAY;
}
if (tenantIdBytes.length != 0) {
rowKeySlotRangesList.add(Arrays.asList(KeyRange.POINT.apply(tenantIdBytes)));
}
// For tenant views without a WHERE clause, return the tenant-id bytes as the
// ROW_KEY_MATCHER so that CompactionScanner can match rows to this view.
if (viewWhereExpression == null) {
if (rowKeySlotRangesList.isEmpty()) {
return ByteUtil.EMPTY_BYTE_ARRAY;
}
ScanRanges scanRange = ScanRanges.createSingleSpan(schema, rowKeySlotRangesList, null, false);
return scanRange.getScanRange().getLowerRange();
}
KeyExpressionVisitor visitor = new KeyExpressionVisitor(context, parentTable);
KeyExpressionVisitor.KeySlots keySlots = viewWhereExpression.accept(visitor);
if (keySlots == null) {
Expand Down
Loading