You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2016/06/05 22:22:49 UTC
[08/12] calcite git commit: [CALCITE-1259] Allow connecting to a
single schema without writing a model
[CALCITE-1259] Allow connecting to a single schema without writing a model
Instantiate schema factory and a few other classes (JsonCustomTable.table,
JsonCustomSchema.factory, RelJson.class), as plug-ins, which allows
using constant fields rather than a default constructor.
Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/80b05c2a
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/80b05c2a
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/80b05c2a
Branch: refs/heads/master
Commit: 80b05c2a931ecf4134c2c7ff73735f36c8989fbe
Parents: 7fe475a
Author: Julian Hyde <jh...@apache.org>
Authored: Fri May 27 17:07:43 2016 -0700
Committer: Julian Hyde <jh...@apache.org>
Committed: Sat Jun 4 21:35:29 2016 -0700
----------------------------------------------------------------------
.../apache/calcite/adapter/jdbc/JdbcSchema.java | 9 ++-
.../calcite/config/CalciteConnectionConfig.java | 5 ++
.../config/CalciteConnectionConfigImpl.java | 16 ++++
.../config/CalciteConnectionProperty.java | 18 +++++
.../java/org/apache/calcite/jdbc/Driver.java | 58 ++++++++++++-
.../org/apache/calcite/model/JsonSchema.java | 8 ++
.../org/apache/calcite/model/ModelHandler.java | 11 ++-
.../apache/calcite/rel/externalize/RelJson.java | 11 +--
.../calcite/schema/impl/AbstractSchema.java | 14 ++++
.../java/org/apache/calcite/test/JdbcTest.java | 85 ++++++++++++++++++++
site/_docs/adapter.md | 36 +++++++++
11 files changed, 254 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
index b83c76c..41d05d2 100644
--- a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
+++ b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
@@ -16,6 +16,7 @@
*/
package org.apache.calcite.adapter.jdbc;
+import org.apache.calcite.avatica.AvaticaUtils;
import org.apache.calcite.avatica.SqlType;
import org.apache.calcite.linq4j.tree.Expression;
import org.apache.calcite.rel.type.RelDataType;
@@ -115,8 +116,8 @@ public class JdbcSchema implements Schema {
try {
final String dataSourceName = (String) operand.get("dataSource");
if (dataSourceName != null) {
- final Class<?> clazz = Class.forName((String) dataSourceName);
- dataSource = (DataSource) clazz.newInstance();
+ dataSource =
+ AvaticaUtils.instantiatePlugin(DataSource.class, dataSourceName);
} else {
final String jdbcUrl = (String) operand.get("jdbcUrl");
final String jdbcDriver = (String) operand.get("jdbcDriver");
@@ -422,6 +423,10 @@ public class JdbcSchema implements Schema {
* }</pre>
*/
public static class Factory implements SchemaFactory {
+ public static final Factory INSTANCE = new Factory();
+
+ private Factory() {}
+
public Schema create(
SchemaPlus parentSchema,
String name,
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/core/src/main/java/org/apache/calcite/config/CalciteConnectionConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/config/CalciteConnectionConfig.java b/core/src/main/java/org/apache/calcite/config/CalciteConnectionConfig.java
index 24906d3..1c3b0d6 100644
--- a/core/src/main/java/org/apache/calcite/config/CalciteConnectionConfig.java
+++ b/core/src/main/java/org/apache/calcite/config/CalciteConnectionConfig.java
@@ -19,6 +19,7 @@ package org.apache.calcite.config;
import org.apache.calcite.avatica.ConnectionConfig;
import org.apache.calcite.avatica.util.Casing;
import org.apache.calcite.avatica.util.Quoting;
+import org.apache.calcite.model.JsonSchema;
import org.apache.calcite.sql.validate.SqlConformance;
/** Interface for reading connection properties within Calcite code. There is
@@ -47,6 +48,10 @@ public interface CalciteConnectionConfig extends ConnectionConfig {
Casing quotedCasing();
/** @see CalciteConnectionProperty#CASE_SENSITIVE */
boolean caseSensitive();
+ /** @see CalciteConnectionProperty#SCHEMA_FACTORY */
+ <T> T schemaFactory(Class<T> schemaFactoryClass, T defaultSchemaFactory);
+ /** @see CalciteConnectionProperty#SCHEMA_TYPE */
+ JsonSchema.Type schemaType();
/** @see CalciteConnectionProperty#SPARK */
boolean spark();
/** @see CalciteConnectionProperty#FORCE_DECORRELATE */
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/core/src/main/java/org/apache/calcite/config/CalciteConnectionConfigImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/config/CalciteConnectionConfigImpl.java b/core/src/main/java/org/apache/calcite/config/CalciteConnectionConfigImpl.java
index 1f810e2..9af61f5 100644
--- a/core/src/main/java/org/apache/calcite/config/CalciteConnectionConfigImpl.java
+++ b/core/src/main/java/org/apache/calcite/config/CalciteConnectionConfigImpl.java
@@ -19,6 +19,7 @@ package org.apache.calcite.config;
import org.apache.calcite.avatica.ConnectionConfigImpl;
import org.apache.calcite.avatica.util.Casing;
import org.apache.calcite.avatica.util.Quoting;
+import org.apache.calcite.model.JsonSchema;
import org.apache.calcite.sql.SqlOperatorTable;
import org.apache.calcite.sql.fun.OracleSqlOperatorTable;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
@@ -118,6 +119,21 @@ public class CalciteConnectionConfigImpl extends ConnectionConfigImpl
.getBoolean(lex().caseSensitive);
}
+ public <T> T schemaFactory(Class<T> schemaFactoryClass,
+ T defaultSchemaFactory) {
+ return CalciteConnectionProperty.SCHEMA_FACTORY.wrap(properties)
+ .getPlugin(schemaFactoryClass, defaultSchemaFactory);
+ }
+
+ public JsonSchema.Type schemaType() {
+ // Avatica won't allow enum properties whose default is null, so we use
+ // NONE, which is equivalent to null.
+ final JsonSchema.Type type =
+ CalciteConnectionProperty.SCHEMA_TYPE.wrap(properties)
+ .getEnum(JsonSchema.Type.class);
+ return type == null || type == JsonSchema.Type.NONE ? null : type;
+ }
+
public boolean spark() {
return CalciteConnectionProperty.SPARK.wrap(properties).getBoolean();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/core/src/main/java/org/apache/calcite/config/CalciteConnectionProperty.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/config/CalciteConnectionProperty.java b/core/src/main/java/org/apache/calcite/config/CalciteConnectionProperty.java
index b63083c..db88abc 100644
--- a/core/src/main/java/org/apache/calcite/config/CalciteConnectionProperty.java
+++ b/core/src/main/java/org/apache/calcite/config/CalciteConnectionProperty.java
@@ -17,6 +17,7 @@
package org.apache.calcite.config;
import org.apache.calcite.avatica.ConnectionProperty;
+import org.apache.calcite.model.JsonSchema;
import org.apache.calcite.sql.validate.SqlConformance;
import java.util.HashMap;
@@ -78,6 +79,23 @@ public enum CalciteConnectionProperty implements ConnectionProperty {
/** Name of initial schema. */
SCHEMA("schema", Type.STRING, null, false),
+ /** Schema factory.
+ *
+ * <p>The name of a class that implements
+ * {@link org.apache.calcite.schema.SchemaFactory}.
+ *
+ * <p>Ignored if {@link #MODEL} is specified. */
+ SCHEMA_FACTORY("schemaFactory", Type.PLUGIN, null, false),
+
+ /** Schema type.
+ *
+ * <p>Value may be null, "MAP", "JDBC", or "CUSTOM"
+ * (implicit if {@link #SCHEMA_FACTORY} is specified).
+ * The value "NONE" is converted to null.
+ *
+ * <p>Ignored if {@link #MODEL} is specified. */
+ SCHEMA_TYPE("schemaType", Type.ENUM, JsonSchema.Type.NONE, false),
+
/** Specifies whether Spark should be used as the engine for processing that
* cannot be pushed to the source system. If false (the default), Calcite
* generates code that implements the Enumerable interface. */
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/core/src/main/java/org/apache/calcite/jdbc/Driver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/Driver.java b/core/src/main/java/org/apache/calcite/jdbc/Driver.java
index 2014e9f..f8b7ca0 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/Driver.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/Driver.java
@@ -17,6 +17,7 @@
package org.apache.calcite.jdbc;
import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.adapter.jdbc.JdbcSchema;
import org.apache.calcite.avatica.AvaticaConnection;
import org.apache.calcite.avatica.BuiltInConnectionProperty;
import org.apache.calcite.avatica.ConnectionProperty;
@@ -27,7 +28,12 @@ import org.apache.calcite.avatica.Meta;
import org.apache.calcite.avatica.UnregisteredDriver;
import org.apache.calcite.config.CalciteConnectionProperty;
import org.apache.calcite.linq4j.function.Function0;
+import org.apache.calcite.model.JsonSchema;
import org.apache.calcite.model.ModelHandler;
+import org.apache.calcite.schema.SchemaFactory;
+import org.apache.calcite.schema.impl.AbstractSchema;
+import org.apache.calcite.util.JsonBuilder;
+import org.apache.calcite.util.Util;
import java.io.IOException;
import java.sql.SQLException;
@@ -35,6 +41,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
/**
@@ -91,7 +98,7 @@ public class Driver extends UnregisteredDriver {
final CalciteConnectionImpl connection =
(CalciteConnectionImpl) connection_;
super.onConnectionInit(connection);
- final String model = connection.config().model();
+ final String model = model(connection);
if (model != null) {
try {
new ModelHandler(connection, model);
@@ -101,11 +108,58 @@ public class Driver extends UnregisteredDriver {
}
connection.init();
}
+
+ String model(CalciteConnectionImpl connection) {
+ String model = connection.config().model();
+ if (model != null) {
+ return model;
+ }
+ SchemaFactory schemaFactory =
+ connection.config().schemaFactory(SchemaFactory.class, null);
+ final Properties info = connection.getProperties();
+ final String schemaName = Util.first(connection.config().schema(), "adhoc");
+ if (schemaFactory == null) {
+ final JsonSchema.Type schemaType = connection.config().schemaType();
+ if (schemaType != null) {
+ switch (schemaType) {
+ case JDBC:
+ schemaFactory = JdbcSchema.Factory.INSTANCE;
+ break;
+ case MAP:
+ schemaFactory = AbstractSchema.Factory.INSTANCE;
+ break;
+ }
+ }
+ }
+ if (schemaFactory != null) {
+ final JsonBuilder json = new JsonBuilder();
+ final Map<String, Object> root = json.map();
+ root.put("version", "1.0");
+ root.put("defaultSchema", schemaName);
+ final List<Object> schemaList = json.list();
+ root.put("schemas", schemaList);
+ final Map<String, Object> schema = json.map();
+ schemaList.add(schema);
+ schema.put("type", "custom");
+ schema.put("name", schemaName);
+ schema.put("factory", schemaFactory.getClass().getName());
+ final Map<String, Object> operandMap = json.map();
+ schema.put("operand", operandMap);
+ for (Map.Entry<String, String> entry : Util.toMap(info).entrySet()) {
+ if (entry.getKey().startsWith("schema.")) {
+ operandMap.put(entry.getKey().substring("schema.".length()),
+ entry.getValue());
+ }
+ }
+ return "inline:" + json.toJsonString(root);
+ }
+ return null;
+ }
};
}
@Override protected Collection<ConnectionProperty> getConnectionProperties() {
- final List<ConnectionProperty> list = new ArrayList<ConnectionProperty>();
+ final List<ConnectionProperty> list = new ArrayList<>();
Collections.addAll(list, BuiltInConnectionProperty.values());
Collections.addAll(list, CalciteConnectionProperty.values());
return list;
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/core/src/main/java/org/apache/calcite/model/JsonSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonSchema.java b/core/src/main/java/org/apache/calcite/model/JsonSchema.java
index d1c46f1..94ab89d 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonSchema.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonSchema.java
@@ -103,6 +103,14 @@ public abstract class JsonSchema {
jsonMaterialization.accept(modelHandler);
}
}
+
+ /** Built-in schema types. */
+ public enum Type {
+ NONE,
+ MAP,
+ JDBC,
+ CUSTOM
+ }
}
// End JsonSchema.java
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/core/src/main/java/org/apache/calcite/model/ModelHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/ModelHandler.java b/core/src/main/java/org/apache/calcite/model/ModelHandler.java
index f7aa5c6..8b451ee 100644
--- a/core/src/main/java/org/apache/calcite/model/ModelHandler.java
+++ b/core/src/main/java/org/apache/calcite/model/ModelHandler.java
@@ -17,6 +17,7 @@
package org.apache.calcite.model;
import org.apache.calcite.adapter.jdbc.JdbcSchema;
+import org.apache.calcite.avatica.AvaticaUtils;
import org.apache.calcite.jdbc.CalciteConnection;
import org.apache.calcite.jdbc.CalciteSchema;
import org.apache.calcite.materialize.Lattice;
@@ -206,8 +207,9 @@ public class ModelHandler {
public void visit(JsonCustomSchema jsonSchema) {
try {
final SchemaPlus parentSchema = currentMutableSchema("sub-schema");
- final Class clazz = Class.forName(jsonSchema.factory);
- final SchemaFactory schemaFactory = (SchemaFactory) clazz.newInstance();
+ final SchemaFactory schemaFactory =
+ AvaticaUtils.instantiatePlugin(SchemaFactory.class,
+ jsonSchema.factory);
final Schema schema =
schemaFactory.create(
parentSchema, jsonSchema.name, operandMap(jsonSchema.operand));
@@ -331,8 +333,9 @@ public class ModelHandler {
public void visit(JsonCustomTable jsonTable) {
try {
final SchemaPlus schema = currentMutableSchema("table");
- final Class clazz = Class.forName(jsonTable.factory);
- final TableFactory tableFactory = (TableFactory) clazz.newInstance();
+ final TableFactory tableFactory =
+ AvaticaUtils.instantiatePlugin(TableFactory.class,
+ jsonTable.factory);
final Table table =
tableFactory.create(schema, jsonTable.name,
operandMap(jsonTable.operand), null);
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java b/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
index 92324ba..b7ef54a 100644
--- a/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
+++ b/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
@@ -16,6 +16,7 @@
*/
package org.apache.calcite.rel.externalize;
+import org.apache.calcite.avatica.AvaticaUtils;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.rel.RelCollation;
import org.apache.calcite.rel.RelCollationImpl;
@@ -447,15 +448,7 @@ public class RelJson {
}
String class_ = (String) map.get("class");
if (class_ != null) {
- try {
- return (SqlOperator) Class.forName(class_).newInstance();
- } catch (InstantiationException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
+ return AvaticaUtils.instantiatePlugin(SqlOperator.class, class_);
}
return null;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/core/src/main/java/org/apache/calcite/schema/impl/AbstractSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/impl/AbstractSchema.java b/core/src/main/java/org/apache/calcite/schema/impl/AbstractSchema.java
index e917b6e..cf537eb 100644
--- a/core/src/main/java/org/apache/calcite/schema/impl/AbstractSchema.java
+++ b/core/src/main/java/org/apache/calcite/schema/impl/AbstractSchema.java
@@ -19,6 +19,7 @@ package org.apache.calcite.schema.impl;
import org.apache.calcite.linq4j.tree.Expression;
import org.apache.calcite.schema.Function;
import org.apache.calcite.schema.Schema;
+import org.apache.calcite.schema.SchemaFactory;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.Schemas;
import org.apache.calcite.schema.Table;
@@ -136,6 +137,19 @@ public class AbstractSchema implements Schema {
public final Schema getSubSchema(String name) {
return getSubSchemaMap().get(name);
}
+
+ /** Schema factory that creates an
+ * {@link org.apache.calcite.schema.impl.AbstractSchema}. */
+ public static class Factory implements SchemaFactory {
+ public static final Factory INSTANCE = new Factory();
+
+ private Factory() {}
+
+ public Schema create(SchemaPlus parentSchema, String name,
+ Map<String, Object> operand) {
+ return new AbstractSchema();
+ }
+ }
}
// End AbstractSchema.java
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index bab74d6..a200ebb 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -5313,6 +5313,91 @@ public class JdbcTest {
.throws_("Table 'adhoc.EMPLOYEES' not found");
}
+ /** Connects to a custom schema without writing a model.
+ *
+ * <p>Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-1259">[CALCITE-1259]
+ * Allow connecting to a single schema without writing a model</a>. */
+ @Test public void testCustomSchemaDirectConnection() throws Exception {
+ final String url = "jdbc:calcite:"
+ + "schemaFactory=" + MySchemaFactory.class.getName()
+ + "; schema.tableName=ELVIS";
+ checkCustomSchema(url, "adhoc"); // implicit schema is called 'adhoc'
+ checkCustomSchema(url + "; schema=xyz", "xyz"); // explicit schema
+ }
+
+ private void checkCustomSchema(String url, String schemaName) throws SQLException {
+ try (Connection connection = DriverManager.getConnection(url)) {
+ assertThat(connection.getSchema(), is(schemaName));
+ final String sql = "select * from \"" + schemaName + "\".ELVIS where \"deptno\" = 10";
+ final String sql2 = "select * from ELVIS where \"deptno\" = 10";
+ String expected = ""
+ + "empid=100; deptno=10; name=Bill; salary=10000.0; commission=1000\n"
+ + "empid=150; deptno=10; name=Sebastian; salary=7000.0; commission=null\n"
+ + "empid=110; deptno=10; name=Theodore; salary=11500.0; commission=250\n";
+ try (Statement statement = connection.createStatement()) {
+ try (ResultSet resultSet = statement.executeQuery(sql)) {
+ assertThat(CalciteAssert.toString(resultSet), is(expected));
+ }
+ try (ResultSet resultSet = statement.executeQuery(sql2)) {
+ assertThat(CalciteAssert.toString(resultSet), is(expected));
+ }
+ }
+ }
+ }
+
+ /** Connects to a JDBC schema without writing a model. */
+ @Test public void testJdbcSchemaDirectConnection() throws Exception {
+ checkJdbcSchemaDirectConnection(
+ "schemaFactory=org.apache.calcite.adapter.jdbc.JdbcSchema$Factory");
+ checkJdbcSchemaDirectConnection("schemaType=JDBC");
+ }
+
+ private void checkJdbcSchemaDirectConnection(String s) throws SQLException {
+ final StringBuilder b = new StringBuilder("jdbc:calcite:");
+ b.append(s);
+ pv(b, "schema.jdbcUser", SCOTT.username);
+ pv(b, "schema.jdbcPassword", SCOTT.password);
+ pv(b, "schema.jdbcUrl", SCOTT.url);
+ pv(b, "schema.jdbcCatalog", SCOTT.catalog);
+ pv(b, "schema.jdbcDriver", SCOTT.driver);
+ pv(b, "schema.jdbcSchema", SCOTT.schema);
+ final String url = b.toString();
+ Connection connection = DriverManager.getConnection(url);
+ assertThat(connection.getSchema(), is("adhoc"));
+ String expected = "C=14\n";
+ final String sql = "select count(*) as c from emp";
+ try (Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(sql)) {
+ assertThat(CalciteAssert.toString(resultSet), is(expected));
+ }
+ }
+
+ private void pv(StringBuilder b, String p, String v) {
+ if (v != null) {
+ b.append("; ").append(p).append("=").append(v);
+ }
+ }
+
+ /** Connects to a map schema without writing a model. */
+ @Test public void testMapSchemaDirectConnection() throws Exception {
+ checkMapSchemaDirectConnection("schemaType=MAP");
+ checkMapSchemaDirectConnection(
+ "schemaFactory=org.apache.calcite.schema.impl.AbstractSchema$Factory");
+ }
+
+ private void checkMapSchemaDirectConnection(String s) throws SQLException {
+ final String url = "jdbc:calcite:" + s;
+ Connection connection = DriverManager.getConnection(url);
+ assertThat(connection.getSchema(), is("adhoc"));
+ String expected = "EXPR$0=1\n";
+ final String sql = "values 1";
+ try (Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(sql)) {
+ assertThat(CalciteAssert.toString(resultSet), is(expected));
+ }
+ }
+
/** Tests that an immutable schema in a model cannot contain a view. */
@Test public void testModelImmutableSchemaCannotContainView()
throws Exception {
http://git-wip-us.apache.org/repos/asf/calcite/blob/80b05c2a/site/_docs/adapter.md
----------------------------------------------------------------------
diff --git a/site/_docs/adapter.md b/site/_docs/adapter.md
index 01a6995..10cb8f8 100644
--- a/site/_docs/adapter.md
+++ b/site/_docs/adapter.md
@@ -79,8 +79,44 @@ JDBC connect string parameters
| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#MODEL">model</a> | URI of the JSON model file.
| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#QUOTING">quoting</a> | How identifiers are quoted. Values are DOUBLE_QUOTE, BACK_QUOTE, BRACKET. If not specified, value from `lex` is used.
| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#SCHEMA">schema</a> | Name of initial schema.
+| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#SCHEMA_FACTORY">schemaFactory</a> | Schema factory. The name of a class that implements <a href="{{ site.apiRoot }}/org/apache/calcite/schema/SchemaFactory.html">SchemaFactory</a> and has a public default constructor or an `INSTANCE` constant. Ignored if `model` is specified.
+| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#SCHEMA_TYPE">schemaType</a> | Schema type. Value must be "MAP" (the default), "JDBC", or "CUSTOM" (implicit if `schemaFactory` is specified). Ignored if `model` is specified.
| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#SPARK">spark</a> | Specifies whether Spark should be used as the engine for processing that cannot be pushed to the source system. If false (the default), Calcite generates code that implements the Enumerable interface.
| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#TIME_ZONE">timeZone</a> | Time zone, for example "gmt-3". Default is the JVM's time zone.
| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#TYPE_SYSTEM">typeSystem</a> | Type system. The name of a class that implements <a href="{{ site.apiRoot }}/org/apache/calcite/rel/type/RelDataTypeSystem.html">RelDataTypeSystem</a> and has a public default constructor or an `INSTANCE` constant.
| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#UNQUOTED_CASING">unquotedCasing</a> | How identifiers are stored if they are not quoted. Values are UNCHANGED, TO_UPPER, TO_LOWER. If not specified, value from `lex` is used.
+To make a connection to a single schema based on a built-in schema type, you don't need to specify
+a model. For example,
+
+ jdbc:calcite:schemaType=JDBC; schema.jdbcUser=SCOTT; schema.jdbcPassword=TIGER; schema.jdbcUrl=jdbc:hsqldb:res:foodmart
+
+creates a connection with a schema mapped via the JDBC schema adapter to the foodmart database.
+
+Similarly, you can connect to a single schema based on a user-defined schema adapter.
+For example,
+
+ jdbc:calcite:schemaFactory=org.apache.calcite.adapter.cassandra.CassandraSchemaFactory; schema.host=localhost; schema.keyspace=twissandra
+
+makes a connection to the Cassandra adapter, equivalent to writing the following model file:
+
+```json
+{
+ "version": "1.0",
+ "defaultSchema": "foodmart",
+ "schemas": [
+ {
+ type: 'custom',
+ name: 'twissandra',
+ factory: 'org.apache.calcite.adapter.cassandra.CassandraSchemaFactory',
+ operand: {
+ host: 'localhost',
+ keyspace: 'twissandra'
+ }
+ }
+ ]
+}
+
+```
+
+Note how each key in the `operand` section appears with a `schema.` prefix in the connect string.