mihaibudiu commented on code in PR #3692: URL: https://github.com/apache/calcite/pull/3692#discussion_r1494969469
########## core/src/test/java/org/apache/calcite/test/JdbcTest.java: ########## @@ -241,6 +245,55 @@ public class JdbcTest { + "(8,1,4))\n" + " as t(rn,val,expected)"; + public static final String FOODMART_SCOTT_CUSTOM_MODEL = "{\n" + + " version: '1.0',\n" + + " schemas: [\n" + + " {\n" + + " type: 'custom',\n" + + " factory: '" + + JdbcCustomSchemaFactory.class.getName() + + "',\n" + + " name: 'SCOTT'\n" + + " }\n" + + " ]\n" + + "}"; + + + /** + * Tests class fro custom JDBC schema. Review Comment: typo ########## core/src/test/java/org/apache/calcite/test/JdbcTest.java: ########## @@ -241,6 +245,55 @@ public class JdbcTest { + "(8,1,4))\n" + " as t(rn,val,expected)"; + public static final String FOODMART_SCOTT_CUSTOM_MODEL = "{\n" + + " version: '1.0',\n" + + " schemas: [\n" + + " {\n" + + " type: 'custom',\n" + + " factory: '" + + JdbcCustomSchemaFactory.class.getName() + + "',\n" + + " name: 'SCOTT'\n" + + " }\n" + + " ]\n" + + "}"; + + + /** + * Tests class fro custom JDBC schema. + */ + public static class JdbcCustomSchema extends DelegatingSchema implements Wrapper { + + public JdbcCustomSchema(SchemaPlus parentSchema, String name) { + super(JdbcSchema.create(parentSchema, name, getDataSource(), SCOTT.catalog, SCOTT.schema)); + } + + private static DataSource getDataSource() { + return JdbcSchema.dataSource(SCOTT.url, SCOTT.driver, SCOTT.username, SCOTT.password); + } + + @Override public Schema snapshot(SchemaVersion version) { + return this; + } + + @Override public <T extends Object> @Nullable T unwrap(Class<T> clazz) { + if (schema instanceof Wrapper) { + return ((Wrapper) schema).unwrap(clazz); + } + return null; + } + } + + /** + * Tests class fro custom JDBC schema factory. Review Comment: same typo. ########## core/src/test/java/org/apache/calcite/test/JdbcTest.java: ########## @@ -241,6 +245,55 @@ public class JdbcTest { + "(8,1,4))\n" + " as t(rn,val,expected)"; + public static final String FOODMART_SCOTT_CUSTOM_MODEL = "{\n" + + " version: '1.0',\n" + + " schemas: [\n" + + " {\n" + + " type: 'custom',\n" + + " factory: '" + + JdbcCustomSchemaFactory.class.getName() + + "',\n" + + " name: 'SCOTT'\n" + + " }\n" + + " ]\n" + + "}"; + + + /** + * Tests class fro custom JDBC schema. Review Comment: The question I still have: how are users supposed to use the new capabilities you are enabling? Can you add a longer comment giving a recipe for the problem you are solving and how people are supposed to solve it using these tools - pointing them to this example. -- 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: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org