Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Table management

Both create and alter table procedures should only be called from SNP GlueTM. Drop table procedure may be called on tables not created by SNP GlueTM.

Create an SNP GlueTM table in the specified source, name, and table definition.

call core.create_glue_table(<Source>, <Table>, <Table definition>);

Alter an SNP GlueTM table in the specified source, name, and table definition

call core.alter_glue_table(<Source>, <Table>, <Table definition>);
Table definition formatting:
{
-- Example of column definition, each column should have said definition
{"fieldname": "<fieldname>", "type": <type>, "key": <true/false>, "comment": "<comment>" }
}
-- Fieldname = Name of the column
-- Type      = Data type of the column
-- Key       = If the column is part of the primary key or not
-- Comment   = Column comment  

Drop an SNP GlueTM table by specifying the source where it is located and its name. Its merge-related artifacts are dropped as well → stream, view, task, and historical table. Before the historical table is deleted it is backed up as <table name>_BAK_<current timestamp> e.g. 'ZZVBAK_BAK_20230606084229'.

This action may lead to data loss! Use with caution.

call core.drop_glue_table(<Source>, <Table>);

Merge

Start the merge on a specific source using its settings.

call core.start_merge(<Source>);

Start merge by providing all the necessary information.

core.start_merge(<Warehouse>, 
                 <App name>,
                 <Source>,
                 <Metadata stream name>,
                 <Metadata table name>,
                 <Historical table suffix>,
                 <Control schedule period>, 
                 'MINUTE',
                 <Merge schedule period>, 
                 'MINUTE');

Resumes all merges inside a source. This only applies to MERGE_<table> tasks and not the 'START_CONTROL' task. Call ‘CORE.RESUME_CONTROL’ for resuming the 'START_CONTROL’ task.

call core.resume_merge(<Source>); 

Resumes merge on a specific table.

Do not call in a loop! In need of resuming multiple merges, provide array of tables instead of calling the stored procedure one by one.

call core.resume_merge(<Source>, <Table>);

Resumes merge on an array of tables.

call core.resume_merge(<Source>, <Array_of_tables>);

Suspends all merges inside a source. This only applies to MERGE_<table> tasks and not the ‘START_CONTROL' task. Call ‘CORE.SUSPEND_CONTROL’ for suspending the 'START_CONTROL’ task.

call core.suspend_merge(<Source>);

Suspends merge on a specific table.

Do not call in a loop! In need of suspending multiple merges, provide array of tables instead of calling the stored procedure one by one.

call core.suspend_merge(<Source>, <Table>);

Suspend merge on an array of tables.

call core.suspend_merge(<Source>, <Array_of_tables>);

Resume ‘START_CONTROL’ task.

call core.resume_control(<Source>);

Suspend the ‘START_CONTROL’ task.

call core.suspend_control(<Source>);

Settings

Get settings of specified scope → 'APP' for application settings, 'DEFAULT' for default (template) source settings, <Source> for specific source settings.

call core.get_settings(<Scope>);

Update settings overwrite existing settings with the same key and appended new ones.

call core.update_merge(<Scope>, to_variant(parse_json('<Settings in json formatting>')));

Example: call core.update_settings('<Scope>',  to_variant(parse_json('
                                              {"warehouse": "<Warehouse>",
                                               "metadata_table": "<Metadata table name>",
                                               "stream_name": "<Stream name>"})));

Set settings completely overwrite all existing values.

Not specified settings already present for the scope will be lost!

call core.set_settings(<Source>, to_variant(parse_json('<Settings in json formatting>')));

Example: call core.set_settings('<Source>','{"warehouse": "<Warehouse>",
                                             "metadata_table": "<Metadata table name>",
                                             "stream_name": "<Stream name>"});

List of all source settings:

  • warehouse → Warehouse under which merge task runs.

  • metadata_table → SNP GlueTM table that specifies which tables were replicated.

  • stream_name → Name of the stream to be created on the metadata table.

  • historical_tab_suffix → Suffix of the table the replicated table is going to be merged into.

  • control_schedule_time → Defines a period how often 'START_CONTROL' task should run.

  • control_schedule_type → Defines the time unit for the 'control_schedule_time'.

  • merge_schedule_time → Defines a period of how often merge tasks should run.

  • merge_schedule_type → Defines the time unit for the 'merge_schedule_time'.

  • merge_status → Flag if a merge was initiated and is set by the ‘CORE.START_MERGE' procedure. Not present in 'DEFAULT’ settings.

Do not set 'control_status' manually!

  • control_status → Flag if the 'START_CONTROL' task exists, is running, or is suspended. Not present in 'DEFAULT’ settings.

Application settings:

  • app_name → Name of the application.

Source management

Register a new source. It creates a new schema if it does not already exists and set default source settings.

In case an already existing source is registered again, its settings will be overwritten, and objects inside it will not be affected.

call core.register_source(<Source>)

Remove source drops source, its schema, if it exists.

This action may lead to data loss! Use with caution.

call core.remove_source(<Source>);

Cleanup

Remove control drops 'START_CONTROL' task, thus preventing from starting merges on newly replicated tables.

The ‘START_CONTROL' task can be recreated by running the 'CORE.START_MERGE’ stored procedure.

call core.remove_control(<Source>);

Drop an SNP GlueTM by specifying its source, type (view, stream, or task), and its name.

This stored procedure cannot drop tables. Use 'CORE.DROP_GLUE_TABLE' for dropping tables.

call core.drop_glue_object(<Source>, <Type>, <Object>);

By not specifying the object name, all objects of said type will be dropped in the specified source.

call core.drop_glue_object(<Source>, <Type>);

Drop glue tasks

The ‘START_CONTROL' task can be recreated by running the 'CORE.START_MERGE’ stored procedure.

Merge tasks can be recreated by:

  • Calling the 'CORE.DEPLOY_MERGE' stored procedure

  • Appending tables metadata to the metadata table

call core.drop_glue_tasks(<Source>);

Drop glue views

Merge view can be recreated by:

  • Calling the 'CORE.DEPLOY_MERGE' stored procedure

  • Appending tables metadata to the metadata table

call core.drop_glue_views(<Source>);

Drop glue streams

Replicated table stream can be recreated by:

  • Calling the 'CORE.DEPLOY_MERGE' stored procedure

  • Appending tables metadata to the metadata table

  • Recreating the stream on the metadata table → can be done by calling the 'CORE.START_MERGE' stored procedure

call core.drop_glue_streams(<So

  • No labels