Compare commits

...

4 Commits

Author SHA1 Message Date
jzhao-talend
d8e1acc4ba chore(TPS-4718):change patch date 2021-04-06 14:53:37 +08:00
jzhao-talend
fb7b116afc fix(TPS-4718):add patch note 2021-03-03 11:36:16 +08:00
Dmytro Sylaiev
4c43d0e5e1 fix(TDI-41651): Add where clause support for update query (#4172) 2021-03-03 11:22:04 +08:00
Dmytro Sylaiev
80414947b5 fix(TDI-41651): Provide possibility to specify alias for output table… (#3645)
* fix(TDI-41651): Provide possibility to specify alias for output table ELT

* Do the same fix as mssqlELT

* Small refactoring for query codeGen

* fix(TDI-41651): Fix issues

* Correct notion in javaxml file

* Rename cleanUp method

* Use stringUtils in alias for input table

* fix(TDI-41651): Add getters for inner class

* fix(TDI-41651): Add missing property in pom.xml

* fix(TDI-41651): Add missing i18n label

* fix(TDI-41651): Remove use alias for output field

* fix(TDI-41651): Fix conflicts
2021-03-03 11:21:48 +08:00
5 changed files with 133 additions and 56 deletions

63
PATCH_RELEASE_NOTE.md Normal file
View File

@@ -0,0 +1,63 @@
---
version: 7.2.1
module: https://talend.poolparty.biz/coretaxonomy/42
product:
- https://talend.poolparty.biz/coretaxonomy/23
---
# TPS-4718
| Info | Value |
| ---------------- | ---------------- |
| Patch Name | Patch\_20210409\_TPS-4718\_v1-7.2.1 |
| Release Date | 2021-04-09 |
| Target Version | 20190620_1446-V7.2.1 |
| Product affected | Talend Studio |
## Introduction
This is a self-contained patch.
**NOTE**: For information on how to obtain this patch, reach out to your Support contact at Talend.
## Fixed issues
This patch contains the following fixes:
- [7.2.1] Issue when updating snowflake table using tELTOutput (TDI-41651)
## Prerequisites
Consider the following requirements for your system:
- Talend Studio 7.2.1 must be installed.
- This patch is depend on TUP patch **TPS-4713**.
## Installation
**NOTE**: If the patch is deployed in the approach Installing the patch using Talend Studio, the folder configuration under this patch must be replaced manually.
### Installing the patch using Software update
1) Logon TAC and switch to Configuration->Software Update, then enter the correct values and save referring to the documentation: https://help.talend.com/reader/f7Em9WV_cPm2RRywucSN0Q/j9x5iXV~vyxMlUafnDejaQ
2) Switch to Software update page, where the new patch will be listed. The patch can be downloaded from here into the nexus repository.
3) On Studio Side: Logon Studio with remote mode, on the logon page the Update button is displayed: click this button to install the patch.
### Installing the patch using Talend Studio
1) Create a folder named "patches" under your studio installer directory and copy the patch .zip file to this folder.
2) Restart your studio: a window pops up, then click OK to install the patch, or restart the commandline and the patch will be installed automatically.
### Installing the patch using Commandline
Execute the following commands:
1. Talend-Studio-win-x86_64.exe -nosplash -application org.talend.commandline.CommandLine -consoleLog -data commandline-workspace startServer -p 8002 --talendDebug
2. initRemote {tac_url} -ul {TAC login username} -up {TAC login password}
3. checkAndUpdate -tu {TAC login username} -tup {TAC login password}

View File

@@ -140,7 +140,15 @@
</PARAMETERS>
<ADVANCED_PARAMETERS>
<ADVANCED_PARAMETERS>
<PARAMETER
NAME="USE_UPDATE_STATEMENT"
FIELD="CHECK"
NUM_ROW="10"
SHOW_IF="DATA_ACTION=='UPDATE'"
>
<DEFAULT>false</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>

View File

