Skip to content

Commit

Permalink
Merge branch 'develop' into HCK-7804
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightlngale authored Sep 17, 2024
2 parents 4b29a12 + ce15900 commit 48a093c
Show file tree
Hide file tree
Showing 12 changed files with 1,905 additions and 69 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/fake-pr-tests.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/trigger-pr-tests-plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Trigger PR tests (Plugins)

on:
pull_request:
types: [auto_merge_enabled]

jobs:
trigger-pr-tests-plugins:
name: Trigger PR tests (Plugins)
runs-on: ubuntu-latest
steps:
- name: Call TeamCity API endpoint
run: |
curl \
-X POST \
-H 'Authorization: Bearer ${{ secrets.TEAMCITY_TRIGGER_TESTS_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{"branchName": "pull/${{ github.event.number }}", "buildType": {"id": "${{ vars.TEAMCITY_BUILD_ID_FOR_TESTING_PLUGIN_PR }}"}}' \
${{ vars.TEAMCITY_API_URL }}/buildQueue
59 changes: 59 additions & 0 deletions adapter/0.2.7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright © 2016-2024 by IntegrIT S.A. dba Hackolade. All rights reserved.
*
* The copyright to the computer software herein is the property of IntegrIT S.A.
* The software may be used and/or copied only with the written permission of
* IntegrIT S.A. or in accordance with the terms and conditions stipulated in
* the agreement/contract under which the software has been supplied.
*
* {
* "add": {
* "entity": [<names of new property>],
* "container": [<names of new property>],
* "model": [<names of new property>],
* "view": [<names of new property>],
* "field": {
* "<type>": [<names of new property>]
* }
* },
* "delete": {
* "entity": [<names of new property>],
* "container": [<names of new property>],
* "model": [<names of new property>],
* "view": [<names of new property>],
* "field": {
* "<type>": [<names of new property>]
* }
* },
* "modify": {
* "entity": [
* {
* "from": { <properties that identify record> },
* "to": { <properties that need to be changed> }
* }
* ],
* "container": [],
* "model": [],
* "view": [],
* "field": []
* },
* }
*/

{
"modify": {
"model": [
[
"populateByPropertySource",
{
"modify": {
"container": [["getNameFromDottedIdentifier", "tagName", "schemaTags"]],
"entity": [["getNameFromDottedIdentifier", "tagName", "tableTags"]],
"view": [["getNameFromDottedIdentifier", "tagName", "viewTags"]],
"field": [["getNameFromDottedIdentifier", "tagName", "columnTags"]]
}
}
]
]
}
}
4 changes: 2 additions & 2 deletions forward_engineering/ddlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = (baseProvider, options, app) => {
tab,
});

