Skip to content
Merged
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 @@ -4279,8 +4279,12 @@ private void analyzeSelectAllColumns(
.orElseThrow(() -> semanticException(TABLE_NOT_FOUND, allColumns, "Unable to resolve reference %s", prefix));
if (identifierChainBasis.getBasisType() == TABLE) {
RelationType relationType = identifierChainBasis.getRelationType().orElseThrow();
List<Field> fields = filterInaccessibleFields(relationType.resolveVisibleFieldsWithRelationPrefix(Optional.of(prefix)));
List<Field> requestedFields = relationType.resolveVisibleFieldsWithRelationPrefix(Optional.of(prefix));
List<Field> fields = filterInaccessibleFields(requestedFields);
if (fields.isEmpty()) {
if (!requestedFields.isEmpty()) {
throw semanticException(TABLE_NOT_FOUND, allColumns, "Relation not found or not allowed");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should this be AccessDeniedException?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back and forth on this; I left it as not found to:

  • Match current COLUMN_NOT_FOUND error code
  • Leave room for columns to be filtered out not due to access control reasons

However I would be open to change.

}
throw semanticException(COLUMN_NOT_FOUND, allColumns, "SELECT * not allowed from relation that has no columns");
}
boolean local = scope.isLocalScope(identifierChainBasis.getScope().orElseThrow());
Expand All @@ -4305,11 +4309,15 @@ private void analyzeSelectAllColumns(
throw semanticException(NOT_SUPPORTED, allColumns, "Column aliases not supported");
}

List<Field> fields = filterInaccessibleFields((List<Field>) scope.getRelationType().getVisibleFields());
List<Field> requestedFields = (List<Field>) scope.getRelationType().getVisibleFields();
List<Field> fields = filterInaccessibleFields(requestedFields);
if (fields.isEmpty()) {
if (node.getFrom().isEmpty()) {
throw semanticException(COLUMN_NOT_FOUND, allColumns, "SELECT * not allowed in queries without FROM clause");
}
if (!requestedFields.isEmpty()) {
throw semanticException(TABLE_NOT_FOUND, allColumns, "Relation not found or not allowed");
}
throw semanticException(COLUMN_NOT_FOUND, allColumns, "SELECT * not allowed from relation that has no columns");
}

Expand Down