kramerul commented on code in PR #4100:
URL: https://github.com/apache/calcite/pull/4100#discussion_r1950429618
##########
core/src/main/java/org/apache/calcite/schema/Schema.java:
##########
@@ -56,9 +59,30 @@
* {@link Schema#getSubSchema(String)}.
*/
public interface Schema {
+
+ /**
+ * Returns a lookup object to find tables.
+ *
+ * @return Lookup
+ */
+ default Lookup<Table> tables() {
+ return new CompatibilityLookup<>(this::getTable, this::getTableNames);
+ }
+
+ /**
+ * Returns a lookup object to find sub schemas.
+ *
+ * @return Lookup
+ */
+ default Lookup<? extends Schema> subSchemas() {
+ return new CompatibilityLookup<>(this::getSubSchema,
this::getSubSchemaNames);
+ }
+
/**
* Returns a table with a given name, or null if not found.
*
+ * <p>Please use {@link Schema#tables()} and {@link Lookup#get(String)}
instead.
Review Comment:
I think that marking this API as deprecated would be the right way. But
doing so might cause trouble for all projects which are using calcite. They
need to change their code to get rid of deprecation warnings.
There is not really a downside to call `getTable`. This PR introduces a new
mechanism to lookup tables and schemas. The old way should be deprecated some
day to get a cleaner `Schema` interface.
--
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]