apache calcite中关于model文件配置

apache calcite(版本: 1.27.0)中关于model文件配置
1.配置样例

{
  "version": "1.0",
  "defaultSchema": "SALES",
  "schemas": [
    {
      "name": "SALES",
      "type": "custom",
      "factory": "org.apache.calcite.adapter.csv.CsvSchemaFactory",
      "operand": {
        "directory": "sales"
      }
    }
  ]
}

version:Schema模型版本号。 必需,必须具有值“1.0”。
defaultSchema:将成为使用此模型的 Calcite 连接的默认模式的模式名称。可选,区分大小写。 如果指定,则此模型中必须有一个具有此名称的模式。
2.部分源码

public class JsonRoot {
  /** Schema model version number. Required, must have value "1.0". */
  public final String version;

  /** Name of the schema that will become the default schema for connections
   * to Calcite that use this model.
   *
   * <p>Optional, case-sensitive. If specified, there must be a schema in this
   * model with this name.
   */
  public final @Nullable String defaultSchema;

  /** List of schema elements.
   *
   * <p>The list may be empty.
   */
  public final List<JsonSchema> schemas = new ArrayList<>();

  @JsonCreator
  public JsonRoot(
      @JsonProperty(value = "version", required = true) String version,
      @JsonProperty("defaultSchema") @Nullable String defaultSchema) {
    this.version = requireNonNull(version, "version");
    this.defaultSchema = defaultSchema;
  }
}
public abstract class JsonSchema {
  /** Name of the schema.
   *
   * <p>Required.
   *
   * @see JsonRoot#defaultSchema
   */
  public final String name;

  /** SQL path that is used to resolve functions used in this schema.
   *
   * <p>May be null, or a list, each element of which is a string or a
   * string-list.
   *
   * <p>For example,
   *
   * <blockquote><pre>path: [ ['usr', 'lib'], 'lib' ]</pre></blockquote>
   *
   * <p>declares a path with two elements: the schema '/usr/lib' and the schema
   * '/lib'. Most schemas are at the top level, and for these you can use a
   * string.
   */
  public final @Nullable List<Object> path;

  /**
   * List of tables in this schema that are materializations of queries.
   *
   * <p>The list may be empty.
   */
  public final List<JsonMaterialization> materializations = new ArrayList<>();

  public final List<JsonLattice> lattices = new ArrayList<>();

  /** Whether to cache metadata (tables, functions and sub-schemas) generated
   * by this schema. Default value is {@code true}.
   *
   * <p>If {@code false}, Calcite will go back to the schema each time it needs
   * metadata, for example, each time it needs a list of tables in order to
   * validate a query against the schema.</p>
   *
   * <p>If {@code true}, Calcite will cache the metadata the first time it reads
   * it. This can lead to better performance, especially if name-matching is
   * case-insensitive
   * (see {@link org.apache.calcite.config.Lex#caseSensitive}).</p>
   *
   * <p>Tables, functions and sub-schemas explicitly created in a schema are
   * not affected by this caching mechanism. They always appear in the schema
   * immediately, and are never flushed.</p>
   */
  public final @Nullable Boolean cache;

  /** Whether to create lattices in this schema based on queries occurring in
   * other schemas. Default value is {@code false}. */
  public final @Nullable Boolean autoLattice;

  protected JsonSchema(String name, @Nullable List<Object> path, @Nullable Boolean cache,
      @Nullable Boolean autoLattice) {
    this.name = name;
    this.path = path;
    this.cache = cache;
    this.autoLattice = autoLattice;
  }

  public abstract void accept(ModelHandler handler);

  public void visitChildren(ModelHandler modelHandler) {
  }

  /** Built-in schema types. */
  public enum Type {
    MAP,
    JDBC,
    CUSTOM
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值