ixtza commented on code in PR #92:
URL:
https://github.com/apache/doris-kafka-connector/pull/92#discussion_r3084313374
##########
src/main/java/org/apache/doris/kafka/connector/service/RestService.java:
##########
@@ -328,6 +331,42 @@ public static Schema getSchema(
}
}
+ public static void createTable(
+ DorisOptions dorisOptions, String db, String table, String stmt,
Logger logger) {
+ logger.trace("start create {}.{} table to doris.", db, table);
+ Object responseData = null;
+ try {
+ String tableSchemaUri =
+ String.format(QUERY_STATEMENT_API,
dorisOptions.getHttpUrl(), db);
+ HttpPost httpPost = new HttpPost(tableSchemaUri);
+ httpPost.setHeader(HttpHeaders.AUTHORIZATION,
authHeader(dorisOptions));
+
+ Map<String, Object> payloadMap = new HashMap<>();
+
+ payloadMap.put("stmt", stmt);
+
+ String payloadJsonString =
OBJECT_MAPPER.writeValueAsString(payloadMap);
+
+ StringEntity entity = new StringEntity(payloadJsonString, "UTF-8");
+
+ entity.setContentType("application/json");
+ httpPost.setEntity(entity);
+ httpPost.setHeader("Accept", "application/json");
+
+ Map<String, Object> responseMap = handleResponse(httpPost, logger);
+ responseData = responseMap.get("msg");
+ if (!"success".equalsIgnoreCase(responseData.toString())) {
+ String errMsg = "Fail to create table via Doris FE. res: " +
responseMap.toString();
+ logger.error(errMsg);
+ throw new DorisException(errMsg);
+ }
+ } catch (Exception e) {
+ String errMsg = "SchemaCreation request error," + e;
+ logger.warn(errMsg);
+ throw new SchemaChangeException("SchemaCreation request error with
" + e.getMessage());
+ }
Review Comment:
Accepted! the method is now removed, and the rest calls are now done in the
[`SchemaCreationManager.java`]
(https://github.com/apache/doris-kafka-connector/pull/92/changes/BASE..4a1c2cee6998ca155c9f21ff1c51986e15a6f8d5#diff-eead07db9d4f34222987bf9e11c65635842e34fb54218e20394eb36aeae43607R213)
the implementation follows the `SchemaChangeManager.java`, I was thinking of
creating an abstract class to hold similar method but reluctant as it would be
to much (?). Open for any input @JNSimba .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]