-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
| 2023.01.01 | 新增GCP BigQuery/Dataflow JJS/QlikSense BI模板。
- Loading branch information
1 parent
107c103
commit bc123b8
Showing
8 changed files
with
235 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
generator-web/src/main/resources/templates/code-generator/bi/qliksense.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
//*************************** | ||
//[${classInfo.classComment} - ${classInfo.tableName}] | ||
//AUTHOR ${authorName} | ||
//HISTORY ${.now?string('yyyy-MM-dd')} | ||
//*************************** | ||
|
||
//*************************** | ||
//load all | ||
[${classInfo.tableName}]: | ||
LOAD * FROM ['LIB://QVD/${classInfo.className}.qvd'](qvd); | ||
|
||
//*************************** | ||
//load columns | ||
[${classInfo.tableName}]: | ||
LOAD | ||
<#list classInfo.fieldList as fieldItem > | ||
"${fieldItem.columnName}" as "${fieldItem.fieldName}"<#if fieldItem_has_next>,</#if> | ||
</#list> | ||
FROM | ||
['LIB://QVD/${classInfo.className}.qvd'](qvd); | ||
; | ||
|
||
//load inline | ||
[${classInfo.tableName}]: | ||
LOAD * INLINE | ||
[ | ||
<#list classInfo.fieldList as fieldItem >${fieldItem.columnName} <#if fieldItem_has_next>,</#if></#list> | ||
<#list classInfo.fieldList as fieldItem >${fieldItem.fieldName} <#if fieldItem_has_next>,</#if></#list> | ||
<#list classInfo.fieldList as fieldItem >${fieldItem.fieldComment} <#if fieldItem_has_next>,</#if></#list> | ||
]; | ||
|
||
//*************************** | ||
//load from api data connection (wrap on) | ||
LIB CONNECT TO '${classInfo.tableName}_api'; | ||
|
||
RestConnectorMasterTable: | ||
SQL SELECT | ||
"__KEY_root", | ||
(SELECT | ||
<#list classInfo.fieldList as fieldItem > | ||
"${fieldItem.columnName}" | ||
</#list> | ||
"__FK_object" | ||
FROM "object" FK "__FK_object") | ||
FROM JSON (wrap on) "root" PK "__KEY_root" | ||
// WITH CONNECTION ( | ||
// Url "https://localhost:8080/${classInfo.tableName}_api", | ||
// QUERY "page" "1", | ||
// QUERY "size" "100", | ||
// HTTPHEADER "token" "123456", | ||
// BODY "Post body here") | ||
; | ||
|
||
[${classInfo.className}]: | ||
LOAD | ||
<#list classInfo.fieldList as fieldItem > | ||
[${fieldItem.columnName}] as [${fieldItem.fieldName}] | ||
</#list> | ||
[__FK_object] AS [__KEY_root] | ||
RESIDENT RestConnectorMasterTable | ||
WHERE NOT IsNull([__FK_stores]); | ||
|
||
DROP TABLE [${classInfo.className}]; | ||
DROP TABLE RestConnectorMasterTable; | ||
|
||
//*************************** | ||
//load from api data connection (wrap off) | ||
LIB CONNECT TO '${classInfo.tableName}_api'; | ||
[${classInfo.className}]: | ||
SQL SELECT | ||
<#list classInfo.fieldList as fieldItem > | ||
[${fieldItem.fieldName}] as [${fieldItem.fieldName}]<#if fieldItem_has_next>,</#if> | ||
</#list> | ||
FROM JSON(wrap off) "${classInfo.className}" | ||
// WITH CONNECTION ( | ||
// Url "https://localhost:8080/${classInfo.tableName}_api", | ||
// QUERY "page" "1", | ||
// QUERY "size" "100", | ||
// HTTPHEADER "token" "123456", | ||
// BODY "Post body here") | ||
; | ||
|
||
//*************************** | ||
//load from sql data connection | ||
LIB CONNECT TO '${classInfo.tableName}_db'; | ||
|
||
SQL SELECT | ||
<#list classInfo.fieldList as fieldItem > | ||
[${fieldItem.columnName}] as [${fieldItem.fieldName}]<#if fieldItem_has_next>,</#if> | ||
</#list> | ||
FROM | ||
${classInfo.tableName} | ||
WHERE | ||
Create_Time > '2023-01-01 00:00:00'; |
17 changes: 17 additions & 0 deletions
17
generator-web/src/main/resources/templates/code-generator/cloud/bigquery.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
SELECT * FROM 'your_project.your_dataset.${tableName}' t | ||
order by t.id desc | ||
LIMIT 100 | ||
; | ||
|
||
SELECT * FROM 'your_project.your_dataset.${tableName}_error_records' t | ||
order by t.timestamp desc | ||
LIMIT 100 | ||
; | ||
|
||
bigquery table -> SCHEMA -> Edit as text , then input below text: | ||
[ | ||
<#list classInfo.fieldList as fieldItem > | ||
{"name":"${fieldItem.columnName}",type:"STRING","mode":"NULLABLE","description": "${fieldItem.fieldName} - ${fieldItem.fieldComment}"}<#if fieldItem_has_next>,</#if> | ||
</#list> | ||
] |
38 changes: 38 additions & 0 deletions
38
generator-web/src/main/resources/templates/code-generator/cloud/dataflowjjs.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* GCP - dataflow job jjs for [${classInfo.classComment} - ${classInfo.tableName}] | ||
* AUTHOR ${authorName} | ||
* | ||
* User-defined function (UDF) to transform events as part of a Dataflow template job. | ||
* upload to GCS and create dataflow job with this js file and method as 'process' | ||
* @param {string} inJson input Pub/Sub JSON message (stringified) | ||
* @return {string} outJson output JSON message (stringified) | ||
*/ | ||
function process(inJson) { | ||
//for local js debug | ||
//var obj = JSON.parse(JSON.stringify(inJson)); | ||
//for online jjs | ||
var obj = JSON.parse(inJson); | ||
var includePubsubMessage = obj.data && obj.attributes; | ||
var data = includePubsubMessage ? obj.data : obj; | ||
//debug and show error if you need special logic | ||
if(data.hasOwnProperty('show_error')){ | ||
throw new ERROR("show_error:"+JSON.stringify(data)) | ||
} | ||
// INSERT CUSTOM TRANSFORMATION LOGIC HERE | ||
var tableObj= {}; | ||
tableObj.insert_time=new Date().toUTCString() | ||
<#list classInfo.fieldList as fieldItem > | ||
tableObj.${fieldItem.columnName}=data.${fieldItem.fieldName} | ||
</#list> | ||
return JSON.stringify(tableObj); | ||
} | ||
|
||
//field name = field name | ||
<#list classInfo.fieldList as fieldItem > | ||
tableObj.${fieldItem.fieldName}=data.${fieldItem.fieldName} | ||
</#list> | ||
|
||
//column name = column name | ||
<#list classInfo.fieldList as fieldItem > | ||
tableObj.${fieldItem.columnName}=data.${fieldItem.columnName} | ||
</#list> |