Skip to content

Commit

Permalink
added sql syntax highlighting to docs
Browse files Browse the repository at this point in the history
Conflicts:
	docs/sql/aggregation.txt
	docs/sql/reference/select.txt
	docs/sql/reference/update.txt
  • Loading branch information
Christian Haudum committed May 8, 2014
1 parent 26d0060 commit 0fbef4d
Show file tree
Hide file tree
Showing 26 changed files with 173 additions and 73 deletions.
1 change: 1 addition & 0 deletions docs/blob.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.. highlight:: sh
.. _blob_support:

============
Expand Down
1 change: 0 additions & 1 deletion docs/buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ show-picked-versions = true
parts = sphinx
sphinx-cmd
test
find-links = https://download.crate.io/eggs/

[test]
recipe = zc.recipe.egg:script
Expand Down
5 changes: 5 additions & 0 deletions docs/configuration.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.. highlight:: sh

=============
Configuration
=============

Expand All @@ -23,6 +26,8 @@ will work this way::

sh$ ./bin/crate -Des.cluster.name=cluster

.. highlight:: yaml

This is exactly the same as setting the cluster name in the config
file::

Expand Down
2 changes: 2 additions & 0 deletions docs/hello.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. highlight:: psql

===========
Hello Crate
===========
Expand Down
13 changes: 12 additions & 1 deletion docs/sql/aggregation.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

.. highlight:: psql
.. _aggregation:

===========
Expand Down Expand Up @@ -87,6 +87,8 @@ of distinct values in this column that are not ``NULL``::
+----------------------+----------+---------------+
SELECT 3 rows in set (... sec)

::

cr> select count(distinct kind) from locations;
+----------------------+
| count(DISTINCT kind) |
Expand All @@ -112,6 +114,7 @@ Example::
+---------------+-------------+
SELECT 3 rows in set (... sec)

::

cr> select min(date) from locations;
+--------------+
Expand Down Expand Up @@ -153,6 +156,7 @@ Some Examples::
+---------------+-------------+
SELECT 3 rows in set (... sec)

::

cr> select max(position) from locations;
+---------------+
Expand All @@ -162,6 +166,7 @@ Some Examples::
+---------------+
SELECT 1 row in set (... sec)

::

cr> select max(name), kind from locations group by kind order by max(name) desc;
+-------------------+-------------+
Expand Down Expand Up @@ -193,6 +198,8 @@ as a double value. Its single argument is the column name of a numeric column or
+---------------+-------------+
SELECT 3 rows in set (... sec)

::

cr> select sum(position) as position_sum from locations;
+--------------+
| position_sum |
Expand All @@ -201,6 +208,8 @@ as a double value. Its single argument is the column name of a numeric column or
+--------------+
SELECT 1 row in set (... sec)

::

cr> select sum(name), kind from locations group by kind order by sum(name) desc;
SQLActionException[unknown function: sum(string)]

Expand Down Expand Up @@ -244,6 +253,8 @@ Example::
+---------------------+
SELECT 1 row in set (... sec)

::

cr> select arbitrary(name), kind from locations
... where name != ''
... group by kind order by kind desc;
Expand Down
15 changes: 15 additions & 0 deletions docs/sql/ddl.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.. highlight:: psql
.. _sql_ddl:

========================
Expand Down Expand Up @@ -75,6 +76,8 @@ A basic boolean type. Accepting ``true`` and ``false`` as values. Example::
... );
CREATE OK (... sec)

::

cr> drop table my_bool_table;
DROP OK (... sec)

Expand Down Expand Up @@ -126,18 +129,28 @@ fractions. Example::
... );
CREATE OK (... sec)

::

cr> insert into my_table4 (id, first_column) values (0, '1970-01-01T00:00:00');
INSERT OK, 1 row affected (... sec)

::

cr> insert into my_table4 (id, first_column) values (1, '1970-01-01T00:00:00+0100');
INSERT OK, 1 row affected (... sec)

::

cr> insert into my_table4 (id, first_column) values (2, 0);
INSERT OK, 1 row affected (... sec)

::

cr> insert into my_table4 (id, first_column) values (3, 1.0);
INSERT OK, 1 row affected (... sec)

::

cr> insert into my_table4 (id, first_column) values (3, 'wrong');
SQLActionException[Validation failed for first_column: wrong type 'string'. expected: 'timestamp']

Expand Down Expand Up @@ -242,6 +255,8 @@ like with ``dynamic`` objects.
An object configured like this will simply accept and return the columns inserted into it,
but otherwise ignore them.

::

