Skip to content

Commit 28eb25b

Browse files
committed
Add Option Config OUTPUT_KEY_NAME
1 parent 3586f28 commit 28eb25b

File tree

2 files changed

+37
-1
lines changed
  • seatunnel-connectors-v2/connector-redis/src/main/java/org/apache/seatunnel/connectors/seatunnel/redis/config
  • seatunnel-e2e/seatunnel-connector-v2-e2e/connector-redis-e2e/src/test/java/org/apache/seatunnel/e2e/connector/redis

2 files changed

+37
-1
lines changed

seatunnel-connectors-v2/connector-redis/src/main/java/org/apache/seatunnel/connectors/seatunnel/redis/config/RedisConfig.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public enum HashKeyParseMode {
8383
Options.key("output_key")
8484
.stringType()
8585
.noDefaultValue()
86-
.withDescription("The key column name. If not set will not output key as a new column.");
86+
.withDescription(
87+
"The key column name. If not set will not output key as a new column.");
8788

8889
public static final Option<RedisDataType> DATA_TYPE =
8990
Options.key("data_type")

seatunnel-e2e/seatunnel-connector-v2-e2e/connector-redis-e2e/src/test/java/org/apache/seatunnel/e2e/connector/redis/RedisTestCaseTemplateIT.java

+35
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,41 @@ public void testRedis(TestContainer container) throws IOException, InterruptedEx
229229
Assertions.assertEquals(0, jedis.llen("key_list"));
230230
}
231231

232+
@TestTemplate
233+
public void testRedisWithOutputKey(TestContainer container)
234+
throws IOException, InterruptedException {
235+
Container.ExecResult execResult =
236+
container.executeJob("/redis-with-output-key-to-redis.conf");
237+
Assertions.assertEquals(0, execResult.getExitCode());
238+
Assertions.assertEquals(100, jedis.llen("key_list"));
239+
List<String> keyList = jedis.lrange("key_list", 0, 100);
240+
for (String key : keyList) {
241+
// each content should have a new column called "origin_key"
242+
log.info(key);
243+
Assertions.assertTrue(key.contains("origin_key"));
244+
}
245+
// Clear data to prevent data duplication in the next TestContainer
246+
jedis.del("key_list");
247+
Assertions.assertEquals(0, jedis.llen("key_list"));
248+
}
249+
250+
@TestTemplate
251+
public void testRedisWithOutputKeyToConsole(TestContainer container)
252+
throws IOException, InterruptedException {
253+
Container.ExecResult execResult = container.executeJob("/redis-to-console.conf");
254+
Assertions.assertEquals(0, execResult.getExitCode());
255+
Assertions.assertEquals(100, jedis.llen("key_list"));
256+
List<String> keyList = jedis.lrange("key_list", 0, 100);
257+
for (String key : keyList) {
258+
// each content should have a new column called "origin_key"
259+
log.info(key);
260+
Assertions.assertTrue(key.contains("origin_key"));
261+
}
262+
// Clear data to prevent data duplication in the next TestContainer
263+
jedis.del("key_list");
264+
Assertions.assertEquals(0, jedis.llen("key_list"));
265+
}
266+
232267
@TestTemplate
233268
public void testRedisWithExpire(TestContainer container)
234269
throws IOException, InterruptedException {

0 commit comments

Comments
 (0)