@@ -35,6 +35,7 @@ skeleton="../templates/db_output_bulk.skeleton"
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
boolean isTableNameVariable="true".equals(ElementParameterParser.getValue(node, "__IS_TABLE_NAME_VARIABLE__"));
boolean useUpdateStatement="true".equals(ElementParameterParser.getValue(node, "__USE_UPDATE_STATEMENT__"));
%>
String select_query_<%=cid %> = null;
String tableName_<%=cid%> = null;
@@ -156,21 +157,36 @@ skeleton="../templates/db_output_bulk.skeleton"
}
if(("INSERT").equals(dataAction)){
%>
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
<%
} else if (("UPDATE").equals(dataAction)){
%>
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> "
<%
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
%>
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
<%
}
%>
;
%>
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
<%
} else if (("UPDATE").equals(dataAction)){
if(useUpdateStatement){
%>
String updateQuery_<%=cid %> = select_query_<%=cid %>;
<%
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
%>
if (updateQuery_<%=cid %>.toUpperCase().contains(" WHERE ")) {
updateQuery_<%=cid %> += " AND (" + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%> + ")";
} else {
updateQuery_<%=cid %> += " WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
}
<%
}
} else {
%>
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> "
<%
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
%>
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
<%
}
%>
;
<%
}
} else if (("DELETE").equals(dataAction)){
%>
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "

View File

@@ -40,4 +40,6 @@ TABLE_ACTION.ITEM.CREATE_IF_NOT_EXISTS=Create table if not exists
TABLE_ACTION.ITEM.DROP_IF_EXISTS_AND_CREATE=Drop table if exists and create
TABLE_ACTION.ITEM.DROP_CREATE=Drop and create table
TABLE_ACTION.ITEM.NONE=None
TABLE_ACTION.NAME=Action on table
TABLE_ACTION.NAME=Action on table
USE_UPDATE_STATEMENT.NAME=Use update statement without subqueries

View File

@@ -627,7 +627,7 @@ public abstract class DbGenerationManager {
int lstSizeOutTableEntries = metadataTableEntries.size();
for (int i = 0; i < lstSizeOutTableEntries; i++) {
ExternalDbMapEntry dbMapEntry = metadataTableEntries.get(i);
String columnEntry = outTableName + DbMapSqlConstants.DOT + dbMapEntry.getName();
String columnEntry = dbMapEntry.getName();
String expression = dbMapEntry.getExpression();
expression = initExpression(component, dbMapEntry);
expression = addQuoteForSpecialChar(expression, component);
@@ -674,13 +674,6 @@ public abstract class DbGenerationManager {
// From
appendSqlQuery(sb, tabSpaceString);
appendSqlQuery(sb, DbMapSqlConstants.FROM);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, targetSchemaTable);
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
// Inner Join
appendSqlQuery(sb, tabSpaceString);
appendSqlQuery(sb, DbMapSqlConstants.INNER_JOIN);
List<ExternalDbMapTable> inputTables = data.getInputTables();
// load input table in hash
@@ -708,19 +701,14 @@ public abstract class DbGenerationManager {
if (language.unuseWithExplicitJoin().contains(joinType) && !explicitJoin) {
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, inputTable.getTableName());
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, inputTable.getAlias());
String alias = inputTable.getAlias();
if (org.apache.commons.lang.StringUtils.isNotEmpty(alias)) {
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, alias);
}
}
}
// On
if (org.apache.commons.lang.StringUtils.isNotEmpty(keyColumn)) {
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
appendSqlQuery(sb, tabSpaceString);
appendSqlQuery(sb, DbMapSqlConstants.ON);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, keyColumn);
}
// where
StringBuilder sbWhere = new StringBuilder();
this.tabSpaceString = DEFAULT_TAB_SPACE_STRING;
@@ -1014,7 +1002,7 @@ public abstract class DbGenerationManager {
*/
protected boolean buildConditions(DbMapComponent component, StringBuilder sb, ExternalDbMapTable inputTable,
boolean writeForJoin, boolean isFirstClause) {
return buildConditions(component, sb, inputTable, writeForJoin, isFirstClause, false);
return buildConditions(component, sb, inputTable, writeForJoin, isFirstClause, false);
}
/**
@@ -1324,8 +1312,8 @@ public abstract class DbGenerationManager {
}
protected String initExpression(DbMapComponent component, ExternalDbMapEntry dbMapEntry) {
String quote = getQuote(component);
String quto_mark = TalendQuoteUtils.QUOTATION_MARK;
String quote = getQuote(component);
String quto_mark = TalendQuoteUtils.QUOTATION_MARK;
String expression = dbMapEntry.getExpression();
if (expression != null) {
List<Map<String, String>> itemNameList = null;
@@ -1434,7 +1422,7 @@ public abstract class DbGenerationManager {
oriName = oriName.replaceAll("\\$", "\\\\\\$"); //$NON-NLS-1$ //$NON-NLS-2$
}
expression = expression.replaceFirst(tableValue + "\\." + co.getLabel(), //$NON-NLS-1$
tableValue + "\\." + oriName); //$NON-NLS-1$
tableValue + "\\." + oriName); //$NON-NLS-1$
expression = replaceAuotes(expression, quto_markParser, quto_mark);
}
}
@@ -1488,23 +1476,23 @@ public abstract class DbGenerationManager {
}
private String getQuote(DbMapComponent component){
String quote = TalendQuoteUtils.QUOTATION_MARK;
IElementParameter mappingPara = component.getElementParameter(EParameterName.MAPPING.getName());
if(mappingPara == null){
return quote;
}
String mapping = (String) mappingPara.getValue();
if(mapping == null){
return quote;
}
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(mapping);
if (mappingTypeRetriever == null) {
return quote;
}
Dbms dbms = mappingTypeRetriever.getDbms();
String product = dbms.getProduct();
EDatabaseTypeName type = EDatabaseTypeName.getTypeFromProductName(product);
return TalendQuoteUtils.getQuoteByDBType(type);
String quote = TalendQuoteUtils.QUOTATION_MARK;
IElementParameter mappingPara = component.getElementParameter(EParameterName.MAPPING.getName());
if(mappingPara == null){
return quote;
}
String mapping = (String) mappingPara.getValue();
if(mapping == null){
return quote;
}
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(mapping);
if (mappingTypeRetriever == null) {
return quote;
}
Dbms dbms = mappingTypeRetriever.getDbms();
String product = dbms.getProduct();
EDatabaseTypeName type = EDatabaseTypeName.getTypeFromProductName(product);
return TalendQuoteUtils.getQuoteByDBType(type);
}
private String getOriginalColumnName(String entryName, DbMapComponent component, ExternalDbMapTable table) {
@@ -1661,4 +1649,4 @@ public abstract class DbGenerationManager {
this.useDelimitedIdentifiers = useDelimitedIdentifiers;
}
}
}