cr> create table my_table15 (
... title string,
... details object(ignored) as (
Expand Down
27 changes: 27 additions & 0 deletions docs/sql/dml.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. highlight:: psql

==============
Querying Crate
==============
Expand Down Expand Up @@ -402,6 +404,8 @@ Some Examples::
+----------+
SELECT 1 row in set (... sec)

::

cr> select count(*) from locations where kind='Planet';
+----------+
| count(*) |
Expand All @@ -410,6 +414,8 @@ Some Examples::
+----------+
SELECT 1 row in set (... sec)

::

cr> select count(name), count(*) from locations;
+-------------+----------+
| count(name) | count(*) |
Expand All @@ -418,6 +424,8 @@ Some Examples::
+-------------+----------+
SELECT 1 row in set (... sec)

::

cr> select max(name) from locations;
+-------------------+
| max(name) |
Expand All @@ -426,6 +434,8 @@ Some Examples::
+-------------------+
SELECT 1 row in set (... sec)

::

cr> select min(date) from locations;
+--------------+
| min(date) |
Expand All @@ -434,6 +444,8 @@ Some Examples::
+--------------+
SELECT 1 row in set (... sec)

::

cr> select count(*), kind from locations group by kind order by kind asc;
+----------+-------------+
| count(*) | kind |
Expand All @@ -444,6 +456,8 @@ Some Examples::
+----------+-------------+
SELECT 3 rows in set (... sec)

::

cr> select max(position), kind from locations group by kind order by max(position) desc;
+---------------+-------------+
| max(position) | kind |
Expand All @@ -454,6 +468,8 @@ Some Examples::
+---------------+-------------+
SELECT 3 rows in set (... sec)

::

cr> select min(name), kind from locations group by kind order by min(name) asc;
+------------------------------------+-------------+
| min(name) | kind |
Expand All @@ -464,6 +480,8 @@ Some Examples::
+------------------------------------+-------------+
SELECT 3 rows in set (... sec)

::

cr> select count(*), min(name), kind from locations group by kind order by kind;
+----------+------------------------------------+-------------+
| count(*) | min(name) | kind |
Expand All @@ -474,6 +492,8 @@ Some Examples::
+----------+------------------------------------+-------------+
SELECT 3 rows in set (... sec)

::

cr> select sum(position) as sum_positions, kind from locations group by kind order by sum_positions;
+---------------+-------------+
| sum_positions | kind |
Expand Down Expand Up @@ -702,6 +722,8 @@ Importing data
Using the ``COPY FROM`` SQL statement, data can be imported into Crate.
Currently the only supported data format is JSON, one line is representing one entry.

.. highlight:: json

Example JSON data::

{"id": 1, "quote": "Don't panic"}
Expand All @@ -719,6 +741,8 @@ Example JSON data::
Import from File URI
--------------------

.. highlight:: psql

An example import from a file URI::

cr> copy quotes from 'file:///tmp/import_data/quotes.json';
Expand Down Expand Up @@ -756,6 +780,9 @@ the table and shard id with gzip compression::

cr> refresh table quotes;
REFRESH OK...

::

cr> copy quotes to DIRECTORY '/tmp/' with (compression='gzip');
COPY OK, 3 rows affected ...

Expand Down
8 changes: 7 additions & 1 deletion docs/sql/information_schema.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

.. _information_schema:
.. highlight:: psql

==================
Information Schema
Expand Down Expand Up @@ -147,8 +147,14 @@ For further information see :ref:`sql_ddl_partitioned_by`.

cr> create table a_partitioned_table (id int, content string) partitioned by (content)
CREATE OK (... sec)

::

cr> insert into a_partitioned_table (id, content) values (1, 'content_a')
INSERT OK, 1 row affected (... sec)

::

cr> insert into a_partitioned_table (id, content) values (2, 'content_b')
INSERT OK, 1 row affected (... sec)

Expand Down
1 change: 1 addition & 0 deletions docs/sql/occ.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.. highlight:: psql
.. _sql_occ:

=========================================
Expand Down
19 changes: 19 additions & 0 deletions docs/sql/partitioned_tables.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.. _partitioned-tables:
.. highlight:: psql

==================
Partitioned Tables
Expand Down Expand Up @@ -56,6 +57,8 @@ recognizable as partitioned table by a non null ``partitioned_by`` column::
+-------------+--------------+------------------+--------------------+--------------+----------------+
SELECT 1 row in set (... sec)

::

cr> SELECT * FROM information_schema.columns
... WHERE schema_name = 'doc' AND table_name = 'parted_table'
... ORDER BY schema_name, table_name, column_name;
Expand Down Expand Up @@ -96,6 +99,8 @@ Insert
... values (1, 'Don''t Panic', 19.5, '2014-04-08');
INSERT OK, 1 row affected (... sec)

::

cr> SELECT partition_ident, "values" FROM information_schema.table_partitions
... WHERE schema_name = 'doc' AND table_name = 'parted_table'
... ORDER BY partition_ident;
Expand All @@ -113,9 +118,13 @@ no additional partition is created::
... values (2, 'Time is an illusion, lunchtime doubly so', 0.7, '2014-04-08');
INSERT OK, 1 row affected (... sec)

::

cr> REFRESH TABLE parted_table;
REFRESH OK (... sec)

::

cr> SELECT partition_ident, "values" FROM information_schema.table_partitions
... WHERE schema_name = 'doc' AND table_name = 'parted_table'
... ORDER BY partition_ident;
Expand All @@ -139,13 +148,21 @@ atomic operation and could lead to inconsistent state::
... WHERE id=1;
SQLActionException[Updating a partitioned-by column is currently not supported]

::

::

cr> UPDATE parted_table set content='now panic!'
... WHERE id=2;
UPDATE OK, 1 row affected (... sec)

::

cr> REFRESH TABLE parted_table;
REFRESH OK (... sec)

::

cr> SELECT * from parted_table WHERE id=2;
+------------+---------------+----+------------------------------------------+-------+
| content | day | id | title | width |
Expand All @@ -164,6 +181,8 @@ matching document, which is a lot faster::
cr> delete from parted_table where day=1396915200000;
DELETE OK, 0 rows affected (... sec)

::

cr> SELECT count(*) as partition_count FROM information_schema.table_partitions
... WHERE schema_name = 'doc' AND table_name = 'parted_table'
... ORDER BY partition_ident;
Expand Down
7 changes: 4 additions & 3 deletions docs/sql/reference/alter_table.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.. highlight:: psql
.. _ref-alter-table:

===========
Expand All @@ -9,12 +10,12 @@ Alter an existing table
Synopsis
========

.. code-block:: sql
::

ALTER [BLOB] TABLE table_name
{ SET ( parameter = value [ , ... ] ) |
{ SET ( parameter = value [ , ... ] ) |
RESET ( parameter [ , ... ] )
}
}

Description
===========
Expand Down
Loading

0 comments on commit 0fbef4d

Please sign in to comment.