const { getTagStatement, getTagAllowedValues, getTagKeyValues, prepareObjectTagsData } =
const { getTagStatement, getTagAllowedValues, getTagKeyValues, prepareObjectTagsData, isEmptyTags } =
require('./helpers/tagHelper')({
getName,
toString,
Expand Down Expand Up @@ -233,7 +233,7 @@ module.exports = (baseProvider, options, app) => {
this.createTag({ tag, schemaName: currentSchemaName, isCaseSensitive }),
);

if (!_.isEmpty(schemaTags)) {
if (!isEmptyTags({ tags: schemaTags })) {
const schemaTagStatement = assignTemplates(templates.alterSchema, {
name: fullName,
operation: 'SET TAG',
Expand Down
32 changes: 22 additions & 10 deletions forward_engineering/helpers/tagHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,30 @@ module.exports = ({ getName, toString }) => {
* @returns {string}
*/
const getTagStatement = ({ tags, isCaseSensitive, indent = ' ' }) => {
if (isEmpty(tags)) {
if (isEmptyTags({ tags })) {
return '';
}

const keyValues = getTagKeyValues({ tags, isCaseSensitive });

if (isEmpty(keyValues)) {
return '';
}

return `${indent}WITH TAG ( ${keyValues} )`;
};

/**
* @param {{ allowedValues: string[] }}
* @returns {string}
*/
const getTagAllowedValues = ({ allowedValues }) => {
if (isEmpty(allowedValues)) {
return '';
}

const values = allowedValues.map(({ value }) => toString(value)).join(', ');
const getTagAllowedValues = ({ allowedValues = [] }) => {
const values = allowedValues
.filter(({ value }) => value)
.map(({ value }) => toString(value))
.join(', ');

return ` ALLOWED_VALUES ${values}`;
return isEmpty(values) ? '' : ` ALLOWED_VALUES ${values}`;
};

/**
Expand All @@ -39,7 +42,7 @@ module.exports = ({ getName, toString }) => {
*/
const getTagKeyValues = ({ tags, isCaseSensitive }) => {
return tags
.filter(tag => tag.tagName)
.filter(tag => tag.tagName && tag.tagValue)
.map(tag => `${getTagName({ tagName: tag.tagName, isCaseSensitive })} = ${toString(tag.tagValue)}`)
.join(', ');
};
Expand Down Expand Up @@ -83,7 +86,7 @@ module.exports = ({ getName, toString }) => {
return '';
}

const tagNames = droppedTags.map(({ tagName }) => tagName).join(', ');
const tagNames = droppedTags.map(({ tagName }) => getTagName({ tagName, isCaseSensitive })).join(', ');

return `TAG ${tagNames}`;
};
Expand Down Expand Up @@ -114,12 +117,21 @@ module.exports = ({ getName, toString }) => {
};
};

/**
* @param {{ tags: ObjectTag[] }}
* @returns {boolean}
*/
const isEmptyTags = ({ tags }) => {
return isEmpty(tags) || tags.every(tag => !tag.tagName);
};

return {
getTagStatement,
getTagAllowedValues,
getTagKeyValues,
prepareObjectTagsData,
getSetTagValue,
getUnsetTagValue,
isEmptyTags,
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Snowflake",
"version": "0.2.8",
"version": "0.2.10",
"author": "hackolade",
"engines": {
"hackolade": "6.1.2",
Expand Down
97 changes: 96 additions & 1 deletion properties_pane/container_level/containerLevelConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,116 @@ making sure that you maintain a proper JSON format.
"propertyTooltip": "",
"propertyType": "group",
"groupItemLimit": 50,
"helpUrl": "https://hackolade.com/help/Snowflake.html#Tags",
"structure": [
{
"propertyName": "Tag name",
"propertyKeyword": "tagName",
"propertyTooltip": "",
"propertyType": "text"
"propertyType": "selecthashed",
"withEmptyOption": true,
"propertySource": {
"source": "tags.*.name"
}
},
{
"propertyName": "Value",
"propertyKeyword": "tagValue",
"propertyTooltip": "",
"propertyType": "selecthashed",
"withEmptyOption": true,
"propertySource": {
"source": "tags.${tagName}.allowedValues.*.value"
},
"shouldValidate": true,
"validation": {
"required": true
},
"dependency": {
"type": "and",
"values": [
{
"type": "not",
"values": [
{
"level": "container",
"source": "tags.${tagName}",
"key": "allowedValues",
"isEmpty": true
}
]
},
{
"level": "container",
"source": "tags.${tagName}",
"key": "allowedValues",
"exist": true
}
]
}
},
{
"propertyName": "Value",
"propertyKeyword": "tagValue",
"propertyTooltip": "",
"propertyType": "text",
"propertySource": {
"source": "tags.${tagName}.allowedValues.*.value"
},
"dependency": {
"type": "and",
"values": [
{
"key": "tagName",
"pattern": "^.+$"
},
{
"type": "or",
"values": [
{
"source": "tags.${tagName}",
"key": "allowedValues",
"isEmpty": true
},
{
"type": "not",
"values": [
{
"source": "tags.${tagName}",
"key": "allowedValues",
"exist": true
}
]
}
]
}
]
},
"shouldValidate": true,
"validation": {
"required": true,
"regex": "^.{0,256}$"
}
},
{
"propertyName": "Value",
"propertyKeyword": "tagValue",
"propertyTooltip": "",
"propertyType": "select",
"disabled": true,
"dependency": {
"type": "or",
"values": [
{
"key": "tagName",
"exist": false
},
{
"key": "tagName",
"pattern": "^$"
}
]
}
}
]
},
Expand Down Expand Up @@ -951,6 +1045,7 @@ making sure that you maintain a proper JSON format.
"propertyType": "group",
"propertyKeyword": "tags",
"propertyTooltip": "Creates a new stored tag or replaces an existing tag for the current database.",
"helpUrl": "https://hackolade.com/help/Snowflake.html#Tags",
"structure": [
{
"propertyName": "Name",
Expand Down
5 changes: 1 addition & 4 deletions properties_pane/defaultData.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
},
"collection": {
"collectionName": "New table",
"external": false,
"formatTypeOptions": {
"NULL_IF": [{ "NULL_IF_item": "\\N" }]
}
"external": false
},
"field": {
"name": "New column",
Expand Down
Loading

0 comments on commit 48a093c

Please sign in to comment.