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 2015/05/29 13:48:35 UTC
svn commit: r1682430 [4/9] - in /incubator/calcite/site: ./ css/ develop/
docs/ downloads/ fonts/ help/ img/ js/ news/ news/2015/ news/2015/01/
news/2015/01/31/ news/2015/01/31/release-1.0.0-incubating/ news/2015/03/
news/2015/03/13/ news/2015/03/13/re...
Added: incubator/calcite/site/docs/howto.html
URL: http://svn.apache.org/viewvc/incubator/calcite/site/docs/howto.html?rev=1682430&view=auto
==============================================================================
--- incubator/calcite/site/docs/howto.html (added)
+++ incubator/calcite/site/docs/howto.html Fri May 29 11:48:34 2015
@@ -0,0 +1,1912 @@
+<!DOCTYPE HTML>
+<html lang="en-US">
+<head>
+ <meta charset="UTF-8">
+ <title>HOWTO</title>
+ <meta name="viewport" content="width=device-width,initial-scale=1">
+ <meta name="generator" content="Jekyll v2.4.0">
+ <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic,900">
+ <link rel="stylesheet" href="/css/screen.css">
+ <link rel="icon" type="image/x-icon" href="/favicon.ico">
+ <!--[if lt IE 9]>
+ <script src="/js/html5shiv.min.js"></script>
+ <script src="/js/respond.min.js"></script>
+ <![endif]-->
+</head>
+
+
+<body class="wrap">
+ <header role="banner">
+ <nav class="mobile-nav show-on-mobiles">
+ <ul>
+ <li class="">
+ <a href="/">Home</a>
+ </li>
+ <li class="current">
+ <a href="/docs/">Documentation</a>
+ </li>
+ <li class="">
+ <a href="/talks/">Talks</a>
+ </li>
+ <li class="">
+ <a href="/news/">News</a>
+ </li>
+ <li class="">
+ <a href="/help/">Help</a>
+ </li>
+ <li class="">
+ <a href="/develop/">Develop</a>
+ </li>
+</ul>
+
+ </nav>
+ <div class="grid">
+ <div class="unit one-third center-on-mobiles">
+ <h1>
+ <a href="/">
+ <span class="sr-only">Apache Calcite</span>
+ <img src="/img/logo.png" width="226" height="140" alt="Calcite Logo">
+ </a>
+ </h1>
+ </div>
+ <nav class="main-nav unit two-thirds hide-on-mobiles">
+ <ul>
+ <li class="">
+ <a href="/">Home</a>
+ </li>
+ <li class="current">
+ <a href="/docs/">Documentation</a>
+ </li>
+ <li class="">
+ <a href="/talks/">Talks</a>
+ </li>
+ <li class="">
+ <a href="/news/">News</a>
+ </li>
+ <li class="">
+ <a href="/help/">Help</a>
+ </li>
+ <li class="">
+ <a href="/develop/">Develop</a>
+ </li>
+</ul>
+
+ </nav>
+ </div>
+</header>
+
+
+ <section class="docs">
+ <div class="grid">
+
+ <div class="docs-nav-mobile unit whole show-on-mobiles">
+ <select onchange="if (this.value) window.location.href=this.value">
+ <option value="">Navigate the docsâ¦</option>
+
+ <optgroup label="Overview">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/index.html">Background</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/tutorial.html">Tutorial</option>
+
+
+
+
+
+
+
+
+
+ <option value="/docs/algebra.html">Algebra</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ <optgroup label="Advanced">
+
+
+
+
+
+
+
+ <option value="/docs/adapter.html">Adapters</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/avatica.html">Avatica</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/stream.html">Streaming</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/lattice.html">Lattices</option>
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ <optgroup label="Reference">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/reference.html">SQL language</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/model.html">JSON models</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/howto.html">HOWTO</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ <optgroup label="Meta">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/downloads.html">Downloads</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/history.html">History</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/contributing.html">Contributing</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/api.html">API</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ </select>
+</div>
+
+
+ <div class="unit four-fifths">
+ <article>
+ <h1>HOWTO</h1>
+ <!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<p>Hereâs some miscellaneous documentation about using Calcite and its various
+adapters.</p>
+
+<h2 id="building-from-a-source-distribution">Building from a source distribution</h2>
+
+<p>Prerequisites are maven (3.2.1 or later)
+and Java (JDK 1.7 or later, 1.8 preferred) on your path.</p>
+
+<p>Unpack the source distribution <code>.tar.gz</code> or <code>.zip</code> file,
+<code>cd</code> to the root directory of the unpacked source,
+then build using maven:</p>
+
+<p><code>bash
+$ tar xvfz calcite-1.3.0-incubating-source.tar.gz
+$ cd calcite-1.3.0-incubating
+$ mvn install
+</code></p>
+
+<p><a href="howto.md#running-tests">Running tests</a> describes how to run more or fewer
+tests.</p>
+
+<h2 id="building-from-git">Building from git</h2>
+
+<p>Prerequisites are git, maven (3.2.1 or later)
+and Java (JDK 1.7 or later, 1.8 preferred) on your path.</p>
+
+<p>Create a local copy of the github repository,
+<code>cd</code> to its root directory,
+then build using maven:</p>
+
+<p><code>bash
+$ git clone git://github.com/apache/incubator-calcite.git
+$ cd incubator-calcite
+$ mvn install
+</code></p>
+
+<p><a href="howto.md#running-tests">Running tests</a> describes how to run more or fewer
+tests.</p>
+
+<h2 id="running-tests">Running tests</h2>
+
+<p>The test suite will run by default when you build, unless you specify
+<code>-DskipTests</code>:</p>
+
+<p><code>bash
+$ mvn clean # Note: mvn clean install does not work, use mvn clean && mvn install
+$ mvn -DskipTests install
+</code></p>
+
+<p>There are other options that control which tests are run, and in what
+environment, as follows.</p>
+
+<ul>
+ <li><code>-Dcalcite.test.db=DB</code> (where db is <code>h2</code>, <code>hsqldb</code>, <code>mysql</code>, or <code>postgresql</code>) allows you
+to change the JDBC data source for the test suite. Calciteâs test
+suite requires a JDBC data source populated with the foodmart data
+set.
+ <ul>
+ <li><code>hsqldb</code>, the default, uses an in-memory hsqldb database.</li>
+ <li>all others access test virtual machine (see <a href="howto.md#running-integration-tests">integration tests</a> below)
+<code>mysql</code> and <code>postgresql</code> might be somewhat faster than hsqldb, but you need to populate it (i.e. provision a VM).</li>
+ </ul>
+ </li>
+ <li><code>-Dcalcite.debug</code> prints extra debugging information to stdout.</li>
+ <li><code>-Dcalcite.test.slow</code> enables tests that take longer to execute. For
+example, there are tests that create virtual TPC-H and TPC-DS schemas
+in-memory and run tests from those benchmarks.</li>
+ <li><code>-Dcalcite.test.splunk=true</code> enables tests that run against Splunk.
+Splunk must be installed and running.</li>
+</ul>
+
+<h2 id="running-integration-tests">Running integration tests</h2>
+
+<p>For testing Calciteâs external adapters, a test virtual machine should be used.
+The VM includes H2, HSQLDB, MySQL, MongoDB, and PostgreSQL.</p>
+
+<p>Test VM requires 5GiB of disk space and it takes 30 minutes to build.</p>
+
+<p>Note: you can use <a href="https://github.com/vlsi/calcite-test-dataset">calcite-test-dataset</a>
+ to populate your own database, however it is recommended to use test VM so the test environment can be reproduced.</p>
+
+<h3 id="vm-preparation">VM preparation</h3>
+
+<p>0) Install dependencies: <a href="https://www.vagrantup.com/">Vagrant</a> and <a href="https://www.virtualbox.org/">VirtualBox</a></p>
+
+<p>1) Clone https://github.com/vlsi/calcite-test-dataset.git at the same level as calcite repository.
+For instance:
+<code>bash
+code
+ +-- calcite
+ +-- calcite-test-dataset
+</code></p>
+
+<p>Note: integration tests search for ../calcite-test-dataset or ../../calcite-test-dataset.
+ You can specify full path via calcite.test.dataset system property.</p>
+
+<p>2) Build and start the VM:
+<code>bash
+cd calcite-test-dataset && mvn install
+</code></p>
+
+<h3 id="vm-management">VM management</h3>
+
+<p>Test VM is provisioned by Vagrant, so regular Vagrant <code>vagrant up</code> and <code>vagrant halt</code> should be used to start and stop the VM.
+The connection strings for different databases are listed in <a href="https://github.com/vlsi/calcite-test-dataset">calcite-test-dataset</a> readme.</p>
+
+<h3 id="suggested-test-flow">Suggested test flow</h3>
+
+<p>Note: test VM should be started before you launch integration tests. Calcite itself does not start/stop the VM.</p>
+
+<p>Command line:
+* Executing regular unit tests (does not require external data): no change. <code>mvn test</code> or <code>mvn install</code>.
+* Executing all tests, for all the DBs: <code>mvn verify -Pit</code>. <code>it</code> stands for âintegration-testâ. <code>mvn install -Pit</code> works as well.
+* Executing just tests for external DBs, excluding unit tests: <code>mvn -Dtest=foo -DfailIfNoTests=false -Pit verify</code>
+* Executing just MongoDB tests: <code>cd mongo; mvn verify -Pit</code></p>
+
+<p>From within IDE:
+* Executing regular unit tests: no change.
+* Executing MongoDB tests: run <code>MongoAdapterIT.java</code> as usual (no additional properties are required)
+* Executing MySQL tests: run <code>JdbcTest</code> and <code>JdbcAdapterTest</code> with setting <code>-Dcalcite.test.db=mysql</code>
+* Executing PostgreSQL tests: run <code>JdbcTest</code> and <code>JdbcAdapterTest</code> with setting <code>-Dcalcite.test.db=postgresql</code></p>
+
+<h3 id="integration-tests-technical-details">Integration tests technical details</h3>
+
+<p>Tests with external data are executed at mavenâs integration-test phase.
+We do not currently use pre-integration-test/post-integration-test, however we could use that in future.
+The verification of build pass/failure is performed at verify phase.
+Integration tests should be named <code>...IT.java</code>, so they are not picked up on unit test execution.</p>
+
+<h2 id="contributing">Contributing</h2>
+
+<p>We welcome contributions.</p>
+
+<p>If you are planning to make a large contribution, talk to us first! It
+helps to agree on the general approach. Log a
+<a href="https://issues.apache.org/jira/browse/CALCITE">JIRA case</a> for your
+proposed feature or start a discussion on the dev list.</p>
+
+<p>Fork the github repository, and create a branch for your feature.</p>
+
+<p>Develop your feature and test cases, and make sure that <code>mvn
+install</code> succeeds. (Run extra tests if your change warrants it.)</p>
+
+<p>Commit your change to your branch, and use a comment that starts with
+the JIRA case number, like this:</p>
+
+<p><code>
+[CALCITE-345] AssertionError in RexToLixTranslator comparing to date literal
+</code></p>
+
+<p>If your change had multiple commits, use <code>git rebase -i master</code> to
+combine them into a single commit, and to bring your code up to date
+with the latest on the main line.</p>
+
+<p>Then push your commit(s) to github, and create a pull request from
+your branch to the incubator-calcite master branch. Update the JIRA case
+to reference your pull request, and a committer will review your
+changes.</p>
+
+<h2 id="getting-started">Getting started</h2>
+
+<p>Calcite is a community, so the first step to joining the project is to introduce yourself.
+Join the <a href="http://mail-archives.apache.org/mod_mbox/incubator-calcite-dev/">developers list</a>
+and send an email.</p>
+
+<p>If you have the chance to attend a <a href="http://www.meetup.com/Apache-Calcite/">meetup</a>,
+or meet <a href="http://calcite.incubator.apache.org/team-list.html">members of the community</a>
+at a conference, thatâs also great.</p>
+
+<p>Choose an initial task to work on. It should be something really simple,
+such as a bug fix or a <a href="https://issues.apache.org/jira/issues/?jql=labels%20%3D%20newbie%20%26%20project%20%3D%20Calcite%20%26%20status%20%3D%20Open">Jira task that we have labeled
+ânewbieâ</a>.
+Follow the <a href="#contributing">contributing guidelines</a> to get your change committed.</p>
+
+<p>After you have made several useful contributions we may
+<a href="https://community.apache.org/contributors/">invite you to become a committer</a>.
+We value all contributions that help to build a vibrant community, not just code.
+You can contribute by testing the code, helping verify a release,
+writing documentation or the web site,
+or just by answering questions on the list.</p>
+
+<h2 id="tracing">Tracing</h2>
+
+<p>To enable tracing, add the following flags to the java command line:</p>
+
+<p><code>
+-Dcalcite.debug=true -Djava.util.logging.config.file=core/src/test/resources/logging.properties
+</code></p>
+
+<p>The first flag causes Calcite to print the Java code it generates
+(to execute queries) to stdout. It is especially useful if you are debugging
+mysterious problems like this:</p>
+
+<p><code>
+Exception in thread "main" java.lang.ClassCastException: Integer cannot be cast to Long
+ at Baz$1$1.current(Unknown Source)
+</code></p>
+
+<p>The second flag specifies a config file for
+the <a href="http://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html">java.util.logging</a>
+framework. Put the following into core/src/test/resources/logging.properties:</p>
+
+<p><code>properties
+handlers= java.util.logging.ConsoleHandler
+.level= INFO
+org.apache.calcite.plan.RelOptPlanner.level=FINER
+java.util.logging.ConsoleHandler.level=ALL
+</code></p>
+
+<p>The line <code>org.apache.calcite.plan.RelOptPlanner.level=FINER</code> tells the planner to produce
+fairly verbose output. You can modify the file to enable other loggers, or to change levels.
+For instance, if you change <code>FINER</code> to <code>FINEST</code> the planner will give you an account of the
+planning process so detailed that it might fill up your hard drive.</p>
+
+<h2 id="csv-adapter">CSV adapter</h2>
+
+<p>See the <a href="tutorial.md">tutorial</a>.</p>
+
+<h2 id="mongodb-adapter">MongoDB adapter</h2>
+
+<p>First, download and install Calcite,
+and <a href="http://www.mongodb.org/downloads">install MongoDB</a>.</p>
+
+<p>Note: you can use MongoDB from integration test virtual machine above.</p>
+
+<p>Import MongoDBâs zipcode data set into MongoDB:</p>
+
+<p><code>bash
+$ curl -o /tmp/zips.json http://media.mongodb.org/zips.json
+$ mongoimport --db test --collection zips --file /tmp/zips.json
+Tue Jun 4 16:24:14.190 check 9 29470
+Tue Jun 4 16:24:14.469 imported 29470 objects
+</code></p>
+
+<p>Log into MongoDB to check itâs there:</p>
+
+<p><code>bash
+$ mongo
+MongoDB shell version: 2.4.3
+connecting to: test
+> db.zips.find().limit(3)
+{ "city" : "ACMAR", "loc" : [ -86.51557, 33.584132 ], "pop" : 6055, "state" : "AL", "_id" : "35004" }
+{ "city" : "ADAMSVILLE", "loc" : [ -86.959727, 33.588437 ], "pop" : 10616, "state" : "AL", "_id" : "35005" }
+{ "city" : "ADGER", "loc" : [ -87.167455, 33.434277 ], "pop" : 3205, "state" : "AL", "_id" : "35006" }
+> exit
+bye
+</code></p>
+
+<p>Connect using the
+<a href="https://github.com/apache/incubator-calcite/blob/master/mongodb/src/test/resources/mongo-zips-model.json">mongo-zips-model.json</a>
+Calcite model:
+<code>bash
+$ ./sqlline
+sqlline> !connect jdbc:calcite:model=mongodb/target/test-classes/mongo-zips-model.json admin admin
+Connecting to jdbc:calcite:model=mongodb/target/test-classes/mongo-zips-model.json
+Connected to: Calcite (version 1.x.x)
+Driver: Calcite JDBC Driver (version 1.x.x)
+Autocommit status: true
+Transaction isolation: TRANSACTION_REPEATABLE_READ
+sqlline> !tables
++------------+--------------+-----------------+---------------+
+| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE |
++------------+--------------+-----------------+---------------+
+| null | mongo_raw | zips | TABLE |
+| null | mongo_raw | system.indexes | TABLE |
+| null | mongo | ZIPS | VIEW |
+| null | metadata | COLUMNS | SYSTEM_TABLE |
+| null | metadata | TABLES | SYSTEM_TABLE |
++------------+--------------+-----------------+---------------+
+sqlline> select count(*) from zips;
++---------+
+| EXPR$0 |
++---------+
+| 29467 |
++---------+
+1 row selected (0.746 seconds)
+sqlline> !quit
+Closing: org.apache.calcite.jdbc.FactoryJdbc41$CalciteConnectionJdbc41
+$
+</code></p>
+
+<h2 id="splunk-adapter">Splunk adapter</h2>
+
+<p>To run the test suite and sample queries against Splunk,
+load Splunkâs <code>tutorialdata.zip</code> data set as described in
+<a href="http://docs.splunk.com/Documentation/Splunk/6.0.2/PivotTutorial/GetthetutorialdataintoSplunk">the Splunk tutorial</a>.</p>
+
+<p>(This step is optional, but it provides some interesting data for the sample
+queries. It is also necessary if you intend to run the test suite, using
+<code>-Dcalcite.test.splunk=true</code>.)</p>
+
+<h2 id="implementing-an-adapter">Implementing an adapter</h2>
+
+<p>New adapters can be created by implementing <code>CalcitePrepare.Context</code>:</p>
+
+<p>```java
+import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.jdbc.CalcitePrepare;
+import org.apache.calcite.jdbc.CalciteRootSchema;</p>
+
+<p>public class AdapterContext implements CalcitePrepare.Context {
+ @Override
+ public JavaTypeFactory getTypeFactory() {
+ // adapter implementation
+ return typeFactory;
+ }</p>
+
+<p>@Override
+ public CalciteRootSchema getRootSchema() {
+ // adapter implementation
+ return rootSchema;
+ }
+}
+```</p>
+
+<h3 id="testing-adapter-in-java">Testing adapter in Java</h3>
+
+<p>The example below shows how SQL query can be submitted to
+<code>CalcitePrepare</code> with a custom context (<code>AdapterContext</code> in this
+case). Calcite prepares and implements the query execution, using the
+resources provided by the <code>Context</code>. <code>CalcitePrepare.PrepareResult</code>
+provides access to the underlying enumerable and methods for
+enumeration. The enumerable itself can naturally be some adapter
+specific implementation.</p>
+
+<p>```java
+import org.apache.calcite.jdbc.CalcitePrepare;
+import org.apache.calcite.prepare.CalcitePrepareImpl;
+import org.junit.Test;</p>
+
+<p>public class AdapterContextTest {
+ @Test
+ public void testSelectAllFromTable() {
+ AdapterContext ctx = new AdapterContext();
+ String sql = âSELECT * FROM TABLENAMEâ;
+ Class elementType = Object[].class;
+ CalcitePrepare.PrepareResult<object> prepared =
+ new CalcitePrepareImpl().prepareSql(ctx, sql, null, elementType, -1);
+ Object enumerable = prepared.getExecutable();
+ // etc.
+ }
+}
+```</object></p>
+
+<h3 id="javatypefactory">JavaTypeFactory</h3>
+
+<p>When Calcite compares types (instances of <code>RelDataType</code>), it requires them to be the same
+object. If there are two distinct type instances that refer to the
+same Java type, Calcite may fail to recognize that they match. It is
+recommended to:
+* Use a single instance of <code>JavaTypeFactory</code> within the calcite context;
+* Store the types so that the same object is always returned for the same type.</p>
+
+<h2 id="set-up-pgp-signing-keys-for-calcite-committers">Set up PGP signing keys (for Calcite committers)</h2>
+
+<p>Follow instructions at http://www.apache.org/dev/release-signing to
+create a key pair. (On Mac OS X, I did <code>brew install gpg</code> and <code>gpg
+--gen-key</code>.)</p>
+
+<p>Add your public key to the <code>KEYS</code> file by following instructions in
+the <code>KEYS</code> file.</p>
+
+<h2 id="making-a-snapshot-for-calcite-committers">Making a snapshot (for Calcite committers)</h2>
+
+<p>Before you start:
+* Set up signing keys as described above.
+* Make sure you are using JDK 1.7 (not 1.8).
+* Make sure build and tests succeed with <code>-Dcalcite.test.db=hsqldb</code> (the default)</p>
+
+<p>```bash
+# Set passphrase variable without putting it into shell history
+read -s GPG_PASSPHRASE</p>
+
+<h1 id="make-sure-that-there-are-no-junk-files-in-the-sandbox">Make sure that there are no junk files in the sandbox</h1>
+<p>git clean -xn
+mvn clean</p>
+
+<p>mvn -Papache-release -Dgpg.passphrase=${GPG_PASSPHRASE} install
+```</p>
+
+<p>When the dry-run has succeeded, change <code>install</code> to <code>deploy</code>.</p>
+
+<h2 id="making-a-release-for-calcite-committers">Making a release (for Calcite committers)</h2>
+
+<p>Before you start:
+* Set up signing keys as described above.
+* Make sure you are using JDK 1.7 (not 1.8).
+* Check that <code>README</code>, <code>README.md</code> and <code>doc/howto.md</code> have the correct version number.
+* Set <code>version.major</code> and <code>version.minor</code> in <code>pom.xml</code>.
+* Make sure build and tests succeed, including with
+ -Dcalcite.test.db={mysql,hsqldb}, -Dcalcite.test.slow=true,
+ -Dcalcite.test.mongodb=true, -Dcalcite.test.splunk=true.
+* Trigger a
+ <a href="https://scan.coverity.com/projects/2966">Coverity scan</a>
+ by merging the latest code into the <code>julianhyde/coverity_scan</code> branch,
+ and when it completes, make sure that there are no important issues.
+* Make sure that
+ <a href="https://issues.apache.org/jira/issues/?jql=project%20%3D%20CALCITE%20AND%20status%20%3D%20Resolved%20and%20fixVersion%20is%20null">
+ every âresolvedâ JIRA case</a> (including duplicates) has
+ a fix version assigned (most likely the version we are
+ just about to release)</p>
+
+<p>Create a release branch named after the release, e.g. <code>branch-1.1</code>, and push it to Apache.</p>
+
+<p><code>bash
+$ git checkout -b branch-X.Y
+$ git push -u origin branch-X.Y
+</code></p>
+
+<p>We will use the branch for the entire the release process. Meanwhile,
+we do not allow commits to the master branch. After the release is
+final, we can use <code>git merge --ff-only</code> to append the changes on the
+release branch onto the master branch. (Apache does not allow reverts
+to the master branch, which makes it difficult to clean up the kind of
+messy commits that inevitably happen while you are trying to finalize
+a release.)</p>
+
+<p>Now, set up your environment and do a dry run. The dry run will not
+commit any changes back to git and gives you the opportunity to verify
+that the release process will complete as expected.</p>
+
+<p>If any of the steps fail, clean up (see below), fix the problem, and
+start again from the top.</p>
+
+<p>```bash
+# Set passphrase variable without putting it into shell history
+read -s GPG_PASSPHRASE</p>
+
+<h1 id="make-sure-that-there-are-no-junk-files-in-the-sandbox-1">Make sure that there are no junk files in the sandbox</h1>
+<p>git clean -xn
+mvn clean</p>
+
+<h1 id="do-a-dry-run-of-the-releaseprepare-step-which-sets-version-numbers">Do a dry run of the release:prepare step, which sets version numbers.</h1>
+<p>mvn -DdryRun=true -DskipTests -DreleaseVersion=X.Y.Z-incubating -DdevelopmentVersion=X.Y.Z+1-incubating-SNAPSHOT -Papache-release -Darguments=â-Dgpg.passphrase=${GPG_PASSPHRASE}â release:prepare 2>&1 | tee /tmp/prepare-dry.log
+```</p>
+
+<p>Check the artifacts:
+* In the <code>target</code> directory should be these 8 files, among others:
+ * apache-calcite-X.Y.Z-incubating-src.tar.gz
+ * apache-calcite-X.Y.Z-incubating-src.tar.gz.asc
+ * apache-calcite-X.Y.Z-incubating-src.tar.gz.md5
+ * apache-calcite-X.Y.Z-incubating-src.tar.gz.sha1
+ * apache-calcite-X.Y.Z-incubating-src.zip
+ * apache-calcite-X.Y.Z-incubating-src.zip.asc
+ * apache-calcite-X.Y.Z-incubating-src.zip.md5
+ * apache-calcite-X.Y.Z-incubating-src.zip.sha1
+* Note that the file names start <code>apache-calcite-</code> and include
+ <code>incubating</code> in the version.
+* In the two source distros <code>.tar.gz</code> and <code>.zip</code> (currently there is
+ no binary distro), check that all files belong to a directory called
+ <code>apache-calcite-X.Y.Z-incubating-src</code>.
+* That directory must contain files <code>DISCLAIMER</code>, <code>NOTICE</code>, <code>LICENSE</code>,
+ <code>README</code>, <code>README.md</code>
+ * Check that the version in <code>README</code> is correct
+* In each .jar (for example
+ <code>core/target/calcite-core-X.Y.Z-incubating.jar</code> and
+ <code>mongodb/target/calcite-mongodb-X.Y.Z-incubating-sources.jar</code>), check
+ that the <code>META-INF</code> directory contains <code>DEPENDENCIES</code>, <code>LICENSE</code>,
+ <code>NOTICE</code> and <code>git.properties</code>
+* In each .jar, check that <code>org-apache-calcite-jdbc.properties</code> is
+ present and does not contain un-substituted <code>${...}</code> variables
+* Check PGP, per https://httpd.apache.org/dev/verification.html</p>
+
+<p>Now, remove the <code>-DdryRun</code> flag and run the release for real.</p>
+
+<p>```bash
+# Prepare sets the version numbers, creates a tag, and pushes it to git.
+mvn -DdryRun=false -DskipTests -DreleaseVersion=X.Y.Z-incubating -DdevelopmentVersion=X.Y.Z+1-incubating-SNAPSHOT -Papache-release -Darguments=â-Dgpg.passphrase=${GPG_PASSPHRASE}â release:prepare 2>&1 | tee /tmp/prepare.log</p>
+
+<h1 id="perform-checks-out-the-tagged-version-builds-and-deploys-to-the-staging-repository">Perform checks out the tagged version, builds, and deploys to the staging repository</h1>
+<p>mvn -DskipTests -Papache-release -Darguments=â-Dgpg.passphrase=${GPG_PASSPHRASE}â release:perform 2>&1 | tee /tmp/perform.log
+```</p>
+
+<p>Verify the staged artifacts in the Nexus repository:
+* Go to https://repository.apache.org/
+* Under <code>Build Promotion</code>, click <code>Staging Repositories</code>
+* In the <code>Staging Repositories</code> tab there should be a line with profile <code>org.apache.calcite</code>
+* Navigate through the artifact tree and make sure the .jar, .pom, .asc files are present
+* Check the box on in the first column of the row,
+ and press the âCloseâ button to publish the repository at
+ https://repository.apache.org/content/repositories/orgapachecalcite-1000
+ (or a similar URL)</p>
+
+<p>Upload the artifacts via subversion to a staging area,
+https://dist.apache.org/repos/dist/dev/incubator/calcite/apache-calcite-X.Y.Z-incubating-rcN:</p>
+
+<p>```bash
+# Create a subversion workspace, if you havenât already
+mkdir -p ~/dist/dev
+pushd ~/dist/dev
+svn co https://dist.apache.org/repos/dist/dev/incubator/calcite
+popd</p>
+
+<h1 id="move-the-files-into-a-directory">Move the files into a directory</h1>
+<p>cd target
+mkdir ~/dist/dev/calcite/apache-calcite-X.Y.Z-incubating-rcN
+mv apache-calcite-* ~/dist/dev/calcite/apache-calcite-X.Y.Z-incubating-rcN</p>
+
+<h1 id="check-in">Check in</h1>
+<p>cd ~/dist/dev/calcite
+svn add apache-calcite-X.Y.Z-incubating-rcN
+svn ci
+```</p>
+
+<h2 id="cleaning-up-after-a-failed-release-attempt-for-calcite-committers">Cleaning up after a failed release attempt (for Calcite committers)</h2>
+
+<p>```
+# Make sure that the tag you are about to generate does not already
+# exist (due to a failed release attempt)
+git tag</p>
+
+<h1 id="if-the-tag-exists-delete-it-locally-and-remotely">If the tag exists, delete it locally and remotely</h1>
+<p>git tag -d apache-calcite-X.Y.Z-incubating
+git push origin :refs/tags/apache-calcite-X.Y.Z-incubating</p>
+
+<h1 id="remove-modified-files">Remove modified files</h1>
+<p>mvn release:clean</p>
+
+<h1 id="check-whether-there-are-modified-files-and-if-so-go-back-to-the">Check whether there are modified files and if so, go back to the</h1>
+<p># original git commit
+git status
+git reset âhard HEAD
+```</p>
+
+<h2 id="validate-a-release">Validate a release</h2>
+
+<p>```bash
+# Check that the signing key (e.g. 2AD3FAE3) is pushed
+gpg ârecv-keys key</p>
+
+<h1 id="check-keys">Check keys</h1>
+<p>curl -O https://dist.apache.org/repos/dist/release/incubator/calcite/KEYS</p>
+
+<h1 id="signcheck-md5-and-sha1-hashes">Sign/check md5 and sha1 hashes</h1>
+<p># (Assumes your O/S has âmd5â and âsha1â commands.)
+function checkHash() {
+ cd â$1â
+ for i in *.{zip,pom,gz}; do
+ if [ ! -f $i ]; then
+ continue
+ fi
+ if [ -f $i.md5 ]; then
+ if [ â$(cat $i.md5)â = â$(md5 -q $i)â ]; then
+ echo $i.md5 present and correct
+ else
+ echo $i.md5 does not match
+ fi
+ else
+ md5 -q $i > $i.md5
+ echo $i.md5 created
+ fi
+ if [ -f $i.sha1 ]; then
+ if [ â$(cat $i.sha1)â = â$(sha1 -q $i)â ]; then
+ echo $i.sha1 present and correct
+ else
+ echo $i.sha1 does not match
+ fi
+ else
+ sha1 -q $i > $i.sha1
+ echo $i.sha1 created
+ fi
+ done
+}
+checkHash apache-calcite-X.Y.Z-incubating-rcN
+```</p>
+
+<h2 id="get-approval-for-a-release-via-apache-voting-process-for-calcite-committers">Get approval for a release via Apache voting process (for Calcite committers)</h2>
+
+<p>Release vote on dev list</p>
+
+<p>```
+To: dev@calcite.incubator.apache.org
+Subject: [VOTE] Release apache-calcite-X.Y.Z-incubating (release candidate N)</p>
+
+<p>Hi all,</p>
+
+<p>I have created a build for Apache Calcite X.Y.Z-incubating, release candidate N.</p>
+
+<p>Thanks to everyone who has contributed to this release.
+<further details="" about="" release.=""> You can read the release notes here:
+https://github.com/apache/incubator-calcite/blob/XXXX/doc/history.md</further></p>
+
+<p>The commit to be voted upon:
+http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/NNNNNN</p>
+
+<p>Its hash is XXXX.</p>
+
+<p>The artifacts to be voted on are located here:
+https://dist.apache.org/repos/dist/dev/incubator/calcite/apache-calcite-X.Y.Z-incubating-rcN/</p>
+
+<p>The hashes of the artifacts are as follows:
+src.tar.gz.md5 XXXX
+src.tar.gz.sha1 XXXX
+src.zip.md5 XXXX
+src.zip.sha1 XXXX</p>
+
+<p>A staged Maven repository is available for review at:
+https://repository.apache.org/content/repositories/orgapachecalcite-NNNN</p>
+
+<p>Release artifacts are signed with the following key:
+https://people.apache.org/keys/committer/jhyde.asc</p>
+
+<p>Please vote on releasing this package as Apache Calcite X.Y.Z-incubating.</p>
+
+<p>The vote is open for the next 72 hours and passes if a majority of
+at least three +1 PPMC votes are cast.</p>
+
+<p>[ ] +1 Release this package as Apache Calcite X.Y.Z-incubating
+[ ] 0 I donât feel strongly about it, but Iâm okay with the release
+[ ] -1 Do not release this package becauseâ¦</p>
+
+<p>Here is my vote:</p>
+
+<p>+1 (binding)</p>
+
+<p>Julian
+```</p>
+
+<p>After vote finishes, send out the result:</p>
+
+<p>```
+Subject: [RESULT] [VOTE] Release apache-calcite-X.Y.Z-incubating (release candidate N)
+To: dev@calcite.incubator.apache.org</p>
+
+<p>Thanks to everyone who has tested the release candidate and given
+their comments and votes.</p>
+
+<p>The tally is as follows.</p>
+
+<p>N binding +1s:</p>
+<names>
+
+N non-binding +1s:
+<names>
+
+No 0s or -1s.
+
+Therefore I am delighted to announce that the proposal to release
+Apache Calcite X.Y.Z-incubating has passed.
+
+I'll now start a vote on the general list. Those of you in the IPMC,
+please recast your vote on the new thread.
+
+Julian
+```
+
+Use the [Apache URL shortener](http://s.apache.org) to generate
+shortened URLs for the vote proposal and result emails. Examples:
+[s.apache.org/calcite-1.2-vote](http://s.apache.org/calcite-1.2-vote) and
+[s.apache.org/calcite-1.2-result](http://s.apache.org/calcite-1.2-result).
+
+Propose a vote on the incubator list.
+
+```
+To: general@incubator.apache.org
+Subject: [VOTE] Release Apache Calcite X.Y.Z (incubating)
+
+Hi all,
+
+The Calcite community has voted on and approved a proposal to release
+Apache Calcite X.Y.Z (incubating).
+
+Proposal:
+http://s.apache.org/calcite-X.Y.Z-vote
+
+Vote result:
+N binding +1 votes
+N non-binding +1 votes
+No -1 votes
+http://s.apache.org/calcite-X.Y.Z-result
+
+The commit to be voted upon:
+http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/NNNNNN
+
+Its hash is XXXX.
+
+The artifacts to be voted on are located here:
+https://dist.apache.org/repos/dist/dev/incubator/calcite/apache-calcite-X.Y.Z-incubating-rcN/
+
+The hashes of the artifacts are as follows:
+src.tar.gz.md5 XXXX
+src.tar.gz.sha1 XXXX
+src.zip.md5 XXXX
+src.zip.sha1 XXXX
+
+A staged Maven repository is available for review at:
+https://repository.apache.org/content/repositories/orgapachecalcite-NNNN
+
+Release artifacts are signed with the following key:
+https://people.apache.org/keys/committer/jhyde.asc
+
+Pursuant to the Releases section of the Incubation Policy and with
+the endorsement of NNN of our mentors we would now like to request
+the permission of the Incubator PMC to publish the release. The vote
+is open for 72 hours, or until the necessary number of votes (3 +1)
+is reached.
+
+[ ] +1 Release this package as Apache Calcite X.Y.Z incubating
+[ ] -1 Do not release this package because...
+
+Julian Hyde, on behalf of Apache Calcite PPMC
+```
+
+After vote finishes, send out the result:
+
+```
+To: general@incubator.apache.org
+Subject: [RESULT] [VOTE] Release Apache Calcite X.Y.Z (incubating)
+
+This vote passes with N +1s and no 0 or -1 votes:
++1 <name> (mentor)
+
+There was some feedback during voting. I shall open a separate
+thread to discuss.
+
+Thanks everyone. Weâll now roll the release out to the mirrors.
+
+Julian
+```
+
+## Publishing a release (for Calcite committers)
+
+After a successful release vote, we need to push the release
+out to mirrors, and other tasks.
+
+In JIRA, search for all issues resolved in this release,
+and do a bulk update changing their status to "Closed",
+with a change comment
+"Resolved in release X.Y.Z-incubating (YYYY-MM-DD)"
+(fill in release number and date appropriately).
+
+Promote the staged nexus artifacts.
+* Go to https://repository.apache.org/
+* Under "Build Promotion" click "Staging Repositories"
+* In the line with "orgapachecalcite-xxxx", check the box
+* Press "Release" button
+
+Check the artifacts into svn.
+
+```bash
+# Get the release candidate.
+mkdir -p ~/dist/dev
+cd ~/dist/dev
+svn co https://dist.apache.org/repos/dist/dev/incubator/calcite
+
+# Copy the artifacts. Note that the copy does not have '-rcN' suffix.
+mkdir -p ~/dist/release
+cd ~/dist/release
+svn co https://dist.apache.org/repos/dist/release/incubator/calcite
+cd calcite
+cp -rp ../../dev/calcite/apache-calcite-X.Y.Z-incubating-rcN apache-calcite-X.Y.Z-incubating
+svn add apache-calcite-X.Y.Z-incubating
+
+# Check in.
+svn ci
+```
+
+Svnpubsub will publish to
+https://dist.apache.org/repos/dist/release/incubator/calcite and propagate to
+http://www.apache.org/dyn/closer.cgi/incubator/calcite within 24 hours.
+
+## Publishing the web site (for Calcite committers)
+
+Get the code:
+
+```bash
+$ svn co https://svn.apache.org/repos/asf/incubator/calcite/site calcite-site
+```
+
+(Note: `https:`, not `http:`.)
+
+Build the site:
+
+```bash
+$ cd calcite-site
+$ ./build.sh
+```
+
+It will prompt you to install jekyll, redcarpet and pygments, if you
+do not have them installed. It will also check out the git source code
+repo, so that it can generate javadoc.
+
+Check in:
+
+```bash
+svn ci -m"Commit message" file...
+```
+
+The site will automatically be deployed as http://calcite.incubator.apache.org.
+</name></names></names>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <div class="section-nav">
+ <div class="left align-right">
+
+
+
+ <a href="/docs/model.html" class="prev">Back</a>
+
+ </div>
+ <div class="right align-left">
+
+
+
+ <a href="/docs/downloads.html" class="next">Next</a>
+
+ </div>
+ </div>
+ <div class="clear"></div>
+
+
+ </article>
+ </div>
+
+ <div class="unit one-fifth hide-on-mobiles">
+ <aside>
+
+ <h4>Overview</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/index.html">Background</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/tutorial.html">Tutorial</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/algebra.html">Algebra</a></li>
+
+
+
+</ul>
+
+
+ <h4>Advanced</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/adapter.html">Adapters</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/avatica.html">Avatica</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/stream.html">Streaming</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/lattice.html">Lattices</a></li>
+
+
+
+</ul>
+
+
+ <h4>Reference</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/reference.html">SQL language</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/model.html">JSON models</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class="current"><a href="/docs/howto.html">HOWTO</a></li>
+
+
+
+</ul>
+
+
+ <h4>Meta</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/downloads.html">Downloads</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/history.html">History</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/contributing.html">Contributing</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/api.html">API</a></li>
+
+
+
+</ul>
+
+
+ </aside>
+</div>
+
+
+ <div class="clear"></div>
+
+ </div>
+ </section>
+
+
+ <footer role="contentinfo">
+ <p>The contents of this website are © 2015
+ <a href="https://www.apache.org/">Apache Software Foundation</a>
+ under the terms of
+ the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">
+ Apache License v2</a>. Apache Calcite and its logo are
+ trademarks of the Apache Software Foundation.</p>
+
+ <p>Apache Calcite is an effort undergoing incubation at The Apache
+ Software Foundation (ASF), sponsored by the Apache
+ Incubator. Incubation is required of all newly accepted projects
+ until a further review indicates that the infrastructure,
+ communications, and decision making process have stabilized in a
+ manner consistent with other successful ASF projects. While
+ incubation status is not necessarily a reflection of the
+ completeness or stability of the code, it does indicate that the
+ project has yet to be fully endorsed by the ASF.</p>
+
+</footer>
+
+ <script>
+ var anchorForId = function (id) {
+ var anchor = document.createElement("a");
+ anchor.className = "header-link";
+ anchor.href = "#" + id;
+ anchor.innerHTML = "<span class=\"sr-only\">Permalink</span><i class=\"fa fa-link\"></i>";
+ anchor.title = "Permalink";
+ return anchor;
+ };
+
+ var linkifyAnchors = function (level, containingElement) {
+ var headers = containingElement.getElementsByTagName("h" + level);
+ for (var h = 0; h < headers.length; h++) {
+ var header = headers[h];
+
+ if (typeof header.id !== "undefined" && header.id !== "") {
+ header.appendChild(anchorForId(header.id));
+ }
+ }
+ };
+
+ document.onreadystatechange = function () {
+ if (this.readyState === "complete") {
+ var contentBlock = document.getElementsByClassName("docs")[0] || document.getElementsByClassName("news")[0];
+ if (!contentBlock) {
+ return;
+ }
+ for (var level = 1; level <= 6; level++) {
+ linkifyAnchors(level, contentBlock);
+ }
+ }
+ };
+</script>
+
+
+</body>
+</html>
Added: incubator/calcite/site/docs/index.html
URL: http://svn.apache.org/viewvc/incubator/calcite/site/docs/index.html?rev=1682430&view=auto
==============================================================================
--- incubator/calcite/site/docs/index.html (added)
+++ incubator/calcite/site/docs/index.html Fri May 29 11:48:34 2015
@@ -0,0 +1,1202 @@
+<!DOCTYPE HTML>
+<html lang="en-US">
+<head>
+ <meta charset="UTF-8">
+ <title>Background</title>
+ <meta name="viewport" content="width=device-width,initial-scale=1">
+ <meta name="generator" content="Jekyll v2.4.0">
+ <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic,900">
+ <link rel="stylesheet" href="/css/screen.css">
+ <link rel="icon" type="image/x-icon" href="/favicon.ico">
+ <!--[if lt IE 9]>
+ <script src="/js/html5shiv.min.js"></script>
+ <script src="/js/respond.min.js"></script>
+ <![endif]-->
+</head>
+
+
+<body class="wrap">
+ <header role="banner">
+ <nav class="mobile-nav show-on-mobiles">
+ <ul>
+ <li class="">
+ <a href="/">Home</a>
+ </li>
+ <li class="current">
+ <a href="/docs/">Documentation</a>
+ </li>
+ <li class="">
+ <a href="/talks/">Talks</a>
+ </li>
+ <li class="">
+ <a href="/news/">News</a>
+ </li>
+ <li class="">
+ <a href="/help/">Help</a>
+ </li>
+ <li class="">
+ <a href="/develop/">Develop</a>
+ </li>
+</ul>
+
+ </nav>
+ <div class="grid">
+ <div class="unit one-third center-on-mobiles">
+ <h1>
+ <a href="/">
+ <span class="sr-only">Apache Calcite</span>
+ <img src="/img/logo.png" width="226" height="140" alt="Calcite Logo">
+ </a>
+ </h1>
+ </div>
+ <nav class="main-nav unit two-thirds hide-on-mobiles">
+ <ul>
+ <li class="">
+ <a href="/">Home</a>
+ </li>
+ <li class="current">
+ <a href="/docs/">Documentation</a>
+ </li>
+ <li class="">
+ <a href="/talks/">Talks</a>
+ </li>
+ <li class="">
+ <a href="/news/">News</a>
+ </li>
+ <li class="">
+ <a href="/help/">Help</a>
+ </li>
+ <li class="">
+ <a href="/develop/">Develop</a>
+ </li>
+</ul>
+
+ </nav>
+ </div>
+</header>
+
+
+ <section class="docs">
+ <div class="grid">
+
+ <div class="docs-nav-mobile unit whole show-on-mobiles">
+ <select onchange="if (this.value) window.location.href=this.value">
+ <option value="">Navigate the docsâ¦</option>
+
+ <optgroup label="Overview">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/index.html">Background</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/tutorial.html">Tutorial</option>
+
+
+
+
+
+
+
+
+
+ <option value="/docs/algebra.html">Algebra</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ <optgroup label="Advanced">
+
+
+
+
+
+
+
+ <option value="/docs/adapter.html">Adapters</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/avatica.html">Avatica</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/stream.html">Streaming</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/lattice.html">Lattices</option>
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ <optgroup label="Reference">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/reference.html">SQL language</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/model.html">JSON models</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/howto.html">HOWTO</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ <optgroup label="Meta">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/downloads.html">Downloads</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/history.html">History</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/contributing.html">Contributing</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/api.html">API</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ </select>
+</div>
+
+
+ <div class="unit four-fifths">
+ <article>
+ <h1>Background</h1>
+ <p>Apache Calcite is a dynamic data management framework.</p>
+
+<p>It contains many of the pieces that comprise a typical database
+management system, but omits some key functions: storage of data,
+algorithms to process data, and a repository for storing metadata.</p>
+
+<p>Calcite intentionally stays out of the business of storing and
+processing data. As we shall see, this makes it an excellent choice
+for mediating between applications and one or more data storage
+locations and data processing engines. It is also a perfect foundation
+for building a database: just add data.</p>
+
+<p>To illustrate, letâs create an empty instance of Calcite and then
+point it at some data.</p>
+
+<div class="highlight"><pre><code class="language-java" data-lang="java"><span class="kd">public</span> <span class="kd">static</span> <span class="kd">class</span> <span class="nc">HrSchema</span> <span class="o">{</span>
+ <span class="kd">public</span> <span class="kd">final</span> <span class="n">Employee</span><span class="o">[]</span> <span class="n">emps</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span>
+ <span class="kd">public</span> <span class="kd">final</span> <span class="n">Department</span><span class="o">[]</span> <span class="n">depts</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span>
+<span class="o">}</span>
+<span class="n">Class</span><span class="o">.</span><span class="na">forName</span><span class="o">(</span><span class="s">"org.apache.calcite.jdbc.Driver"</span><span class="o">);</span>
+<span class="n">Properties</span> <span class="n">info</span> <span class="o">=</span> <span class="k">new</span> <span class="nf">Properties</span><span class="o">();</span>
+<span class="n">info</span><span class="o">.</span><span class="na">setProperty</span><span class="o">(</span><span class="s">"lex"</span><span class="o">,</span> <span class="s">"JAVA"</span><span class="o">);</span>
+<span class="n">Connection</span> <span class="n">connection</span> <span class="o">=</span> <span class="n">DriverManager</span><span class="o">.</span><span class="na">getConnection</span><span class="o">(</span><span class="s">"jdbc:calcite:"</span><span class="o">,</span> <span class="n">info</span><span class="o">);</span>
+<span class="n">CalciteConnection</span> <span class="n">calciteConnection</span> <span class="o">=</span>
+ <span class="n">connection</span><span class="o">.</span><span class="na">unwrap</span><span class="o">(</span><span class="n">CalciteConnection</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>
+<span class="n">ReflectiveSchema</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="n">calciteConnection</span><span class="o">,</span>
+ <span class="n">calciteConnection</span><span class="o">.</span><span class="na">getRootSchema</span><span class="o">(),</span> <span class="s">"hr"</span><span class="o">,</span> <span class="k">new</span> <span class="nf">HrSchema</span><span class="o">());</span>
+<span class="n">Statement</span> <span class="n">statement</span> <span class="o">=</span> <span class="n">calciteConnection</span><span class="o">.</span><span class="na">createStatement</span><span class="o">();</span>
+<span class="n">ResultSet</span> <span class="n">resultSet</span> <span class="o">=</span> <span class="n">statement</span><span class="o">.</span><span class="na">executeQuery</span><span class="o">(</span>
+ <span class="s">"select d.deptno, min(e.empid)\n"</span>
+ <span class="o">+</span> <span class="s">"from hr.emps as e\n"</span>
+ <span class="o">+</span> <span class="s">"join hr.depts as d\n"</span>
+ <span class="o">+</span> <span class="s">" on e.deptno = d.deptno\n"</span>
+ <span class="o">+</span> <span class="s">"group by d.deptno\n"</span>
+ <span class="o">+</span> <span class="s">"having count(*) > 1"</span><span class="o">);</span>
+<span class="n">print</span><span class="o">(</span><span class="n">resultSet</span><span class="o">);</span>
+<span class="n">resultSet</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
+<span class="n">statement</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
+<span class="n">connection</span><span class="o">.</span><span class="na">close</span><span class="o">();</span></code></pre></div>
+
+<p>Where is the database? There is no database. The connection is
+completely empty until <code>ReflectiveSchema.create</code> registers a Java
+object as a schema and its collection fields <code>emps</code> and <code>depts</code> as
+tables.</p>
+
+<p>Calcite does not want to own data; it does not even have favorite data
+format. This example used in-memory data sets, and processed them
+using operators such as <code>groupBy</code> and <code>join</code> from the linq4j
+library. But Calcite can also process data in other data formats, such
+as JDBC. In the first example, replace</p>
+
+<div class="highlight"><pre><code class="language-java" data-lang="java"><span class="n">ReflectiveSchema</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="n">calciteConnection</span><span class="o">,</span>
+ <span class="n">calciteConnection</span><span class="o">.</span><span class="na">getRootSchema</span><span class="o">(),</span> <span class="s">"hr"</span><span class="o">,</span> <span class="k">new</span> <span class="nf">HrSchema</span><span class="o">());</span></code></pre></div>
+
+<p>with</p>
+
+<div class="highlight"><pre><code class="language-java" data-lang="java"><span class="n">Class</span><span class="o">.</span><span class="na">forName</span><span class="o">(</span><span class="s">"com.mysql.jdbc.Driver"</span><span class="o">);</span>
+<span class="n">BasicDataSource</span> <span class="n">dataSource</span> <span class="o">=</span> <span class="k">new</span> <span class="nf">BasicDataSource</span><span class="o">();</span>
+<span class="n">dataSource</span><span class="o">.</span><span class="na">setUrl</span><span class="o">(</span><span class="s">"jdbc:mysql://localhost"</span><span class="o">);</span>
+<span class="n">dataSource</span><span class="o">.</span><span class="na">setUsername</span><span class="o">(</span><span class="s">"username"</span><span class="o">);</span>
+<span class="n">dataSource</span><span class="o">.</span><span class="na">setPassword</span><span class="o">(</span><span class="s">"password"</span><span class="o">);</span>
+<span class="n">JdbcSchema</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="n">calciteConnection</span><span class="o">.</span><span class="na">getRootSchema</span><span class="o">(),</span> <span class="s">"name"</span><span class="o">,</span> <span class="n">dataSource</span><span class="o">,</span>
+ <span class="kc">null</span><span class="o">,</span> <span class="s">"hr"</span><span class="o">);</span></code></pre></div>
+
+<p>and Calcite will execute the same query in JDBC. To the application,
+the data and API are the same, but behind the scenes the
+implementation is very different. Calcite uses optimizer rules to push
+the <code>JOIN</code> and <code>GROUP BY</code> operations to the source database.</p>
+
+<p>In-memory and JDBC are just two familiar examples. Calcite can handle
+any data source and data format. To add a data source, you need to
+write an adapter that tells Calcite what collections in the data
+source it should consider âtablesâ.</p>
+
+<p>For more advanced integration, you can write optimizer
+rules. Optimizer rules allow Calcite to access data of a new format,
+allow you to register new operators (such as a better join algorithm),
+and allow Calcite to optimize how queries are translated to
+operators. Calcite will combine your rules and operators with built-in
+rules and operators, apply cost-based optimization, and generate an
+efficient plan.</p>
+
+<h3 id="writing-an-adapter">Writing an adapter</h3>
+
+<p>The subproject under example/csv provides a CSV adapter, which is
+fully functional for use in applications but is also simple enough to
+serve as a good template if you are writing your own adapter.</p>
+
+<p>See the <a href="tutorial.html">tutorial</a> for information on using
+the CSV adapter and writing other adapters.</p>
+
+<p>See the <a href="howto.html">HOWTO</a> for more information about
+using other adapters, and about using Calcite in general.</p>
+
+<h2 id="status">Status</h2>
+
+<p>The following features are complete.</p>
+
+<ul>
+ <li>Query parser, validator and optimizer</li>
+ <li>Support for reading models in JSON format</li>
+ <li>Many standard functions and aggregate functions</li>
+ <li>JDBC queries against Linq4j and JDBC back-ends</li>
+ <li>Linq4j front-end</li>
+ <li>SQL features: SELECT, FROM (including JOIN syntax), WHERE, GROUP BY
+(including GROUPING SETS), aggregate functions (including
+COUNT(DISTINCT â¦) and FILTER), HAVING, ORDER BY (including NULLS
+FIRST/LAST), set operations (UNION, INTERSECT, MINUS), sub-queries
+(including correlated sub-queries), windowed aggregates, LIMIT
+(syntax as <a href="http://www.postgresql.org/docs/8.4/static/sql-select.html#SQL-LIMIT">Postgres</a>);
+more details in the <a href="reference.html">SQL reference</a></li>
+ <li>Local and remote JDBC drivers; see <a href="avatica.html">Avatica</a></li>
+ <li>Several <a href="adapter.html">adapters</a></li>
+</ul>
+
+<h2 id="disclaimer">Disclaimer</h2>
+
+<p>Apache Calcite is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Incubator. Incubation is
+required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making
+process have stabilized in a manner consistent with other successful
+ASF projects. While incubation status is not necessarily a reflection
+of the completeness or stability of the code, it does indicate that
+the project has yet to be fully endorsed by the ASF.</p>
+
+
+
+
+
+
+
+
+
+ <div class="section-nav">
+ <div class="left align-right">
+
+ <span class="prev disabled">Back</span>
+
+ </div>
+ <div class="right align-left">
+
+
+
+ <a href="/docs/tutorial.html" class="next">Next</a>
+
+ </div>
+ </div>
+ <div class="clear"></div>
+
+
+ </article>
+ </div>
+
+ <div class="unit one-fifth hide-on-mobiles">
+ <aside>
+
+ <h4>Overview</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class="current"><a href="/docs/index.html">Background</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/tutorial.html">Tutorial</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/algebra.html">Algebra</a></li>
+
+
+
+</ul>
+
+
+ <h4>Advanced</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/adapter.html">Adapters</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/avatica.html">Avatica</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/stream.html">Streaming</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/lattice.html">Lattices</a></li>
+
+
+
+</ul>
+
+
+ <h4>Reference</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/reference.html">SQL language</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/model.html">JSON models</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/howto.html">HOWTO</a></li>
+
+
+
+</ul>
+
+
+ <h4>Meta</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/downloads.html">Downloads</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/history.html">History</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/contributing.html">Contributing</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/api.html">API</a></li>
+
+
+
+</ul>
+
+
+ </aside>
+</div>
+
+
+ <div class="clear"></div>
+
+ </div>
+ </section>
+
+
+ <footer role="contentinfo">
+ <p>The contents of this website are © 2015
+ <a href="https://www.apache.org/">Apache Software Foundation</a>
+ under the terms of
+ the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">
+ Apache License v2</a>. Apache Calcite and its logo are
+ trademarks of the Apache Software Foundation.</p>
+
+ <p>Apache Calcite is an effort undergoing incubation at The Apache
+ Software Foundation (ASF), sponsored by the Apache
+ Incubator. Incubation is required of all newly accepted projects
+ until a further review indicates that the infrastructure,
+ communications, and decision making process have stabilized in a
+ manner consistent with other successful ASF projects. While
+ incubation status is not necessarily a reflection of the
+ completeness or stability of the code, it does indicate that the
+ project has yet to be fully endorsed by the ASF.</p>
+
+</footer>
+
+ <script>
+ var anchorForId = function (id) {
+ var anchor = document.createElement("a");
+ anchor.className = "header-link";
+ anchor.href = "#" + id;
+ anchor.innerHTML = "<span class=\"sr-only\">Permalink</span><i class=\"fa fa-link\"></i>";
+ anchor.title = "Permalink";
+ return anchor;
+ };
+
+ var linkifyAnchors = function (level, containingElement) {
+ var headers = containingElement.getElementsByTagName("h" + level);
+ for (var h = 0; h < headers.length; h++) {
+ var header = headers[h];
+
+ if (typeof header.id !== "undefined" && header.id !== "") {
+ header.appendChild(anchorForId(header.id));
+ }
+ }
+ };
+
+ document.onreadystatechange = function () {
+ if (this.readyState === "complete") {
+ var contentBlock = document.getElementsByClassName("docs")[0] || document.getElementsByClassName("news")[0];
+ if (!contentBlock) {
+ return;
+ }
+ for (var level = 1; level <= 6; level++) {
+ linkifyAnchors(level, contentBlock);
+ }
+ }
+ };
+</script>
+
+
+</body>
+</html>
Added: incubator/calcite/site/docs/lattice.html
URL: http://svn.apache.org/viewvc/incubator/calcite/site/docs/lattice.html?rev=1682430&view=auto
==============================================================================
--- incubator/calcite/site/docs/lattice.html (added)
+++ incubator/calcite/site/docs/lattice.html Fri May 29 11:48:34 2015
@@ -0,0 +1,1222 @@
+<!DOCTYPE HTML>
+<html lang="en-US">
+<head>
+ <meta charset="UTF-8">
+ <title>Lattices</title>
+ <meta name="viewport" content="width=device-width,initial-scale=1">
+ <meta name="generator" content="Jekyll v2.4.0">
+ <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic,900">
+ <link rel="stylesheet" href="/css/screen.css">
+ <link rel="icon" type="image/x-icon" href="/favicon.ico">
+ <!--[if lt IE 9]>
+ <script src="/js/html5shiv.min.js"></script>
+ <script src="/js/respond.min.js"></script>
+ <![endif]-->
+</head>
+
+
+<body class="wrap">
+ <header role="banner">
+ <nav class="mobile-nav show-on-mobiles">
+ <ul>
+ <li class="">
+ <a href="/">Home</a>
+ </li>
+ <li class="current">
+ <a href="/docs/">Documentation</a>
+ </li>
+ <li class="">
+ <a href="/talks/">Talks</a>
+ </li>
+ <li class="">
+ <a href="/news/">News</a>
+ </li>
+ <li class="">
+ <a href="/help/">Help</a>
+ </li>
+ <li class="">
+ <a href="/develop/">Develop</a>
+ </li>
+</ul>
+
+ </nav>
+ <div class="grid">
+ <div class="unit one-third center-on-mobiles">
+ <h1>
+ <a href="/">
+ <span class="sr-only">Apache Calcite</span>
+ <img src="/img/logo.png" width="226" height="140" alt="Calcite Logo">
+ </a>
+ </h1>
+ </div>
+ <nav class="main-nav unit two-thirds hide-on-mobiles">
+ <ul>
+ <li class="">
+ <a href="/">Home</a>
+ </li>
+ <li class="current">
+ <a href="/docs/">Documentation</a>
+ </li>
+ <li class="">
+ <a href="/talks/">Talks</a>
+ </li>
+ <li class="">
+ <a href="/news/">News</a>
+ </li>
+ <li class="">
+ <a href="/help/">Help</a>
+ </li>
+ <li class="">
+ <a href="/develop/">Develop</a>
+ </li>
+</ul>
+
+ </nav>
+ </div>
+</header>
+
+
+ <section class="docs">
+ <div class="grid">
+
+ <div class="docs-nav-mobile unit whole show-on-mobiles">
+ <select onchange="if (this.value) window.location.href=this.value">
+ <option value="">Navigate the docsâ¦</option>
+
+ <optgroup label="Overview">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/index.html">Background</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/tutorial.html">Tutorial</option>
+
+
+
+
+
+
+
+
+
+ <option value="/docs/algebra.html">Algebra</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ <optgroup label="Advanced">
+
+
+
+
+
+
+
+ <option value="/docs/adapter.html">Adapters</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/avatica.html">Avatica</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/stream.html">Streaming</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/lattice.html">Lattices</option>
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ <optgroup label="Reference">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/reference.html">SQL language</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/model.html">JSON models</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/howto.html">HOWTO</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ <optgroup label="Meta">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/downloads.html">Downloads</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/history.html">History</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/contributing.html">Contributing</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <option value="/docs/api.html">API</option>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </optgroup>
+
+ </select>
+</div>
+
+
+ <div class="unit four-fifths">
+ <article>
+ <h1>Lattices</h1>
+ <!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<p>A lattice is a framework for creating and populating materialized views,
+and for recognizing that a materialized view can be used to solve a
+particular query.</p>
+
+<p>A lattice represents a star (or snowflake) schema, not a general
+schema. In particular, all relationships must be many-to-one, heading
+from a fact table at the center of the star.</p>
+
+<p>The name derives from the mathematics: a
+<a href="http://en.wikipedia.org/wiki/Lattice_(order)">lattice</a>
+is a
+<a href="http://en.wikipedia.org/wiki/Partially_ordered_set">partially
+ordered set</a> where any two elements have a unique greatest lower
+bound and least upper bound.</p>
+
+<p>[<a href="#ref-hru96">HRU96</a>] observed that the set of possible
+materializations of a data cube forms a lattice, and presented an
+algorithm to choose a good set of materializations. Calciteâs
+recommendation algorithm is derived from this.</p>
+
+<p>The lattice definition uses a SQL statement to represent the star. SQL
+is a useful short-hand to represent several tables joined together,
+and assigning aliases to the column names (it more convenient than
+inventing a new language to represent relationships, join conditions
+and cardinalities).</p>
+
+<p>Unlike regular SQL, order is important. If you put A before B in the
+FROM clause, and make a join between A and B, you are saying that
+there is a many-to-one foreign key relationship from A to B. (E.g. in
+the example lattice, the Sales fact table occurs before the Time
+dimension table, and before the Product dimension table. The Product
+dimension table occurs before the ProductClass outer dimension table,
+further down an arm of a snowflake.)</p>
+
+<p>A lattice implies constraints. In the A to B relationship, there is a
+foreign key on A (i.e. every value of Aâs foreign key has a
+corresponding value in Bâs key), and a unique key on B (i.e. no key
+value occurs more than once). These constraints are really important,
+because it allows the planner to remove joins to tables whose columns
+are not being used, and know that the query results will not change.</p>
+
+<p>Calcite does not check these constraints. If they are violated,
+Calcite will return wrong results.</p>
+
+<p>A lattice is a big, virtual join view. It is not materialized (it
+would be several times larger than the star schema, because of
+denormalization) and you probably wouldnât want to query it (far too
+many columns). So what is it useful for? As we said above, (a) the
+lattice declares some very useful primary and foreign key constraints,
+(b) it helps the query planner map user queries onto
+filter-join-aggregate materialized views (the most useful kind of
+materialized view for DW queries), (c) gives Calcite a framework
+within which to gather stats about data volumes and user queries, (d)
+allows Calcite to automatically design and populate materialized
+views.</p>
+
+<p>Most star schema models force you to choose whether a column is a
+dimension or a measure. In a lattice, every column is a dimension
+column. (That is, it can become one of the columns in the GROUP BY clause
+to query the star schema at a particular dimensionality). Any column
+can also be used in a measure; you define measures by giving the
+column and an aggregate function.</p>
+
+<p>If âunit_salesâ tends to be used much more often as a measure rather
+than a dimension, thatâs fine. Calciteâs algorithm should notice that
+it is rarely aggregated, and not be inclined to create tiles that
+aggregate on it. (By âshouldâ I mean âcould and one day willâ. The
+algorithm does not currently take query history into account when
+designing tiles.)</p>
+
+<p>But someone might want to know whether orders with fewer than 5 items
+were more or less profitable than orders with more than 100. All of a
+sudden, âunit_salesâ has become a dimension. If thereâs virtually zero
+cost to declaring a column a dimension column, I figured letâs make
+them all dimension columns.</p>
+
+<p>The model allows for a particular table to be used more than once,
+with a different table alias. You could use this to model say
+OrderDate and ShipDate, with two uses to the Time dimension table.</p>
+
+<p>Most SQL systems require that the column names in a view are unique.
+This is hard to achieve in a lattice, because you often include
+primary and foreign key columns in a join. So Calcite lets you refer
+to columns in two ways. If the column is unique, you can use its name,
+[âunit_salesâ]. Whether or not it is unique in the lattice, it will be
+unique in its table, so you can use it qualified by its table alias.
+Examples:
+* [âsalesâ, âunit_salesâ]
+* [âship_dateâ, âtime_idâ]
+* [âorder_dateâ, âtime_idâ]</p>
+
+<p>A âtileâ is a materialized table in a lattice, with a particular
+dimensionality. (What Kylin calls a âcuboidâ.) The âtilesâ attribute
+of the <a href="model.html#lattice">lattice JSON element</a>
+defines an initial set of tiles to materialize.</p>
+
+<p>If you run the algorithm, you can omit the tiles attribute. Calcite
+will choose an initial set. If you include the tiles attribute, the
+algorithm will start with that list and then start finding other tiles
+that are complementary (i.e. âfill in the gapsâ left by the initial
+tiles).</p>
+
+<h3 id="references">References</h3>
+
+<h4 id="ref-hru96">[HRU96]</h4>
+<p>V. Harinarayan, A. Rajaraman and J. Ullman.
+<a href="http://web.eecs.umich.edu/~jag/eecs584/papers/implementing_data_cube.pdf">Implementing
+data cubes efficiently</a>. In <em>Proc. ACM SIGMOD Conf.</em>, Montreal, 1996.</p>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <div class="section-nav">
+ <div class="left align-right">
+
+
+
+ <a href="/docs/stream.html" class="prev">Back</a>
+
+ </div>
+ <div class="right align-left">
+
+
+
+ <a href="/docs/reference.html" class="next">Next</a>
+
+ </div>
+ </div>
+ <div class="clear"></div>
+
+
+ </article>
+ </div>
+
+ <div class="unit one-fifth hide-on-mobiles">
+ <aside>
+
+ <h4>Overview</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/index.html">Background</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/tutorial.html">Tutorial</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/algebra.html">Algebra</a></li>
+
+
+
+</ul>
+
+
+ <h4>Advanced</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/adapter.html">Adapters</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/avatica.html">Avatica</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/stream.html">Streaming</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class="current"><a href="/docs/lattice.html">Lattices</a></li>
+
+
+
+</ul>
+
+
+ <h4>Reference</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/reference.html">SQL language</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/model.html">JSON models</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/howto.html">HOWTO</a></li>
+
+
+
+</ul>
+
+
+ <h4>Meta</h4>
+
+
+<ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/downloads.html">Downloads</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/history.html">History</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/contributing.html">Contributing</a></li>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <li class=""><a href="/docs/api.html">API</a></li>
+
+
+
+</ul>
+
+
+ </aside>
+</div>
+
+
+ <div class="clear"></div>
+
+ </div>
+ </section>
+
+
+ <footer role="contentinfo">
+ <p>The contents of this website are © 2015
+ <a href="https://www.apache.org/">Apache Software Foundation</a>
+ under the terms of
+ the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">
+ Apache License v2</a>. Apache Calcite and its logo are
+ trademarks of the Apache Software Foundation.</p>
+
+ <p>Apache Calcite is an effort undergoing incubation at The Apache
+ Software Foundation (ASF), sponsored by the Apache
+ Incubator. Incubation is required of all newly accepted projects
+ until a further review indicates that the infrastructure,
+ communications, and decision making process have stabilized in a
+ manner consistent with other successful ASF projects. While
+ incubation status is not necessarily a reflection of the
+ completeness or stability of the code, it does indicate that the
+ project has yet to be fully endorsed by the ASF.</p>
+
+</footer>
+
+ <script>
+ var anchorForId = function (id) {
+ var anchor = document.createElement("a");
+ anchor.className = "header-link";
+ anchor.href = "#" + id;
+ anchor.innerHTML = "<span class=\"sr-only\">Permalink</span><i class=\"fa fa-link\"></i>";
+ anchor.title = "Permalink";
+ return anchor;
+ };
+
+ var linkifyAnchors = function (level, containingElement) {
+ var headers = containingElement.getElementsByTagName("h" + level);
+ for (var h = 0; h < headers.length; h++) {
+ var header = headers[h];
+
+ if (typeof header.id !== "undefined" && header.id !== "") {
+ header.appendChild(anchorForId(header.id));
+ }
+ }
+ };
+
+ document.onreadystatechange = function () {
+ if (this.readyState === "complete") {
+ var contentBlock = document.getElementsByClassName("docs")[0] || document.getElementsByClassName("news")[0];
+ if (!contentBlock) {
+ return;
+ }
+ for (var level = 1; level <= 6; level++) {
+ linkifyAnchors(level, contentBlock);
+ }
+ }
+ };
+</script>
+
+
+</body>
+</html>