Skip to content

Commit 45dcf49

Browse files
authored
Merge pull request #413 from JuliaMongo/DOCSP-29384
(DOCSP)-29384 Clarify the need to name the custom schema when loading it into drdl
2 parents 804fdc9 + b4945a7 commit 45dcf49

11 files changed

+112
-31
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. important::
2+
3+
If you upload a custom schema, you must store it with its specified
4+
name, using :commandoption:`name-schema <name-schema>`, and then specify
5+
this name to the :binary:`~bin.mongosqld` with
6+
:option:`--schemaName <mongosqld --schemaName>`.
7+
If you don't store the schema's name when you upload it, the schema
8+
name defaults to ``defaultSchema``. If the schema's name doesn't exist,
9+
this results in an error from :binary:`~bin.mongosqld` similar to the
10+
following: MongoDB schema not yet available.
11+
Error initializing schema: no schema found for name.

source/includes/options/commandoption-mongodrdl-name-schema.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
- *Required.* Specifies the database where the schema information
1818
is stored.
1919

20-
* - ``--name``
20+
* - :option:`--name <mongodrdl --name>`
2121
- *Required.* The new name of the schema.
2222

23-
* - ``--schema``
23+
* - :option:`--schema <mongodrdl --schema>`
2424
- *Required* The string representation of the
2525
:ref:`ObjectId <document-bson-type-object-id>` of the schema.
2626

source/includes/options/commandoption-mongodrdl-upload.rst

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,21 @@
3535
:copyable: false
3636
3737
5d793f3f6a26a3ce66c304ea
38+
39+
The next step is to store the schema under a name you provide, using
40+
the :commandoption:`name-schema <name-schema>` command:
41+
42+
.. code-block:: sh
3843
39-
To use the newly uploaded schema, restart :binary:`~bin.mongosqld`
40-
with the schema database specified by the
41-
:option:`--schemaSource <mongosqld --schemaSource>` option and
42-
the :option:`--schemaMode <mongosqld --schemaMode>` set to ``custom``:
44+
mongodrdl name-schema --name movies --schemaSource schemas --schema 5d793f3f6a26a3ce66c304ea
45+
46+
To use the newly uploaded schema that received a specified name,
47+
restart :binary:`~bin.mongosqld` with the schema database specified by the
48+
:option:`--schemaSource <mongosqld --schemaSource>` option, with the
49+
schema's name specified with :option:`--schemaName <mongosqld --schemaName>`:
4350

4451
.. code-block:: sh
4552
46-
mongosqld --schemaMode custom --schemaSource <schema-db>
53+
mongosqld --schemaSource <schema-db> --schemaName movies
4754
48-
55+
.. include:: /includes/fact-name-your-schema.rst
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. option:: --name <db-name>
2+
3+
4+
.. versionadded:: 2.11
5+
6+
Specifies the schema name.
7+
8+
.. include:: /includes/fact-name-your-schema.rst
9+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. option:: --schema <db-id>
2+
3+
.. versionadded:: 2.11
4+
5+
*Required*. Specifies the string representation of the
6+
:ref:`ObjectId <document-bson-type-object-id>` of the schema.
7+

source/includes/options/option-mongosqld-schemaName.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
the :option:`--schemaSource <mongosqld --schemaSource>` database.
99
Specifying schema names allows you to store multiple schemas in
1010
the :option:`--schemaSource <mongosqld --schemaSource>` database.
11-
The behavior depends on on the value of
11+
The behavior depends on the value of
1212
:option:`--schemaMode <mongosqld --schemaMode>`:
1313

