You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Storages/ExternalStream/ExternalStreamSettings.h
+1
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,7 @@ class ASTStorage;
19
19
M(String, ssl_ca_cert_file, "", "The path of ssl ca cert file", 0) \
20
20
M(String, properties, "", "A semi-colon-separated key-value pairs for configuring the kafka client used by the external stream. A key-value pair is separated by a equal sign. Example: 'client.id=my-client-id;group.id=my-group-id'. Note, not all properties are supported, please check the document for supported properties.", 0) \
21
21
M(String, sharding_expr, "", "An expression which will be evaluated on each row of data returned by the query to calculate the an integer which will be used to determine the ID of the partition to which the row of data will be sent. If not set, data are sent to any partition randomly.", 0) \
22
+
M(String, message_key, "", "An expression which will be evaluated on each row of data returned by the query to compute a string which will be used as the message key.", 0) \
22
23
M(Bool, one_message_per_row, false, "If set to true, when send data to the Kafka external stream with row-based data format like `JSONEachRow`, it will produce one message per row.", 0) \
23
24
/* those are log related settings */ \
24
25
M(String, log_files, "", "A comma-separated list of log files", 0) \
throwException(ErrorCodes::INVALID_SETTING_VALUE, "message_key was not a valid expression, parse failed at {}, expected {}", expected.max_parsed_pos, fmt::join(expected.variants, ", "));
263
+
264
+
if (!pos->isEnd())
265
+
throwException(ErrorCodes::INVALID_SETTING_VALUE, "message_key must be a single expression, got extra characters: {}", expected.max_parsed_pos);
266
+
267
+
auto syntax_result = TreeRewriter(context).analyze(message_key_ast, storage->getInMemoryMetadata().getColumns().getAllPhysical());
268
+
auto analyzer = ExpressionAnalyzer(message_key_ast, syntax_result, context).getActions(true);
269
+
constauto & block = analyzer->getSampleBlock();
270
+
if (block.columns() != 1)
271
+
throwException(ErrorCodes::INVALID_SETTING_VALUE, "message_key expression must return exactly one column");
272
+
273
+
auto type_id = block.getByPosition(0).type->getTypeId();
274
+
if (type_id != TypeIndex::String && type_id != TypeIndex::FixedString)
275
+
throwException(ErrorCodes::INVALID_SETTING_VALUE, "message_key must have type of string");
276
+
}
277
+
231
278
/// Validate the topic still exists, specified partitions are still valid etc
0 commit comments