Skip to content

Commit 533d991

Browse files
authored
HCK-15551: improve view column comments (#330)
* use refDescription if present for view column references * add refDescription for script generation options * do not populate columnList for basic use-cases
1 parent a706510 commit 533d991

3 files changed

Lines changed: 28 additions & 11 deletions

File tree

forward_engineering/config.json

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,13 +561,23 @@
561561
"exist": false
562562
},
563563
{
564-
"key": "description",
565-
"exist": true
564+
"type": "or",
565+
"values": [
566+
{
567+
"key": "description",
568+
"exist": true
569+
},
570+
{
571+
"key": "refDescription",
572+
"exist": true
573+
}
574+
]
566575
}
567576
]
568577
},
569578
"defaultValue": {
570-
"description": ""
579+
"description": "",
580+
"refDescription": ""
571581
},
572582
"applyToValue": "ignore"
573583
},
@@ -593,8 +603,17 @@
593603
"exist": false
594604
},
595605
{
596-
"key": "description",
597-
"exist": true
606+
"type": "or",
607+
"values": [
608+
{
609+
"key": "description",
610+
"exist": true
611+
},
612+
{
613+
"key": "refDescription",
614+
"exist": true
615+
}
616+
]
598617
},
599618
{
600619
"type": "not",
@@ -609,7 +628,8 @@
609628
]
610629
},
611630
"defaultValue": {
612-
"description": ""
631+
"description": "",
632+
"refDescription": ""
613633
},
614634
"applyToValue": "separate"
615635
}

forward_engineering/helpers/viewHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function getDefaultColumnList(properties) {
101101
.reduce((columnList, [name, property]) => {
102102
columnList.push({
103103
name: `${prepareName(name)}`,
104-
comment: property.description,
104+
comment: property.refDescription || property.description,
105105
isActivated: property.isActivated,
106106
});
107107

reverse_engineering/hqlToCollectionsVisitor.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,6 @@ class Visitor extends HiveParserVisitor {
396396
const { table } = this.visitWhenExists(ctx, 'selectStatementWithCTE', {});
397397
const columns = this.visitWhenExists(ctx, 'columnNameCommentList', []);
398398
const jsonSchema = convertColumnsToJsonSchema(columns);
399-
const columnList = columns
400-
.map(column => column.name + (column.comment ? ` COMMENT '${column.comment}'` : ''))
401-
.join(', ');
402399
const columnNames = columns.map(column => column.name).join(', ');
403400
const tableProperties = this.visitWhenExists(ctx, 'tablePropertiesPrefixed');
404401

@@ -413,7 +410,7 @@ class Visitor extends HiveParserVisitor {
413410
data: {
414411
description,
415412
tableProperties,
416-
columnList,
413+
columnList: '',
417414
},
418415
};
419416
}

0 commit comments

Comments
 (0)