yuqi1129 commented on code in PR #12577:
URL: https://github.com/apache/gravitino/pull/12577#discussion_r3871758715
##########
core/src/main/java/org/apache/gravitino/storage/relational/mapper/SchemaMetaMapper.java:
##########
@@ -86,6 +87,36 @@ SchemaPO selectSchemaByFullQualifiedName(
@SelectProvider(type = SchemaMetaSQLProviderFactory.class, method =
"selectSchemaMetaById")
SchemaPO selectSchemaMetaById(@Param("schemaId") Long schemaId);
+ /**
+ * Returns one when an active table, view, fileset, function, model, or
topic exists in the
+ * schema, and {@code null} otherwise.
+ *
+ * <p>Only a literal is selected because callers need an existence answer,
not complete child
+ * metadata. The final limit also lets the database stop as soon as it finds
the first child.
+ */
+ @Select({
+ "SELECT 1 FROM "
+ + TableMetaMapper.TABLE_NAME
+ + " WHERE schema_id = #{schemaId} AND deleted_at = 0",
+ "UNION ALL SELECT 1 FROM "
+ + ViewMetaMapper.TABLE_NAME
+ + " WHERE schema_id = #{schemaId} AND deleted_at = 0",
+ "UNION ALL SELECT 1 FROM "
+ + FilesetMetaMapper.META_TABLE_NAME
+ + " WHERE schema_id = #{schemaId} AND deleted_at = 0",
+ "UNION ALL SELECT 1 FROM "
+ + FunctionMetaMapper.TABLE_NAME
+ + " WHERE schema_id = #{schemaId} AND deleted_at = 0",
+ "UNION ALL SELECT 1 FROM "
+ + ModelMetaMapper.TABLE_NAME
+ + " WHERE schema_id = #{schemaId} AND deleted_at = 0",
+ "UNION ALL SELECT 1 FROM "
+ + TopicMetaMapper.TABLE_NAME
+ + " WHERE schema_id = #{schemaId} AND deleted_at = 0",
+ "LIMIT 1"
+ })
Review Comment:
Updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]