Skip to content

Commit 2cafa83

Browse files
committed
Document newly added MATERIALIZE VIEWS for new sources.
Now it's possible to use this clause with a PostgreSQL or an MS SQL database source. Fixes #817.
1 parent c019c16 commit 2cafa83

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

docs/ref/mssql.rst

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ MS SQL Database Migration Options: WITH
3131
---------------------------------------
3232

3333
When loading from a `MS SQL` database, the same options as when loading a
34-
`MySQL` database are supported. Please refer to the MySQL section. The
34+
`MS SQL` database are supported. Please refer to the MS SQL section. The
3535
following options are added:
3636

3737
- *create schemas*
@@ -53,7 +53,39 @@ CAST
5353
The cast clause allows to specify custom casting rules, either to overload
5454
the default casting rules or to amend them with special cases.
5555

56-
Please refer to the MySQL CAST clause for details.
56+
Please refer to the MS SQL CAST clause for details.
57+
58+
MS SQL Views Support
59+
--------------------
60+
61+
MS SQL views support allows pgloader to migrate view as if they were base
62+
tables. This feature then allows for on-the-fly transformation from MS SQL
63+
to PostgreSQL, as the view definition is used rather than the base data.
64+
65+
MATERIALIZE VIEWS
66+
^^^^^^^^^^^^^^^^^
67+
68+
This clause allows you to implement custom data processing at the data
69+
source by providing a *view definition* against which pgloader will query
70+
the data. It's not possible to just allow for plain `SQL` because we want to
71+
know a lot about the exact data types of each column involved in the query
72+
output.
73+
74+
This clause expect a comma separated list of view definitions, each one
75+
being either the name of an existing view in your database or the following
76+
expression::
77+
78+
*name* `AS` `$$` *sql query* `$$`
79+
80+
The *name* and the *sql query* will be used in a `CREATE VIEW` statement at
81+
the beginning of the data loading, and the resulting view will then be
82+
dropped at the end of the data loading.
83+
84+
MATERIALIZE ALL VIEWS
85+
^^^^^^^^^^^^^^^^^^^^^
86+
87+
Same behaviour as *MATERIALIZE VIEWS* using the dynamic list of views as
88+
returned by MS SQL rather than asking the user to specify the list.
5789

5890
MS SQL Partial Migration
5991
------------------------
@@ -96,7 +128,7 @@ schema 'public' in the target database with this command::
96128
ALTER TABLE NAMES MATCHING ... IN SCHEMA '...'
97129
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98130

99-
See the MySQL explanation for this clause above. It works the same in the
131+
See the MS SQL explanation for this clause above. It works the same in the
100132
context of migrating from MS SQL, only with the added option to specify the
101133
name of the schema where to find the definition of the target tables.
102134

docs/ref/pgsql.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,38 @@ The supported casting options are:
283283

284284
column enumerate.foo using empty-string-to-null
285285

286+
PostgreSQL Views Support
287+
------------------------
288+
289+
PostgreSQL views support allows pgloader to migrate view as if they were
290+
base tables. This feature then allows for on-the-fly transformation of the
291+
source schema, as the view definition is used rather than the base data.
292+
293+
MATERIALIZE VIEWS
294+
^^^^^^^^^^^^^^^^^
295+
296+
This clause allows you to implement custom data processing at the data
297+
source by providing a *view definition* against which pgloader will query
298+
the data. It's not possible to just allow for plain `SQL` because we want to
299+
know a lot about the exact data types of each column involved in the query
300+
output.
301+
302+
This clause expect a comma separated list of view definitions, each one
303+
being either the name of an existing view in your database or the following
304+
expression::
305+
306+
*name* `AS` `$$` *sql query* `$$`
307+
308+
The *name* and the *sql query* will be used in a `CREATE VIEW` statement at
309+
the beginning of the data loading, and the resulting view will then be
310+
dropped at the end of the data loading.
311+
312+
MATERIALIZE ALL VIEWS
313+
^^^^^^^^^^^^^^^^^^^^^
314+
315+
Same behaviour as *MATERIALIZE VIEWS* using the dynamic list of views as
316+
returned by PostgreSQL rather than asking the user to specify the list.
317+
286318
PostgreSQL Partial Migration
287319
----------------------------
288320

0 commit comments

Comments
 (0)