Compare commits

...

1 Commits

Author SHA1 Message Date
Oleksandr Zhelezniak
709204470a feat(TDI-50340): bigqueryinput read timeout 2023-10-30 10:07:57 +02:00
3 changed files with 24 additions and 6 deletions

View File

@@ -39,6 +39,7 @@
String thousandsSeparator = ElementParameterParser.getValueWithJavaType(node, "__THOUSANDS_SEPARATOR__", JavaTypesManager.CHARACTER);
String decimalSeparator = ElementParameterParser.getValueWithJavaType(node, "__DECIMAL_SEPARATOR__", JavaTypesManager.CHARACTER);
final boolean forceSingleQueryExecution = ElementParameterParser.getBooleanValue(node,"__FORCE_SINGLE_QUERY_EXEC__");
final String readTimeout = ElementParameterParser.getValue(node,"__READ_TIMEOUT__");
query = query.replaceAll("\n"," ");
query = query.replaceAll("\r"," ");
@@ -210,13 +211,27 @@ globalMap.put("<%=cid%>_ERROR_MESSAGE",ee_<%=cid%>.getMessage());
if (ElementParameterParser.canEncrypt(node, "__ACCESS_TOKEN__")) {%>
final String decryptedAccessToken_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, "__ACCESS_TOKEN__")%>);
credential_<%=cid%> =
new com.google.api.client.auth.oauth2.Credential(com.google.api.client.auth.oauth2.BearerToken.authorizationHeaderAccessMethod()).setFromTokenResponse(
(new com.google.api.client.auth.oauth2.TokenResponse()).setAccessToken(decryptedAccessToken_<%=cid%>));
credential_<%=cid%> = new com.google.api.client.auth.oauth2.Credential(com.google.api.client.auth.oauth2.BearerToken.authorizationHeaderAccessMethod()) {
@Override
public void initialize(final com.google.api.client.http.HttpRequest request) throws IOException {
super.initialize(request);
<% if (readTimeout != null && !readTimeout.trim().isEmpty()) { %>
request.setReadTimeout(<%=readTimeout%>);
<% } %>
}
}
.setFromTokenResponse((new com.google.api.client.auth.oauth2.TokenResponse()).setAccessToken(decryptedAccessToken_<%=cid%>));
<%} else {%>
credential_<%=cid%> =
new com.google.api.client.auth.oauth2.Credential(com.google.api.client.auth.oauth2.BearerToken.authorizationHeaderAccessMethod()).setFromTokenResponse(
(new com.google.api.client.auth.oauth2.TokenResponse()).setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>));
credential_<%=cid%> = new com.google.api.client.auth.oauth2.Credential(com.google.api.client.auth.oauth2.BearerToken.authorizationHeaderAccessMethod()) {
@Override
public void initialize(final com.google.api.client.http.HttpRequest request) throws IOException {
super.initialize(request);
<% if (readTimeout != null && !readTimeout.trim().isEmpty()) { %>
request.setReadTimeout(<%=readTimeout%>);
<% } %>
}
}
.setFromTokenResponse((new com.google.api.client.auth.oauth2.TokenResponse()).setAccessToken(<%= ElementParameterParser.getValue(node, "__ACCESS_TOKEN__")%>));
<%}
} %>
bigqueryclient_<%=cid%> = new com.google.api.services.bigquery.Bigquery.Builder(TRANSPORT_<%=cid %>, JSON_FACTORY_<%=cid %>,credential_<%=cid%>).setApplicationName("Talend").build();

View File

@@ -237,6 +237,8 @@
<PARAMETER NAME="FORCE_SINGLE_QUERY_EXEC" FIELD="CHECK" REQUIRED="true" NUM_ROW="50">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER NAME="READ_TIMEOUT" FIELD="TEXT" REQUIRED="false" NUM_ROW="60"/>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>

View File

@@ -12,6 +12,7 @@ PROJECT_ID.NAME=Project ID
AUTHORIZATION_CODE.NAME=Authorization Code
ACCESS_TOKEN.NAME=OAuth Access Token
FORCE_SINGLE_QUERY_EXEC.NAME=Force single query execution
READ_TIMEOUT.NAME=Read timeout (ms)
QUERY.NAME=Query
SCHEMA.NAME=Schema
ENCODING.NAME=Encoding