1414
.. list-table::
@@ -28,8 +28,8 @@
2828
<mongosqld --schemaSource>` database after the |bi-short|
2929
samples the schema on startup.
3030

31-
If not specified, defaults to ``defaultSchema``.
32-
31+
.. include:: /includes/fact-name-your-schema.rst
32+
3333
.. include:: /includes/sampling-ref-chart-link.rst
3434

3535

source/launch.txt

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,23 @@ databases. You have several options for creating a schema and
2424
launching :binary:`~bin.mongosqld`. This guide will help you choose
2525
the best option for your needs.
2626

27-
By default, :binary:`~bin.mongosqld` generates a :doc:`data schema
28-
</schema-configuration>` and holds it in memory. Alternatively, if
29-
you prefer to create a schema file and edit it manually, use the
30-
:binary:`~bin.mongodrdl` program to create a ``.drdl`` schema
31-
file and use the :option:`--schema <mongosqld --schema>` option
32-
when starting :binary:`~bin.mongosqld`. For more information on schema
33-
generation and data sampling, see :doc:`schema-configuration`.
27+
By default, :binary:`~bin.mongosqld` generates a default :doc:`data schema
28+
</schema-configuration>` and stores it in memory. Alternatively, if you prefer
29+
to create a custom schema and edit it manually, use one of these two methods:
30+
31+
- Use the :binary:`~bin.mongodrdl` program to create a custom ``.drdl`` schema
32+
file and then start :binary:`~bin.mongosqld` with the
33+
:option:`--schema <mongodrdl --schema>` option to point to this file.
34+
35+
- If you previously uploaded a custom schema with the :commandoption:`upload`
36+
command, you must use the :commandoption:`name-schema <name-schema>`
37+
command to store the schema internally under the provided custom name.
38+
Then you can start :binary:`~bin.mongosqld` with
39+
:option:`--schemaSource <mongosqld --schema>`,
40+
:option:`--schemaMode <mongosqld --schema>`, and
41+
:option:`--schemaName <mongosqld --schemaName>` options.
42+
43+
To learn more about creating a schema and data sampling, see :doc:`schema-configuration`.
3444

3545
Prerequisites
3646
-------------

source/reference/mongodrdl.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ Core Options
131131

132132
.. include:: /includes/options/option-mongodrdl-preJoined.rst
133133

134+
.. include:: /includes/options/option-mongodrdl-schema.rst
135+
136+
.. include:: /includes/options/option-mongodrdl-name.rst
137+
134138
.. include:: /includes/options/option-mongodrdl-schemaSource.rst
135139

136140
TLS/SSL Options

source/schema-configuration.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The default sampling mode which :binary:`~bin.mongosqld` uses to
2626
analyze your collections and derive a static schema. In this mode,
2727
:binary:`~bin.mongosqld` derives the schema on startup and holds the
2828
schema in memory.
29-
29+
3030
:ref:`bi-persistent-schema`
3131
---------------------------------------------------------
3232

@@ -71,11 +71,11 @@ table along with other collection data.
7171
:ref:`type-conflict-resolution`
7272
-------------------------------
7373

74-
Relational databases do not allow dynamically typed columns so when
74+
Relational databases don't allow dynamically typed columns. When
7575
the |bi-short| samples data from MongoDB to generate a schema, type
76-
conversion conflicts may occur. See this page for more information
77-
on how the |bi-short| resolves these conflicts and displays data
78-
when conflicts are present.
76+
conversion conflicts may occur. To learn more about how the |bi-short|
77+
resolves these conflicts and displays data when conflicts are present,
78+
see the following sections.
7979

8080

8181
.. toctree::

source/schema/cached-sampling.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ of the schema which it then caches in memory.
2929

3030
.. include:: /includes/fact-sampleRefresh.rst
3131

32-
If the schema which :binary:`~bin.mongosqld` creates does not meet your
32+
If the schema which :binary:`~bin.mongosqld` creates doesn't meet your
3333
BI workload needs, you can manually generate a :ref:`schema file
3434
<schema-with-drdl-file>` file and edit it as necessary.
3535

source/schema/load-schema-from-drdl.txt

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ requirements.
2121
You can manually edit the schema definition files to perform the
2222
following actions:
2323

24-
- Add fields that :binary:`~bin.mongodrdl` did not discover within
24+
- Add fields that :binary:`~bin.mongodrdl` didn't discover within
2525
the subset of documents that it sampled
2626
- Remove fields
2727
- Remove tables
@@ -32,11 +32,44 @@ following actions:
3232

3333
.. include:: /includes/fact-geospatial-views.rst
3434

35-
When you're done editing your ``.drdl`` file, you can either:
35+
When you're done editing your ``.drdl`` file, you can follow the steps in
36+
one of the following options:
3637

37-
- Use :binary:`~bin.mongodrdl` to :commandoption:`upload` the schema
38-
to your MongoDB deployment.
38+
- Option 1. Upload the schema, give it a name, and start :binary:`~bin.mongosqld`,
39+
specifying both the schema's name, source, and mode, as in the following steps:
3940

40-
- Run :binary:`~bin.mongosqld` with the
41-
:option:`--schema <mongosqld --schema>` option to specify the
42-
``.drdl`` when launching ``mongosqld``.
41+
1. Use :binary:`~bin.mongodrdl` to :commandoption:`upload` the schema
42+
to your MongoDB deployment, similar to the following example:
43+
44+
.. code-block:: sh
45+
46+
mongodrdl upload --host <hostName> --schemaSource schemas --drdl ./movies.drdl
47+
48+
The string representation of the :ref:`ObjectId <document-bson-type-object-id>`
49+
of the uploaded schema is returned:
50+
51+
.. code-block:: sh
52+
:copyable: false
53+
54+
5d793f3f6a26a3ce66c304ea
55+
56+
2. Name your schema, using the :commandoption:`name-schema <name-schema>`
57+
command, similar to the following example:
58+
59+
.. code-block:: sh
60+
61+
mongodrdl name-schema --name movies --schemaSource schemas --schema 5d793f3f6a26a3ce66c304ea
62+
63+
3. Start :binary:`~bin.mongosqld` with a named schema, using
64+
:option:`--schemaSource <mongosqld --schema>`,
65+
:option:`--schemaMode <mongosqld --schema>`,
66+
and :option:`--schemaName <mongosqld --schemaName>` options,
67+
similar to the following example:
68+
69+
.. code-block::
70+
71+
mongosqld --schemaMode custom --schemaSource schemas --schemaName movies
72+
73+
- Option 2. Start :binary:`~bin.mongosqld` with the
74+
:option:`--schema <mongosqld --schema>` option to specify the path to the
75+
``.drdl`` schema file.

0 commit comments

Comments
 (0)