Skip to main content

mapping_rules

Creates, updates, deletes, gets or lists a mapping_rules resource.

Overview

Namemapping_rules
TypeResource
Idgoogle.datamigration.mapping_rules

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringFull name of the mapping rule resource, in the form of: projects/{project}/locations/{location}/conversionWorkspaces/{set}/mappingRule/{rule}.
conditionalColumnSetValueobjectOptional. Rule to specify how the data contained in a column should be transformed (such as trimmed, rounded, etc) provided that the data meets certain criteria. (id: ConditionalColumnSetValue)
convertRowidColumnobjectOptional. Rule to specify how multiple tables should be converted with an additional rowid column. (id: ConvertRowIdToColumn)
displayNamestringOptional. A human readable name
entityMoveobjectOptional. Rule to specify how multiple entities should be relocated into a different schema. (id: EntityMove)
filterobjectRequired. The rule filter (id: MappingRuleFilter)
filterTableColumnsobjectOptional. Rule to specify the list of columns to include or exclude from a table. (id: FilterTableColumns)
multiColumnDataTypeChangeobjectOptional. Rule to specify how multiple columns should be converted to a different data type. (id: MultiColumnDatatypeChange)
multiEntityRenameobjectOptional. Rule to specify how multiple entities should be renamed. (id: MultiEntityRename)
revisionCreateTimestring (google-datetime)Output only. The timestamp that the revision was created.
revisionIdstringOutput only. The revision ID of the mapping rule. A new revision is committed whenever the mapping rule is changed in any way. The format is an 8-character hexadecimal string.
ruleOrderstring (int64)Required. The order in which the rule is applied. Lower order rules are applied before higher value rules so they may end up being overridden.
ruleScopestringRequired. The rule scope
setTablePrimaryKeyobjectOptional. Rule to specify the primary key for a table (id: SetTablePrimaryKey)
singleColumnChangeobjectOptional. Rule to specify how a single column is converted. (id: SingleColumnChange)
singleEntityRenameobjectOptional. Rule to specify how a single entity should be renamed. (id: SingleEntityRename)
singlePackageChangeobjectOptional. Rule to specify how a single package is converted. (id: SinglePackageChange)
sourceSqlChangeobjectOptional. Rule to change the sql code for an entity, for example, function, procedure. (id: SourceSqlChange)
statestringOptional. The mapping rule state

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, conversionWorkspacesId, mappingRulesIdGets the details of a mapping rule.
listselectprojectsId, locationsId, conversionWorkspacesIdpageSize, pageTokenLists the mapping rules for a specific conversion workspace.
createinsertprojectsId, locationsId, conversionWorkspacesIdmappingRuleId, requestIdCreates a new mapping rule for a given conversion workspace.
deletedeleteprojectsId, locationsId, conversionWorkspacesId, mappingRulesIdrequestIdDeletes a single mapping rule.
importexecprojectsId, locationsId, conversionWorkspacesIdImports the mapping rules for a given conversion workspace. Supports various formats of external rules files.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
conversionWorkspacesIdstring
locationsIdstring
mappingRulesIdstring
projectsIdstring
mappingRuleIdstring
pageSizeinteger (int32)
pageTokenstring
requestIdstring

SELECT examples

Gets the details of a mapping rule.

SELECT
name,
conditionalColumnSetValue,
convertRowidColumn,
displayName,
entityMove,
filter,
filterTableColumns,
multiColumnDataTypeChange,
multiEntityRename,
revisionCreateTime,
revisionId,
ruleOrder,
ruleScope,
setTablePrimaryKey,
singleColumnChange,
singleEntityRename,
singlePackageChange,
sourceSqlChange,
state
FROM google.datamigration.mapping_rules
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND conversionWorkspacesId = '{{ conversionWorkspacesId }}' -- required
AND mappingRulesId = '{{ mappingRulesId }}' -- required;

INSERT examples

Creates a new mapping rule for a given conversion workspace.

INSERT INTO google.datamigration.mapping_rules (
data__name,
data__displayName,
data__state,
data__ruleScope,
data__filter,
data__ruleOrder,
data__singleEntityRename,
data__multiEntityRename,
data__entityMove,
data__singleColumnChange,
data__multiColumnDataTypeChange,
data__conditionalColumnSetValue,
data__convertRowidColumn,
data__setTablePrimaryKey,
data__singlePackageChange,
data__sourceSqlChange,
data__filterTableColumns,
projectsId,
locationsId,
conversionWorkspacesId,
mappingRuleId,
requestId
)
SELECT
'{{ name }}',
'{{ displayName }}',
'{{ state }}',
'{{ ruleScope }}',
'{{ filter }}',
'{{ ruleOrder }}',
'{{ singleEntityRename }}',
'{{ multiEntityRename }}',
'{{ entityMove }}',
'{{ singleColumnChange }}',
'{{ multiColumnDataTypeChange }}',
'{{ conditionalColumnSetValue }}',
'{{ convertRowidColumn }}',
'{{ setTablePrimaryKey }}',
'{{ singlePackageChange }}',
'{{ sourceSqlChange }}',
'{{ filterTableColumns }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ conversionWorkspacesId }}',
'{{ mappingRuleId }}',
'{{ requestId }}'
RETURNING
name,
conditionalColumnSetValue,
convertRowidColumn,
displayName,
entityMove,
filter,
filterTableColumns,
multiColumnDataTypeChange,
multiEntityRename,
revisionCreateTime,
revisionId,
ruleOrder,
ruleScope,
setTablePrimaryKey,
singleColumnChange,
singleEntityRename,
singlePackageChange,
sourceSqlChange,
state
;

DELETE examples

Deletes a single mapping rule.

DELETE FROM google.datamigration.mapping_rules
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND conversionWorkspacesId = '{{ conversionWorkspacesId }}' --required
AND mappingRulesId = '{{ mappingRulesId }}' --required
AND requestId = '{{ requestId }}';

Lifecycle Methods

Imports the mapping rules for a given conversion workspace. Supports various formats of external rules files.

EXEC google.datamigration.mapping_rules.import 
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@conversionWorkspacesId='{{ conversionWorkspacesId }}' --required
@@json=
'{
"rulesFormat": "{{ rulesFormat }}",
"rulesFiles": "{{ rulesFiles }}",
"autoCommit": {{ autoCommit }}
}';